summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-system/gen_light_include.py
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2012-11-03 17:58:30 (GMT)
committerJames Meyer <james.meyer@operamail.com>2012-11-03 17:58:30 (GMT)
commit306d9e4bfa29faaa561d54df14a0533d034f9773 (patch)
treecd048e1ea1a5c5e82382df1cdf35505fed3fc5ed /abs/core/LinHES-system/gen_light_include.py
parentd2ee4ff86df4e9104e7465abf78b5496572a7a49 (diff)
downloadlinhes_pkgbuild-306d9e4bfa29faaa561d54df14a0533d034f9773.zip
linhes_pkgbuild-306d9e4bfa29faaa561d54df14a0533d034f9773.tar.gz
linhes_pkgbuild-306d9e4bfa29faaa561d54df14a0533d034f9773.tar.bz2
LinHES-system: add gen_light_include.py
refs #864
Diffstat (limited to 'abs/core/LinHES-system/gen_light_include.py')
-rw-r--r--abs/core/LinHES-system/gen_light_include.py55
1 files changed, 55 insertions, 0 deletions
diff --git a/abs/core/LinHES-system/gen_light_include.py b/abs/core/LinHES-system/gen_light_include.py
new file mode 100644
index 0000000..ce0ec6d
--- /dev/null
+++ b/abs/core/LinHES-system/gen_light_include.py
@@ -0,0 +1,55 @@
+#! /usr/bin/python2
+#Helper program that generates gen_is.xml thats custom to linhes.
+#Contents of gen_is.xml are read from /etc/gen_is_xml.d
+#This script should be run everytime a is.xml entry is added or removed
+
+
+import os, sys
+import glob
+
+def read_snippets(dir_name):
+ conf_snippets=""
+ try:
+ os.chdir(dir_name)
+ except:
+ print " gen_light_conf: Couldn't change dir to %s" %dir_name
+ print " Exiting"
+ sys.exit(0)
+ file_list=glob.glob("*.conf")
+ for conf_file in file_list:
+ try:
+ print " gen_light_conf: reading in %s" %conf_file
+ f=open(conf_file,'r')
+ lines=f.readlines()
+ f.close()
+ except:
+ print " gen_light_conf: Couldn't open %s for reading" %conf_file
+ print " Exiting"
+ sys.exit(1)
+ for line in lines:
+ conf_snippets+=line
+ if len(file_list) == 0:
+ print " gen_light_conf: no conf files found"
+ conf_snippets=""
+
+ return conf_snippets
+
+
+def write_conf(conf,filename):
+ try:
+ f=open(filename, 'w')
+ except:
+ print " gen_light_conf: Couldn't open %s" %(filename)
+ print " Exiting"
+ sys.exit(2)
+ f.write(conf)
+ f.close()
+
+def main():
+ filename="/etc/lighttpd/conf.include"
+ light_conf_dir="/etc/gen_light_conf.d/"
+ conf_snippets=read_snippets(light_conf_dir)
+ write_conf(conf_snippets,filename)
+
+if __name__ == "__main__":
+ main() \ No newline at end of file