X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=wamblee-upnpmonitor%2Ffiles%2Fetc%2Finit.d%2Fupnpmonitor;fp=wamblee-upnpmonitor%2Ffiles%2Fetc%2Finit.d%2Fupnpmonitor;h=0dde25e86c4d9385774843e37b3796c3eb6961bc;hb=9fcdbb28f7e1f5e2e2d0e0729271cb1305df5928;hp=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391;hpb=c2b0bc89067fda22755e884a771b809463ea8e30;p=upnpmonitor diff --git a/wamblee-upnpmonitor/files/etc/init.d/upnpmonitor b/wamblee-upnpmonitor/files/etc/init.d/upnpmonitor index e69de29..0dde25e 100755 --- a/wamblee-upnpmonitor/files/etc/init.d/upnpmonitor +++ b/wamblee-upnpmonitor/files/etc/init.d/upnpmonitor @@ -0,0 +1,99 @@ +#!/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 + +