merged master onto senslab2, manually solved conflicts in setup.py
[sfa.git] / sfa / init.d / sfa-cm
index 5fb94b3..cdddf8b 100755 (executable)
@@ -6,9 +6,6 @@
 #
 # description:   Wraps PLCAPI into the SFA compliant API
 #
-# $Id: sfa 14304 2009-07-06 20:19:51Z thierry $
-# $URL: https://svn.planet-lab.org/svn/sfa/trunk/sfa/init.d/sfa $
-#
 
 # Source config
 . /etc/sfa/sfa_config
 # source function library
 . /etc/init.d/functions
 
+init_key() {
+    # if key doesnt exist use sfa_componenet_setup to get it  
+    if [ ! -f /var/lib/sfa/server.key ]; then
+        /usr/bin/sfa_component_setup.py -k
+    fi
+}
 
 start() {
         echo -n $"Starting SFA:  "
 
         if [ "$SFA_CM_ENABLED" ]; then
             echo "Component Mgr"
-            /usr/bin/sfa-server.py -c -d $OPTIONS
+            # make sure server key (nodes private key) exists first
+            init_key
+            /usr/bin/sfa-start.py -c -d $OPTIONS
         fi
 
         RETVAL=$?
@@ -33,7 +38,7 @@ start() {
 
 stop() {
     echo -n $"Shutting down SFA: "
-    killproc sfa-server.py
+    killproc sfa-start.py
     RETVAL=$?
 
     echo