From 4c3293b79113967cfe86eab4ff6ec974f809e07e Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Thu, 4 Jun 2009 21:04:03 -0500
Subject: LinHES-config:  fix modules.mythvantage typo in ir setup. Set default
 value for templates if the variable isn't present to the shell.

---
 abs/core-testing/LinHES-config/PKGBUILD        |  2 +-
 abs/core-testing/LinHES-config/mv_ir.py        | 24 +++++++++++++++++-------
 abs/core-testing/LinHES-config/systemconfig.py |  8 +++++++-
 3 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/abs/core-testing/LinHES-config/PKGBUILD b/abs/core-testing/LinHES-config/PKGBUILD
index 58dcfd8..7bd6369 100755
--- a/abs/core-testing/LinHES-config/PKGBUILD
+++ b/abs/core-testing/LinHES-config/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=LinHES-config
 pkgver=1.0
-pkgrel=429
+pkgrel=430
 conflicts=(MythVantage-config MythVantage-config-dev LinHES-config-dev )
 pkgdesc="Install and configure your system"
 depends=(bc libstatgrab  mysql-python expect curl dnsutils parted sg3_utils nmbscan system-templates rsync python-parted )
diff --git a/abs/core-testing/LinHES-config/mv_ir.py b/abs/core-testing/LinHES-config/mv_ir.py
index 6ce549f..efc8a60 100755
--- a/abs/core-testing/LinHES-config/mv_ir.py
+++ b/abs/core-testing/LinHES-config/mv_ir.py
@@ -34,7 +34,7 @@ def scrub_modules(filename,module):
 
 def add_module(filename,module):
     logging.debug("    adding  %s to %s",module,filename)
-    cmd = ''' echo %s >> %s ''' %(module,filename)
+    cmd = ''' echo "%s" >> %s ''' %(module,filename)
     mv_common.runcmd(cmd)
 
 def unload_all_lirc():
@@ -98,7 +98,7 @@ def setup_ir_receiver(ReceiverType,TEMPLATES):
     logging.info("    Configuring receiver %s", ReceiverType)
     if ReceiverType == "Serial":
         scrub_modules("/etc/modules.mythvantage","lirc")
-        add_module("/etc/modules/.mythvantage","lirc_serial    #lirc")
+        add_module("/etc/modules.mythvantage","lirc_serial    #lirc")
         cmd = "load-modules-mythvantage.sh"
         mv_common.runcmd(cmd)
         mv_common.remove_service("igdaemon")
@@ -106,7 +106,7 @@ def setup_ir_receiver(ReceiverType,TEMPLATES):
 
     elif ReceiverType == "Usb-imon":
         scrub_modules("/etc/modules.mythvantage","lirc")
-        add_module("/etc/modules/.mythvantage","lirc_imon    #lirc")
+        add_module("/etc/modules.mythvantage","lirc_imon    #lirc")
         cmd = "load-modules-mythvantage.sh"
         mv_common.runcmd(cmd)
         mv_common.remove_service("igdaemon")
@@ -114,7 +114,18 @@ def setup_ir_receiver(ReceiverType,TEMPLATES):
 
     elif ReceiverType == "Hauppauge":
         scrub_modules("/etc/modules.mythvantage","lirc")
-        add_module("/etc/modules/.mythvantage","lirc_i2c    #lirc")
+        add_module("/etc/modules.mythvantage","lirc_i2c    #lirc")
+        mv_common.cp_and_log(TEMPLATES+"/modules/lirc_i2c.conf" ,
+                             "/etc/modprobe.d/lirc_i2c.conf")
+        cmd = "rmmod lirc_i2c"
+        mv_common.runcmd(cmd)
+        cmd = "load-modules-mythvantage.sh"
+        mv_common.runcmd(cmd)
+        mv_common.remove_service("igdaemon")
+        mv_common.remove_service("tatir")
+    elif ReceiverType == "pvr150":
+        scrub_modules("/etc/modules.mythvantage","lirc")
+        add_module("/etc/modules.mythvantage","lirc_i2c    #lirc")
         mv_common.cp_and_log(TEMPLATES+"/modules/lirc_i2c.conf" ,
                              "/etc/modprobe.d/lirc_i2c.conf")
         cmd = "rmmod lirc_i2c"
@@ -123,7 +134,6 @@ def setup_ir_receiver(ReceiverType,TEMPLATES):
         mv_common.runcmd(cmd)
         mv_common.remove_service("igdaemon")
         mv_common.remove_service("tatir")
-
     elif ReceiverType == "iguanaIR-usb":
         scrub_modules("/etc/modules.mythvantage","lirc")
         mv_common.add_service("igdaemon")
@@ -179,8 +189,8 @@ def setup_blaster_transmiter(HostBlasterType):
     elif HostBlasterType == "pvr150":
         scrub_modules("/etc/modules.mythvantage", "blaster")
         scrub_modules("/etc/modules.mythvantage", "lirc")
-        add_module("/etc/modules/.mythvantage", "lirc_pvr150    #blaster")
-        add_module("/etc/modules/.mythvantage", "lirc_pvr150    #lirc")
+        add_module("/etc/modules.mythvantage", "lirc_pvr150    #blaster")
+        add_module("/etc/modules.mythvantage", "lirc_pvr150    #lirc")
         cmd = "rmmod lirc_i2c"
         mv_common.runcmd(cmd)
         cmd = "load-modules-mythvantage.sh"
diff --git a/abs/core-testing/LinHES-config/systemconfig.py b/abs/core-testing/LinHES-config/systemconfig.py
index 77471c2..5ccaa10 100755
--- a/abs/core-testing/LinHES-config/systemconfig.py
+++ b/abs/core-testing/LinHES-config/systemconfig.py
@@ -202,7 +202,13 @@ if __name__ == "__main__":
             var, val = line.rsplit("=", 1)
             val = val.strip('"')
             systemconfig[var.strip()] = val.strip()
-    systemconfig["TEMPLATES"] = os.environ["TEMPLATES"]
+    try:
+        systemconfig["TEMPLATES"] = os.environ["TEMPLATES"]
+    except:
+        logging.critical("    *TEMPLATES is not defined")
+        logging.critical("    *using default value")
+        systemconfig["TEMPLATES"] = "/usr/MythVantage/templates"
+
     logging.debug("______START OF DEBUG______")
     main(sys.argv[1:])
     logging.debug("______cmd line options______")
-- 
cgit v0.12