recompute config files (sh and py) from xml
[sfa.git] / sfa / init.d / sfa
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$
10 # $URL$
11 #
12
13 # recompute /etc/sfa/sfa_config from the xml files
14 # not too sure this is the right place, should probably be done by sfa-config-tty..
15 xml_files="/etc/sfa/default_config.xml"
16 [ -f /etc/sfa/configs/site.xml ] && xml_files="$xml_files /etc/sfa/configs/site.xml"
17 plc-config --shell  $xml_files > /etc/sfa/sfa_config
18 plc-config --python $xml_files > /etc/sfa/sfa_config.py
19
20 # Source config
21 . /etc/sfa/sfa_config
22
23 # source function library
24 . /etc/init.d/functions
25
26
27 start() {
28         echo -n $"Starting SFA:  "
29
30         if [ "$SFA_REGISTRY_ENABLED" ]; then
31             echo "Registry"
32             daemon /usr/bin/sfa-server.py -r -d $OPTIONS
33         fi
34
35         if [ "$SFA_AGGREGATE_ENABLED" ]; then
36             echo "Aggregate"
37             daemon /usr/bin/sfa-server.py -a -d $OPTIONS
38         fi
39         
40         if [ "$SFA_SM_ENABLED" ]; then
41             echo "SliceMgr"
42             daemon /usr/bin/sfa-server.py -s -d $OPTIONS
43         fi
44
45         RETVAL=$?
46         echo
47         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sfa
48
49 }
50
51 stop() {
52     echo -n $"Shutting down SFA: "
53     killproc sfa-server.py
54     RETVAL=$?
55
56     echo
57     [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sfa
58 }
59
60
61
62 case "$1" in
63   start)
64     start
65     ;;
66   stop)
67     stop
68     ;;
69   restart|reload)
70     stop
71     start
72     ;;
73   condrestart)
74     if [ -f /var/lock/subsys/sfa ]; then
75         stop
76         start
77     fi
78     ;;
79   status)
80     status sfa
81     RETVAL=$?
82     ;;
83   *)
84     echo $"Usage: $0 {start|stop|restart|condrestart|status}"
85     exit 1
86 esac
87
88 exit $RETVAL
89