sfa-0.9-17 tag
[sfa.git] / sfa / init.d / sfa-cm
1 #!/bin/bash
2 #
3 # sfa   Wraps PLCAPI into the SFA compliant API
4 #
5 # chkconfig: 2345 5 99
6 #
7 # description:   Wraps PLCAPI into the SFA compliant API
8 #
9 # $Id: sfa 14304 2009-07-06 20:19:51Z thierry $
10 # $URL: https://svn.planet-lab.org/svn/sfa/trunk/sfa/init.d/sfa $
11 #
12
13 # Source config
14 . /etc/sfa/sfa_config
15
16 # source function library
17 . /etc/init.d/functions
18
19 init_key() {
20     # if key doesnt exist use sfa_componenet_setup to get it  
21     if [ ! -f /var/lib/sfa/server.key ]; then
22         /usr/bin/sfa_component_setup.py -k
23     fi
24 }
25
26 start() {
27         echo -n $"Starting SFA:  "
28
29         if [ "$SFA_CM_ENABLED" ]; then
30             echo "Component Mgr"
31             # make sure server key (nodes private key) exists first
32             init_key
33             /usr/bin/sfa-server.py -c -d $OPTIONS
34         fi
35
36         RETVAL=$?
37         echo
38         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sfa
39
40 }
41
42 stop() {
43     echo -n $"Shutting down SFA: "
44     killproc sfa-server.py
45     RETVAL=$?
46
47     echo
48     [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sfa
49 }
50
51
52
53 case "$1" in
54   start)
55     start
56     ;;
57   stop)
58     stop
59     ;;
60   restart|reload)
61     stop
62     start
63     ;;
64   condrestart)
65     if [ -f /var/lock/subsys/sfa ]; then
66         stop
67         start
68     fi
69     ;;
70   status)
71     status sfa
72     RETVAL=$?
73     ;;
74   *)
75     echo $"Usage: $0 {start|stop|restart|condrestart|status}"
76     exit 1
77 esac
78
79 exit $RETVAL
80