update db to contain whatever initscript file contents are in /etc/plc_sliceinitscripts
Marc Fiuczynski [Thu, 9 Jul 2009 05:54:12 +0000 (05:54 +0000)]
db-config
db-config.d/06-initscripts

index 27963a4..e69bb0c 100755 (executable)
--- a/db-config
+++ b/db-config
@@ -43,13 +43,28 @@ g_conf_files = filter(lambda conf_file: conf_file['enabled'] and \
 g_dests = [conf_file['dest'] for conf_file in g_conf_files]
 g_conf_files = dict(zip(g_dests, g_conf_files))
 
+# Get list of existing initscripts
+g_oldinitscripts = GetInitScripts()
+g_oldinitscripts = [script['name'] for script in oldinitscripts]
+
+def SetInitScript(initscript):
+    global g_oldinitscripts
+    if initscript['name'] not in g_oldinitscripts:
+        AddInitScript(initscript)
+        g_oldinitscript.append(initscript['name'])
+    else:
+        orig_initscript = g_oldinitscripts[initscript['name']]
+        initscript_id = orig_initscript['initscript_id']
+        UpdateConfFile(initscript_id, initscript)
+        
 def SetConfFile(conf_file):
     global g_conf_files, g_dests
     if conf_file['dest'] not in g_dests:
         AddConfFile(conf_file)
     else:
         orig_conf_file = g_conf_files[conf_file['dest']]
-        UpdateConfFile(orig_conf_file['conf_file_id'], conf_file)
+        conf_file_id = orig_conf_file['conf_file_id']
+        UpdateConfFile(conf_file_id, conf_file)
 
 def SetSlice(slice, tags):
     # Create or Update slice
index 7bb8c74..1cc06a3 100644 (file)
@@ -17,11 +17,5 @@ for (root, dirs, files) in os.walk("/etc/plc_sliceinitscripts"):
         default_initscripts.append({"name":name,"enabled":True,"script":script})
         file.close()
 
-# Get list of existing initscripts
-oldinitscripts = GetInitScripts()
-oldinitscripts = [script['name'] for script in oldinitscripts]
-
 for initscript in default_initscripts:
-    if initscript['name'] not in oldinitscripts:
-        AddInitScript(initscript)
-
+       SetInitScript(initscript)