finished to clean up SFA_*_TYPE and the like
[sfa.git] / 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
10 # Source config
11 . /etc/sfa/sfa_config
12
13 # source function library
14 . /etc/init.d/functions
15
16 init_key() {
17     # if key doesnt exist use sfa_componenet_setup to get it  
18     if [ ! -f /var/lib/sfa/server.key ]; then
19         /usr/bin/sfa_component_setup.py -k
20     fi
21 }
22
23 start() {
24         echo -n $"Starting SFA:  "
25
26         if [ "$SFA_CM_ENABLED" ]; then
27             echo "Component Mgr"
28             # make sure server key (nodes private key) exists first
29             init_key
30             /usr/bin/sfa-start.py -c -d $OPTIONS
31         fi
32
33         RETVAL=$?
34         echo
35         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sfa
36
37 }
38
39 stop() {
40     echo -n $"Shutting down SFA: "
41     killproc sfa-start.py
42     RETVAL=$?
43
44     echo
45     [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sfa
46 }
47
48
49
50 case "$1" in
51   start)
52     start
53     ;;
54   stop)
55     stop
56     ;;
57   restart|reload)
58     stop
59     start
60     ;;
61   condrestart)
62     if [ -f /var/lock/subsys/sfa ]; then
63         stop
64         start
65     fi
66     ;;
67   status)
68     status sfa
69     RETVAL=$?
70     ;;
71   *)
72     echo $"Usage: $0 {start|stop|restart|condrestart|status}"
73     exit 1
74 esac
75
76 exit $RETVAL
77