Merge branch 'upstreammaster'
[sfa.git] / sfa / init.d / sfa
index 4b77177..08975dc 100755 (executable)
@@ -2,13 +2,11 @@
 #
 # sfa   Wraps PLCAPI into the SFA compliant API
 #
-# chkconfig: 2345 5 99
+# hopefully right after plc
+# chkconfig: 2345 61 39
 #
 # description:   Wraps PLCAPI into the SFA compliant API
 #
-# $Id$
-# $URL$
-#
 
 # Source config
 [ -f /etc/sfa/sfa_config ] && . /etc/sfa/sfa_config
@@ -29,14 +27,14 @@ reload ()
        /etc/sfa/configs/site.xml
     )
     for file in "${files[@]}" ; do
-       if [ -n "$force" -o $file -nt /etc/sfa/plc_config.xml ] ; then
-           tmp=$(mktemp /tmp/plc_config.xml.XXXXXX)
+       if [ -n "$force" -o $file -nt /etc/sfa/sfa_config.xml ] ; then
+           tmp=$(mktemp /tmp/sfa_config.xml.XXXXXX)
            plc-config --xml "${files[@]}" >$tmp
            if [ $? -eq 0 ] ; then
-               mv $tmp /etc/sfa/plc_config.xml
-               chmod 444 /etc/sfa/plc_config.xml
+               mv $tmp /etc/sfa/sfa_config.xml
+               chmod 444 /etc/sfa/sfa_config.xml
            else
-               echo "PLC: Warning: Invalid configuration file(s) detected"
+               echo "SFA: Warning: Invalid configuration file(s) detected"
                rm -f $tmp
            fi
            break
@@ -44,52 +42,54 @@ reload ()
     done
 
     # Convert configuration to various formats
-    if [ -n "$force" -o /etc/sfa/plc_config.xml -nt /etc/sfa/plc_config ] ; then
-       plc-config --shell >/etc/sfa/plc_config
-    fi
-    if [ -n "$force" -o /etc/sfa/plc_config.xml -nt /etc/sfa/plc_config.py ] ; then
-       plc-config --python >/etc/sfa/plc_config.py
+    if [ -n "$force" -o /etc/sfa/sfa_config.xml -nt /etc/sfa/sfa_config ] ; then
+       plc-config --shell /etc/sfa/sfa_config.xml >/etc/sfa/sfa_config
     fi
-    if [ -n "$force" -o /etc/sfa/plc_config.xml -nt /etc/sfa/php/plc_config.php ] ; then
-       mkdir -p /etc/sfa/php
-       plc-config --php >/etc/sfa/php/plc_config.php
+    if [ -n "$force" -o /etc/sfa/sfa_config.xml -nt /etc/sfa/sfa_config.py ] ; then
+       plc-config --python /etc/sfa/sfa_config.xml >/etc/sfa/sfa_config.py
     fi
+#    if [ -n "$force" -o /etc/sfa/sfa_config.xml -nt /etc/sfa/php/sfa_config.php ] ; then
+#      mkdir -p /etc/sfa/php
+#      plc-config --php  /etc/sfa/sfa_config.xml >/etc/sfa/php/sfa_config.php
+#    fi
+
+    # [re]generate the sfa_component_config
+    gen-sfa-cm-config.py        
 }
 
 start() {
     
     reload
 
-    echo -n $"Starting SFA:  "
+    # install peer certs
+    action $"SFA installing peer certs" daemon /usr/bin/sfa-start.py -t -d $OPTIONS 
 
-    if [ "$SFA_REGISTRY_ENABLED" ]; then
-        echo "Registry"
-        daemon /usr/bin/sfa-server.py -r -d $OPTIONS
+    if [ "$SFA_REGISTRY_ENABLED" -eq 1 ]; then
+        action $"SFA Registry" daemon /usr/bin/sfa-start.py -r -d $OPTIONS
     fi
 
-    if [ "$SFA_AGGREGATE_ENABLED" ]; then
-        echo "Aggregate"
-        daemon /usr/bin/sfa-server.py -a -d $OPTIONS
+    if [ "$SFA_AGGREGATE_ENABLED" -eq 1 ]; then
+        action $"SFA Aggregate" daemon /usr/bin/sfa-start.py -a -d $OPTIONS
     fi
         
-    if [ "$SFA_SM_ENABLED" ]; then
-        echo "SliceMgr"
-        daemon /usr/bin/sfa-server.py -s -d $OPTIONS
+    if [ "$SFA_SM_ENABLED" -eq 1 ]; then
+        action "SFA SliceMgr" daemon /usr/bin/sfa-start.py -s -d $OPTIONS
+    fi
+
+    if [ "$SFA_FLASHPOLICY_ENABLED" -eq 1 ]; then
+        action "Flash Policy Server" daemon /usr/bin/sfa_flashpolicy.py --file="$SFA_FLASHPOLICY_CONFIG_FILE" --port=$SFA_FLASHPOLICY_PORT -d
     fi
 
     RETVAL=$?
-    echo
-    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sfa
+    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sfa-start.py
 
 }
 
 stop() {
-    echo -n $"Shutting down SFA: "
-    killproc sfa-server.py
+    action $"Shutting down SFA" killproc sfa-start.py
     RETVAL=$?
 
-    echo
-    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sfa
+    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sfa-start.py
 }
 
 
@@ -99,13 +99,13 @@ case "$1" in
     reload) reload force ;;
     restart) stop; start ;;
     condrestart)
-       if [ -f /var/lock/subsys/sfa ]; then
+       if [ -f /var/lock/subsys/sfa-start.py ]; then
             stop
             start
        fi
        ;;
     status)
-       status sfa
+       status sfa-start.py
        RETVAL=$?
        ;;
     *)