108 lines
2.7 KiB
Bash
Executable File
108 lines
2.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
### BEGIN INIT INFO
|
|
# Provides: airtime-liquidsoap
|
|
# 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: Liquidsoap daemon
|
|
### END INIT INFO
|
|
|
|
USERID=pypo
|
|
GROUPID=pypo
|
|
NAME="Liquidsoap Playout Engine"
|
|
|
|
DAEMON=/usr/lib/airtime/pypo/bin/airtime-liquidsoap
|
|
PIDFILE=/var/run/airtime-liquidsoap.pid
|
|
EXEC='/usr/bin/airtime-liquidsoap'
|
|
|
|
start () {
|
|
chown pypo:pypo /var/log/airtime/pypo
|
|
chown pypo:pypo /var/log/airtime/pypo-liquidsoap
|
|
chown pypo:pypo /etc/airtime/liquidsoap.cfg
|
|
|
|
touch $PIDFILE
|
|
chown pypo:pypo $PIDFILE
|
|
|
|
#start-stop-daemon --start --quiet --chuid $USERID:$GROUPID \
|
|
#--pidfile $PIDFILE --nicelevel -15 --startas $DAEMON
|
|
start-stop-daemon --start --quiet --chuid $USERID:$GROUPID \
|
|
--nicelevel -15 --startas $DAEMON --exec $EXEC
|
|
}
|
|
|
|
stop () {
|
|
#send term signal after 10 seconds
|
|
timeout -s9 10s /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/10/KILL/5 --quiet --pidfile $PIDFILE
|
|
start-stop-daemon --stop --oknodo --retry=TERM/10/KILL/5 --quiet --exec $EXEC
|
|
|
|
rm -f $PIDFILE
|
|
sleep 2
|
|
}
|
|
|
|
start_with_monit () {
|
|
start
|
|
monit monitor airtime-liquidsoap >/dev/null 2>&1
|
|
}
|
|
|
|
stop_with_monit() {
|
|
monit unmonitor airtime-liquidsoap >/dev/null 2>&1
|
|
stop
|
|
}
|
|
|
|
|
|
|
|
|
|
case "${1:-''}" in
|
|
'stop')
|
|
echo -n "Stopping $NAME: "
|
|
stop
|
|
echo "Done."
|
|
;;
|
|
'start')
|
|
echo -n "Starting $NAME: "
|
|
start
|
|
echo "Done."
|
|
;;
|
|
'restart')
|
|
# restart commands here
|
|
echo -n "Restarting $NAME: "
|
|
stop
|
|
start
|
|
echo "Done."
|
|
;;
|
|
|
|
'status')
|
|
if [ -f "$PIDFILE" ]; then
|
|
pid=`cat $PIDFILE`
|
|
if [ -d "/proc/$pid" ]; then
|
|
echo "$NAME is running"
|
|
exit 0
|
|
fi
|
|
fi
|
|
echo "$NAME is not running"
|
|
exit 1
|
|
;;
|
|
'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."
|
|
;;
|
|
|
|
*) # no parameter specified
|
|
echo "Usage: $SELF start|stop|restart|status"
|
|
exit 1
|
|
;;
|
|
|
|
esac
|