61b7254c972a81bf24c081a7ee28a4a691d183ed
[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 pidfile=${PIDFILE-/var/run/nm.pid}
24 lockfile=${LOCKFILE-/var/lock/subsys/nm}
25 RETVAL=0
26
27 do_start()
28 {
29     echo -n $"Starting $prog: "
30     daemon --check=nm $nm "$@"
31     RETVAL=$?
32     echo
33     [ $RETVAL -eq 0 ] && touch ${lockfile}
34     return $RETVAL
35 }
36
37 start()
38 {
39     do_start $options
40 }
41
42 stop()
43 {
44     echo -n $"Stopping $prog: "
45     killproc nm
46     RETVAL=$?
47     echo
48     [ $RETVAL -eq 0 ] && rm -f ${lockfile} ${pidfile}
49 }
50
51 restart()
52 {
53     stop
54     do_start $restartoptions
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