-since we had an accidental merge between devel and 2.1.x, I'm rounding up these changes that need to be in 2.1.x and putting them here.
151 lines
4.5 KiB
Bash
Executable file
151 lines
4.5 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
### BEGIN INIT INFO
|
|
# Provides: airtime-playout
|
|
# Required-Start: $local_fs $remote_fs $network $syslog
|
|
# 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
|
|
|
|
USERID=pypo
|
|
ROOTUSERID=root
|
|
GROUPID=pypo
|
|
NAME=Airtime\ Playout
|
|
|
|
DAEMON0=/usr/lib/airtime/pypo/bin/airtime-playout
|
|
PIDFILE0=/var/run/airtime-playout.pid
|
|
|
|
DAEMON1=/usr/lib/airtime/pypo/bin/airtime-liquidsoap
|
|
PIDFILE1=/var/run/airtime-liquidsoap.pid
|
|
|
|
liquidsoap_start () {
|
|
start-stop-daemon --start --background --quiet --chuid $USERID:$GROUPID \
|
|
--nicelevel -15 --make-pidfile --pidfile $PIDFILE1 --startas $DAEMON1
|
|
|
|
monit monitor airtime-liquidsoap >/dev/null 2>&1
|
|
}
|
|
|
|
liquidsoap_stop () {
|
|
monit unmonitor airtime-liquidsoap >/dev/null 2>&1
|
|
/usr/lib/airtime/airtime_virtualenv/bin/python /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_prepare_terminate.py
|
|
|
|
# Send TERM after 5 seconds, wait at most 30 seconds.
|
|
start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --pidfile $PIDFILE1
|
|
rm -f $PIDFILE1
|
|
}
|
|
|
|
stop_pypo () {
|
|
monit unmonitor airtime-playout >/dev/null 2>&1
|
|
|
|
# Send TERM after 5 seconds, wait at most 30 seconds.
|
|
start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --pidfile $PIDFILE0
|
|
rm -f $PIDFILE0
|
|
}
|
|
|
|
start () {
|
|
chown pypo:pypo /etc/airtime
|
|
chown pypo:pypo /etc/airtime/liquidsoap.cfg
|
|
|
|
start-stop-daemon --start --background --quiet --chuid $ROOTUSERID:$ROOTUSERID --make-pidfile --pidfile $PIDFILE0 --startas $DAEMON0
|
|
monit monitor airtime-playout >/dev/null 2>&1
|
|
|
|
liquidsoap_start
|
|
}
|
|
|
|
stop () {
|
|
# Send TERM after 5 seconds, wait at most 30 seconds.
|
|
|
|
monit unmonitor airtime-playout >/dev/null 2>&1
|
|
start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --pidfile $PIDFILE0
|
|
rm -f $PIDFILE0
|
|
|
|
liquidsoap_stop
|
|
}
|
|
|
|
monit_restart() {
|
|
|
|
start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --pidfile $PIDFILE0
|
|
rm -f $PIDFILE0
|
|
|
|
/usr/lib/airtime/airtime_virtualenv/bin/python /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_prepare_terminate.py
|
|
start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --pidfile $PIDFILE1
|
|
rm -f $PIDFILE1
|
|
|
|
start-stop-daemon --start --background --quiet --chuid $ROOTUSERID:$ROOTUSERID --make-pidfile --pidfile $PIDFILE0 --startas $DAEMON0
|
|
|
|
start-stop-daemon --start --background --quiet --chuid $USERID:$GROUPID \
|
|
--nicelevel -15 --make-pidfile --pidfile $PIDFILE1 --startas $DAEMON1
|
|
|
|
}
|
|
|
|
start_no_monit() {
|
|
start-stop-daemon --start --background --quiet --chuid $ROOTUSERID:$ROOTUSERID --make-pidfile --pidfile $PIDFILE0 --startas $DAEMON0
|
|
liquidsoap_start
|
|
}
|
|
|
|
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-no-monit')
|
|
# restart commands here
|
|
echo -n "Starting $NAME: "
|
|
start_no_monit
|
|
echo "Done."
|
|
;;
|
|
'monit-restart')
|
|
# restart commands here
|
|
echo -n "Monit Restarting $NAME: "
|
|
monit_restart
|
|
echo "Done."
|
|
;;
|
|
'status')
|
|
# status commands here
|
|
/usr/bin/airtime-check-system
|
|
;;
|
|
'stop-liquidsoap')
|
|
echo -n "Stopping Liquidsoap: "
|
|
liquidsoap_stop
|
|
echo "Done."
|
|
;;
|
|
'start-liquidsoap')
|
|
echo -n "Starting Liquidsoap: "
|
|
liquidsoap_start
|
|
echo "Done."
|
|
;;
|
|
'restart-liquidsoap')
|
|
# restart commands here
|
|
echo -n "Restarting Liquidsoap: "
|
|
liquidsoap_stop
|
|
liquidsoap_start
|
|
echo "Done."
|
|
;;
|
|
'pypo-stop')
|
|
# restart commands here
|
|
echo -n "Restarting Pypo: "
|
|
stop_pypo
|
|
echo "Done."
|
|
;;
|
|
*) # no parameter specified
|
|
echo "Usage: $SELF start|stop|restart|status"
|
|
exit 1
|
|
;;
|
|
esac
|