sintonia/python_apps/media-monitor/airtime-media-monitor-init-d

82 lines
2.0 KiB
Plaintext
Raw Normal View History

#!/bin/bash
### BEGIN INIT INFO
# Provides: airtime-media-monitor
# Required-Start: $local_fs $remote_fs $network $syslog $all
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Manage airtime-media-monitor daemon
### END INIT INFO
USERID=root
GROUPID=www-data
NAME=Airtime\ Media\ Monitor
DAEMON=/usr/lib/airtime/media-monitor/airtime-media-monitor
PIDFILE=/var/run/airtime-media-monitor.pid
start () {
start-stop-daemon --start --background --quiet --chuid $USERID:$GROUPID \
--make-pidfile --pidfile $PIDFILE --startas $DAEMON
}
stop () {
# Send TERM after 5 seconds, wait at most 30 seconds.
start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --pidfile $PIDFILE
rm -f $PIDFILE
}
start_with_monit() {
start
monit monitor airtime-media-monitor >/dev/null 2>&1
}
stop_with_monit() {
monit unmonitor airtime-media-monitor >/dev/null 2>&1
stop
}
case "${1:-''}" in
'start')
# start commands here
echo -n "Starting $NAME: "
start
echo "Done."
;;
'stop')
# stop commands here
echo -n "Stopping $NAME: "
stop
echo "Done."
;;
'restart')
# restart commands here
echo -n "Restarting $NAME: "
stop
start
echo "Done."
;;
'start-with-monit')
# restart commands here
echo -n "Starting $NAME: "
start_with_monit
echo "Done."
;;
'stop-with-monit')
# restart commands here
echo -n "Stopping $NAME: "
stop_with_monit
echo "Done."
;;
'status')
# status commands here
/usr/bin/airtime-check-system
;;
*) # no parameter specified
echo "Usage: $SELF start|stop|restart|status"
exit 1
;;
esac