From 306d9e4bfa29faaa561d54df14a0533d034f9773 Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Sat, 3 Nov 2012 12:58:30 -0500
Subject: LinHES-system: add gen_light_include.py

refs #864
---
 abs/core/LinHES-system/PKGBUILD             | 10 ++++--
 abs/core/LinHES-system/gen_light_include.py | 55 +++++++++++++++++++++++++++++
 abs/core/LinHES-system/readme_light         |  1 +
 3 files changed, 63 insertions(+), 3 deletions(-)
 create mode 100644 abs/core/LinHES-system/gen_light_include.py
 create mode 100644 abs/core/LinHES-system/readme_light

diff --git a/abs/core/LinHES-system/PKGBUILD b/abs/core/LinHES-system/PKGBUILD
index 2606cf0..a7e0ac9 100755
--- a/abs/core/LinHES-system/PKGBUILD
+++ b/abs/core/LinHES-system/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=LinHES-system
 pkgver=2
-pkgrel=118
+pkgrel=122
 arch=('i686' 'x86_64')
 MVDIR=$startdir/pkg/usr/LH
 BINDIR=$startdir/pkg/usr/bin
@@ -23,7 +23,8 @@ binfiles="LinHES-start optimize_mythdb.py
  diskspace.sh
  cacheclean lh_backend_control.sh switch_web.sh
  create_media_dirs.sh
- msg_client.py msg_daemon.py gen_is_xml.py gen_lib_xml.py
+ msg_client.py msg_daemon.py
+ gen_is_xml.py gen_lib_xml.py gen_light_include.py
  misc_recent_recordings.pl
  misc_status_config.py
  misc_status_info.sh
@@ -35,7 +36,7 @@ source=(LinHES-session
     LinHES-profile.sh $binfiles
     alsa-base myth_mtc.lr
     diskspace cacheclean.cron
-    readme_is_xml add_storage.readme
+    readme_is_xml readme_light add_storage.readme
     system-sudo.rules )
 
 build() {
@@ -61,6 +62,7 @@ build() {
         install -m644 -D $startdir/src/alsa-base $startdir/pkg/etc/modprobe.d/alsa-base.conf
         install -m644 -D $startdir/src/readme_is_xml $startdir/pkg/etc/gen_is_xml.d/readme_is_xml
         install -m644 -D $startdir/src/readme_is_xml $startdir/pkg/etc/gen_lib_xml.d/readme_gen_xml
+        install -m644 -D $startdir/src/readme_light  $startdir/pkg/etc/gen_light_conf.d/readme_gen_light
         install -m644 -D $startdir/src/add_storage.readme $startdir/pkg/etc/storage.d/readme
        # install -m755 -D $startdir/src/smolt.cron $startdir/pkg/etc/cron.weekly/smolt.cron
         install -m755 -D $startdir/src/cacheclean.cron $startdir/pkg/etc/cron.weekly/cacheclean.cron
@@ -105,6 +107,7 @@ md5sums=('07ed5c1c4cd6cac2d1307e6c3b71372b'
          '55b33e6a08eeea2a5280da0100f2c33c'
          'ea315f41dcd6c978e546c95fc05546cf'
          'ac61cc460d9e97ba1f5ef69e92cdfbe5'
+         'f3502bb7c665750da0ecdf6918f7c838'
          '06a628469051237943b7c874f2e29b8a'
          '54ebcc024db2e0ebe8121305d8926767'
          '45f46d1f9193c8dde18e56369ec29a1e'
@@ -117,5 +120,6 @@ md5sums=('07ed5c1c4cd6cac2d1307e6c3b71372b'
          '84492954db16740f949d795b74383189'
          '02c810c2f47b7c4495fdacaf54189473'
          '1e2ca4dd872a50df6b70528e06df558a'
+         '59d0602bac7e06f11abba1894acc8bb0'
          'da432d68962e109e09beb2b71c8c8571'
          '366ccb097d1c221389709485c3b2d159')
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
diff --git a/abs/core/LinHES-system/readme_light b/abs/core/LinHES-system/readme_light
new file mode 100644
index 0000000..0f35b19
--- /dev/null
+++ b/abs/core/LinHES-system/readme_light
@@ -0,0 +1 @@
+Files ending in .conf will be read by gen_light and rewrite /etc/lighttpd/conf.include
-- 
cgit v0.12

