Skip to content

Commit

Permalink
Add example init.d script
Browse files Browse the repository at this point in the history
Contributed-By: Christopher Gray
  • Loading branch information
jamesoff committed Feb 6, 2018
1 parent 7e48f62 commit f8021f2
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions scripts/init.d/simplemonitor
@@ -0,0 +1,59 @@
#!/bin/sh
# chkconfig: 234 90 10
# SimpleMonitor
#

. /etc/rc.d/init.d/functions

. /etc/sysconfig/network

[ "$NETWORKING" = "no" ] && exit 0


workdir="/usr/local/bin/simplemonitor"
appname="simplemonitor"
appbin="/usr/bin/python"
apparg="monitor.py"
appoptions="-q"
pidfile="/var/run/$appname.pid"
lockfile="/var/lock/subsys/$appname"

start() {
cd $workdir
echo -n $"Starting $appname: "
daemon --pidfile $pidfile "$appbin $apparg $appoptions &"
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch $lockfile
return $RETVAL
}

stop() {
echo -n $"Stopping $appname: "
killproc $appbin
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f $lockfile
return $RETVAL
}

case "$1" in

start)
$1
;;

stop)
$1
;;

restart)
stop
start
;;

*)
echo "Usage: /etc/init.d/simplemonitor (start|stop|restart)"
exit 1
esac
exit 0

0 comments on commit f8021f2

Please sign in to comment.