init_tempmon 1.03 KB
Newer Older
1 2
#!/bin/sh

3
DEAMON=/usr/bin/init_tempmon.py
4 5 6
PATH=/sbin:/bin:/usr/sbin:/usr/bin
NAME=init_tempmon
DESC="temperature monitor daemon"
7
SCRIPT_NAME=init_tempmon.py
8

9 10 11 12 13
# 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
14 15 16

case "$1" in
  start)
17 18 19 20
	if [ ! -f $PID_FILE ]; then
		echo -n "Starting $DESC: "
		echo $SCRIPT_NAME
		$DEAMON &
21
	else
22
		echo "Already running"
23 24 25
	fi
	;;
  stop)
26 27 28 29 30 31 32 33 34
	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
35 36
	;;
  restart)
37 38 39 40 41 42 43 44 45
	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
46 47
	;;
  status)
48 49 50
	echo -n "$NAME status: "
	if [ -f $PID_FILE ]; then
	  echo "Running"
51
	else
52
	  echo "Not running"
53 54 55 56 57 58 59 60 61 62
	fi
	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|status}" >&2
	exit 1
	;;
esac

exit 0