#!/bin/sh DEAMON=/usr/bin/init_tempmon.py PATH=/sbin:/bin:/usr/sbin:/usr/bin NAME=init_tempmon DESC="temperature monitor daemon" SCRIPT_NAME=init_tempmon.py # PID file name, must match to the name in init_tempmon.py sript PID_FILE=/var/run/init_tempmon.pid . /etc/init.d/functions test -x $DEAMON || exit 0 case "$1" in start) if [ ! -f $PID_FILE ]; then echo -n "Starting $DESC: " echo $SCRIPT_NAME $DEAMON & else echo "Already running" fi ;; stop) if [ -f $PID_FILE ]; then echo -n "Stopping $DESC: " echo "$NAME" pid=$(cat $PID_FILE) /bin/kill $pid rm $PID_FILE else echo "Not running, nothing to stop" fi ;; restart) if [ -f $PID_FILE ]; then echo -n "Restarting $DESC: " echo "$NAME" pid=$(cat $PID_FILE) /bin/kill $pid $DEAMON & else echo "Not running, nothing to restart" fi ;; status) echo -n "$NAME status: " if [ -f $PID_FILE ]; then echo "Running" else echo "Not running" fi ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop|restart|status}" >&2 exit 1 ;; esac exit 0