shebangs just in case
[nodemanager.git] / initscripts / nm
1 #!/bin/bash
2 #
3 # nm       Starts and stops Node Manager daemon
4 #
5 # chkconfig: 3 97 26
6 # description: Starts and stops Node Manager daemon
7 #
8
9 # Source function library.
10 . /etc/init.d/functions
11
12 [ -f /etc/sysconfig/nodemanager ] && . /etc/sysconfig/nodemanager
13
14 # Wait for libvirt to finish initializing
15 sleep 10
16
17 options=${OPTIONS-"-d"}
18 # turn on verbosity
19 verboseoptions=${DEBUGOPTIONS-"-v -d"}
20 # debug mode is interactive, and has faster period 
21 # run in deamon mode with service nm restardebug -d
22 debugoptions=${DEBUGOPTIONS-"-v -p 30 -r 15"}
23
24 nodemanager=${NODEMANAGER-"python /usr/share/NodeManager/nodemanager.py"}
25 prog="Node Manager"
26 pidfile=${PIDFILE-/var/run/nodemanager.pid}
27
28 RETVAL=0
29
30 function start() {
31     action $"Starting $prog: " daemon --pidfile=$pidfile --check=nodemanager $nodemanager "$@"
32 }
33
34 function stop() {
35     action $"Stopping $prog: " killproc -p $pidfile nodemanager
36 }
37
38 case "$1" in
39     start)
40         start $options
41         ;;
42     stop)
43         stop
44         ;;
45     status)
46         status -p $pidfile nodemanager
47         RETVAL=$?
48         ;;
49     restart|reload)
50         shift
51         stop
52         start $options "$@"
53         ;;
54     condrestart)
55         shift
56         [ -f ${pidfile} ] && { stop; start $options "$@"; }
57         ;;
58     restartverbose)
59         shift
60         stop
61         $nodemanager $verboseoptions "$@"
62         ;;
63     restartdebug)
64         shift
65         stop
66         echo "Restarting with $debugoptions $@ .."
67         $nodemanager $debugoptions "$@"
68         ;;
69     *)
70         echo $"Usage: $0 {start|stop|status|restart|condrestart|restartdebug [-d]}"
71         exit 1
72         ;;
73 esac
74
75 exit $RETVAL