#!/bin/bash ### BEGIN INIT INFO # Provides: airtime-show-recorder # 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-show-recorder daemon ### END INIT INFO USERID=pypo GROUPID=pypo NAME=Airtime\ Show\ Recorder DAEMON=/usr/lib/airtime/show-recorder/airtime-show-recorder PIDFILE=/var/run/airtime-show-recorder.pid start () { monit monitor airtime-show-recorder >/dev/null 2>&1 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. monit unmonitor airtime-show-recorder >/dev/null 2>&1 start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --pidfile $PIDFILE rm -f $PIDFILE } 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." ;; 'status') # status commands here /usr/bin/airtime-check-system ;; *) # no parameter specified echo "Usage: $SELF start|stop|restart|status" exit 1 ;; esac