(*) basically no operational change
[nodemanager.git] / nm.init
1 #!/bin/bash
2 #
3 # nm       Starts and stops Node Manager daemon
4 #
5 # chkconfig: 3 86 26
6 # description: Starts and stops Node Manager daemon
7 #
8
9 # Source function library.
10 . /etc/init.d/functions
11
12 if [ -f /etc/sysconfig/NodeManager ]; then
13     . /etc/sysconfig/NodeManager
14 fi
15
16 nm=${NM-"python /usr/share/NodeManager/nm.py"}
17 prog="Node Manager"
18 restartoptions=
19 pidfile=${PIDFILE-/var/run/nm.pid}
20 lockfile=${LOCKFILE-/var/lock/subsys/nm}
21 RETVAL=0
22
23 do_start()
24 {
25     echo -n $"Starting $prog: "
26     daemon --check=nm $nm "$@"
27     RETVAL=$?
28     echo
29     [ $RETVAL -eq 0 ] && touch ${lockfile}
30     return $RETVAL
31 }
32
33 start()
34 {
35     do_start ${OPTIONS-"-d -s"}
36 }
37
38 stop()
39 {
40     echo -n $"Stopping $prog: "
41     killproc nm
42     RETVAL=$?
43     echo
44     [ $RETVAL -eq 0 ] && rm -f ${lockfile} ${pidfile}
45     for i in $( vps aux | grep nm.py | awk '{print $2}' ); do
46         kill -9 $i
47     done
48
49 }
50
51 restart()
52 {
53     stop
54     do_start ${OPTIONS-"-d"}
55 }
56
57
58 case "$1" in
59     start)
60     start
61     ;;
62     stop)
63     stop
64     ;;
65     status)
66     status $nm
67     RETVAL=$?
68     ;;
69     restart|reload)
70     restart
71     ;;
72     condrestart)
73     if [ -f ${pidfile} ] ; then
74         restart
75     fi
76     ;;
77     *)
78     echo $"Usage: $0 {start|stop|restart|condrestart|status}"
79     exit 1
80 esac
81
82 exit 0