4 # description: pl_mom (daemon of death) startup script
7 CODE='/usr/local/planetlab/bin/pl_mom.pl'
10 . /etc/rc.d/init.d/functions
14 pidfile=/var/run/$PROC.pid
17 pid=`cat $pidfile 2>/dev/null`
19 # this eliminates a race condition between checking existence of pidfile
20 # and reading its value
22 [ -n "$pid" -a -d /proc/$pid ]
27 echo -n "starting $PROC:"
28 [ -r $CODE ] || action "code missing" /bin/false || exit 1
29 pid=`cat $pidfile 2>/dev/null`
30 if [ -n "$pid" ]; then
31 # check whether process really exists
32 # yes - don't try to start
33 [ -d /proc/$pid ] && action "already running" /bin/true && exit 1
35 # no - PID file is stale
43 check_status || cmd=failure
49 echo -n "shutting down $PROC: "
50 check_status && kill -TERM -`cat $pidfile` && sleep 1
52 check_status || cmd=success && rm -f $pidfile
65 check_status && echo 'running' && exit 0 || \
66 echo 'not running' && exit 1
70 echo "Usage: $0 {start|stop|restart|status}"