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