#!/bin/bash # # Author: Erik Brakkee # # init.d/upnpmonitor # # System startup script for the upnp monitor. # ### BEGIN INIT INFO # Provides: upnpmonitor # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 3 5 # Default-Stop: 0 1 2 6 # Description: Start upnpmonitor ### END INIT INFO test -s /etc/rc.status && . /etc/rc.status && rc_reset # Determine the base and follow a runlevel link name. base=${0##*/} link=${base#*[SK][0-9][0-9]} # Force execution if not called by a runlevel directory. #test $link = $base && START_GLASSFISH=yes #test "$START_UPNPMONITOR" = yes || exit 0 # setup environment [[ -r /etc/profile.local ]] && . /etc/profile.local exec=/opt/upnpmonitor/bin/upnpmonitor prog=${exec##*/} lockfile=/var/lock/upnpmonitor echo "prog = $prog" start() { echo -n "Starting upnp monitor: " if [[ ! -r "$lockfile" ]] then su upnpmonitor -c "$exec" > /var/log/upnpmonitor.log 2>&1 & pid=$! rv=$? [ $rv -eq 0 ] && echo $pid > $lockfile else rv=0 fi return $rv } stop() { echo -n "Shutting down upnpmonitor: " kill -2 $( < $lockfile ) rv=$? rm -f $lockfile return $rv } restart() { stop start } case "$1" in start|stop|restart) if ! $1 then return=$rc_failed fi rc_status -v ;; force-reload) restart ;; status) echo -n "Checking for upnp monitor status..." checkproc $prog rc_status -v ;; try-restart|condrestart) if status $prog >/dev/null ; then restart fi ;; reload) echo "Service ${0##*/} does not support the reload action " 1>&2 exit 3 ;; *) echo "Usage: $0 {start|stop|status|restart|try-restart|force-reload}" 1>&2 exit 2 ;; esac