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