#!/bin/bash
#
# take a look at /etc/rc.d/functions for a better understanding and for some
# useful functions, especially when it comes to working with daemons
. /etc/rc.conf
. /etc/rc.d/functions
# NAME is the name you want displayed when starting or stopping service
# SHORT_NAME should be a unique identifier without spaces
# COMMAND is the command to be run when starting the program
NAME="Answering Machine"
SHORT_NAME="answeringmachine"
COMMAND="cd /home/digitalpioneer/Desktop && /etc/answeringmachine/answering_machine"
case "$1" in
start)
stat_busy "Starting $NAME..."
`$COMMAND`
if [ $? -gt 0 ]; then
stat_fail
else
add_daemon $SHORT_NAME
stat_done
fi
;;
stop)
stat_busy "Stopping $NAME..."
kill -9 `pidof answering_machine`
if [ $? -gt 0 ]; then
stat_fail
else
rm_daemon $SHORT_NAME
stat_done
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
;;
esac