2011-05-31 00:55:52 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2011-06-01 20:18:58 +02:00
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Provides: airtime-playout
|
2013-05-27 19:41:36 +02:00
|
|
|
# Required-Start: $local_fs $remote_fs $network $syslog $all
|
2011-06-01 20:18:58 +02:00
|
|
|
# Required-Stop: $local_fs $remote_fs $network $syslog
|
|
|
|
# Default-Start: 2 3 4 5
|
|
|
|
# Default-Stop: 0 1 6
|
|
|
|
# Short-Description: Manage airtime-playout daemon
|
|
|
|
### END INIT INFO
|
|
|
|
|
2012-08-19 03:52:06 +02:00
|
|
|
USERID=root
|
2013-04-02 01:31:13 +02:00
|
|
|
NAME="Airtime Scheduler"
|
2011-05-31 00:55:52 +02:00
|
|
|
|
2012-08-19 03:52:06 +02:00
|
|
|
DAEMON=/usr/lib/airtime/pypo/bin/airtime-playout
|
|
|
|
PIDFILE=/var/run/airtime-playout.pid
|
2011-12-15 17:16:14 +01:00
|
|
|
|
2011-06-17 02:01:37 +02:00
|
|
|
start () {
|
2013-05-06 18:11:19 +02:00
|
|
|
mkdir -p /var/log/airtime/pypo
|
|
|
|
|
2013-04-02 01:31:13 +02:00
|
|
|
start-stop-daemon --start --background --quiet --chuid $USERID:$USERID \
|
|
|
|
--make-pidfile --pidfile $PIDFILE --startas $DAEMON
|
2011-05-31 00:55:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
stop () {
|
|
|
|
# Send TERM after 5 seconds, wait at most 30 seconds.
|
2012-08-19 03:52:06 +02:00
|
|
|
start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --pidfile $PIDFILE
|
|
|
|
rm -f $PIDFILE
|
2011-08-24 23:17:28 +02:00
|
|
|
}
|
|
|
|
|
2013-04-02 01:31:13 +02:00
|
|
|
start_with_monit() {
|
|
|
|
start
|
|
|
|
monit monitor airtime-playout >/dev/null 2>&1
|
|
|
|
}
|
|
|
|
|
|
|
|
stop_with_monit() {
|
|
|
|
monit unmonitor airtime-playout >/dev/null 2>&1
|
|
|
|
stop
|
2011-09-28 18:15:13 +02:00
|
|
|
}
|
|
|
|
|
2011-05-31 00:55:52 +02:00
|
|
|
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."
|
|
|
|
;;
|
2013-04-02 01:31:13 +02:00
|
|
|
'start-with-monit')
|
2011-09-28 18:15:13 +02:00
|
|
|
# restart commands here
|
|
|
|
echo -n "Starting $NAME: "
|
2013-04-02 01:31:13 +02:00
|
|
|
start_with_monit
|
|
|
|
echo "Done."
|
|
|
|
;;
|
|
|
|
'stop-with-monit')
|
|
|
|
# restart commands here
|
|
|
|
echo -n "Stopping $NAME: "
|
|
|
|
stop_with_monit
|
2011-09-28 18:15:13 +02:00
|
|
|
echo "Done."
|
|
|
|
;;
|
2013-04-02 01:31:13 +02:00
|
|
|
|
2011-05-31 00:55:52 +02:00
|
|
|
'status')
|
|
|
|
# status commands here
|
|
|
|
/usr/bin/airtime-check-system
|
|
|
|
;;
|
|
|
|
*) # no parameter specified
|
|
|
|
echo "Usage: $SELF start|stop|restart|status"
|
|
|
|
exit 1
|
|
|
|
;;
|
2012-08-19 03:52:06 +02:00
|
|
|
|
2011-05-31 00:55:52 +02:00
|
|
|
esac
|