1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/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