From 2ce20c77e0e643b5d60ef0dff4d689bb5a05f656 Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Sat, 6 Dec 2008 18:39:49 -0600
Subject: Add support for Autodetection of Hauppauge pvr-250 receivers.  This
 should work but I don't have a pvr-250 receiver anymore so can't fully test
 it.

If PVR-250 is found then the old Hauppauge remote is assumed to be in use.

Detection first checks for USB receivers, if no receiver is found it then checks for Hauppauge receivers.
First found remote wins, so if a USB receiver is found the Hauppauge detection is never run.

Oddly enough I never wanted to use a Hauppauage receiver again, but somehow I spent most of the adding support for it.
---
 abs/core-testing/LinHES-config/PKGBUILD            |    2 +-
 .../LinHES-config/install_functions.sh             |   37 +-
 abs/core-testing/LinHES-config/systemconfig.sh     |   19 +-
 .../LinHES-config/templates/modules/lirc_i2c.conf  |    2 +
 .../templates/remotes/hauppauge-grey/lircd.conf    |  199 +++
 .../templates/remotes/hauppauge-grey/lircrc        |  505 ++++++++
 .../templates/remotes/hauppauge-grey/preview.jpg   |  Bin 0 -> 45763 bytes
 .../LinHES-config/templates/remotes/i2c.id         |    5 +
 abs/core-testing/LinHES-system/PKGBUILD            |    4 +-
 .../LinHES-system/load-modules-mythvantage.sh      |   32 +
 abs/core-testing/runit-scripts/PKGBUILD            |    2 +-
 abs/core-testing/runit-scripts/runitscripts/1      |    2 +-
 .../runit-scripts/runitscripts/services/lircd/run  |    4 +-
 .../MythVantage-config/install_functions.sh        |   23 +
 abs/mv-core/MythVantage-config/systemconfig.sh     | 1318 ++++++++++----------
 .../templates/modules/lirc_i2c.conf                |    2 +
 .../MythVantage-config/templates/remotes/i2c.id    |    5 +
 .../runitscripts/services/lircd/run                |    6 +-
 18 files changed, 1494 insertions(+), 673 deletions(-)
 create mode 100644 abs/core-testing/LinHES-config/templates/modules/lirc_i2c.conf
 create mode 100644 abs/core-testing/LinHES-config/templates/remotes/hauppauge-grey/lircd.conf
 create mode 100644 abs/core-testing/LinHES-config/templates/remotes/hauppauge-grey/lircrc
 create mode 100644 abs/core-testing/LinHES-config/templates/remotes/hauppauge-grey/preview.jpg
 create mode 100644 abs/core-testing/LinHES-config/templates/remotes/i2c.id
 create mode 100755 abs/core-testing/LinHES-system/load-modules-mythvantage.sh
 create mode 100644 abs/mv-core/MythVantage-config/templates/modules/lirc_i2c.conf
 create mode 100644 abs/mv-core/MythVantage-config/templates/remotes/i2c.id

diff --git a/abs/core-testing/LinHES-config/PKGBUILD b/abs/core-testing/LinHES-config/PKGBUILD
index 144d96e..07ccda7 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=65
+pkgrel=84
 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 )
diff --git a/abs/core-testing/LinHES-config/install_functions.sh b/abs/core-testing/LinHES-config/install_functions.sh
index 3e7f8f8..d976dbb 100755
--- a/abs/core-testing/LinHES-config/install_functions.sh
+++ b/abs/core-testing/LinHES-config/install_functions.sh
@@ -35,7 +35,7 @@ update_db_settings Theme "$pick"
 
 
 function setupremote {
-    [ -e $BASE/etc/lircd.conf ] && mv -f $BASE/etc/lircd.conf $BASE/etc/lircd.conf.`date +%Y-%m-%d-%H-%M` 
+    [ -e $BASE/etc/lircd.conf ] && mv -f $BASE/etc/lircd.conf $BASE/etc/lircd.conf.`date +%Y-%m-%d-%H-%M`
     if [ -d $TEMPLATES/remotes/$Remotetype ]
     then
             cd $TEMPLATES/remotes/$Remotetype
@@ -50,16 +50,40 @@ function setupremote {
 	    echo "Starting with support for $Remotetype"
 	    if [ x$Remotetype = "xdvico" ]
 	    then
-	            /usr/sbin/lircd  -d /dev/usb/hiddev0 
+	            /usr/sbin/lircd  -d /dev/usb/hiddev0
 	    else
 	            /usr/sbin/lircd  -d /dev/lirc0
 	    fi
 	    [ -e /root/.mythtv ] ||  mkdir /root/.mythtv 2>/dev/null
-            ln -s /etc/lircrc /root/.mythtv/lircrc 2>/dev/null
+        ln -s /etc/lircrc /root/.mythtv/lircrc 2>/dev/null
+    else
+        echo "Couldn't open directory $TEMPLATES/remotes/$Remotetype"
     fi
 }
 
+function scan_for_hpg_receiver() {
+echo "Scanning for Hauppauge receiver"
+for hpgid in `lspci -nm  -d4444: |cut -d" " -f6-  |tr -d '"'|tr " " :`
+do
+    line=`grep $hpgid $TEMPLATES/remotes/i2c.id`
+    if [ $? = 0 ]
+    then
+        modprobe lirc_i2c
+        FoundReceiverType=`echo "$line"|cut -d"|" -f2`
+        Remotetype=`echo "$line"|cut -d"|" -f4`
+        statusline=`echo "$line"|cut -d"|" -f2,4`
+        echo "Found $statusline , $Remotetype"
+        update_db_settings  HostReceiverType $FoundReceiverType
+        setupremote
+        break
+    fi
+
+done
+}
+
+
 function scan_for_usb_remote () {
+found_remote=1
 echo "Scanning for usb receiver/remote"
 while read line
 do
@@ -68,11 +92,16 @@ do
     if [ $? = 0 ]
     then
         Remotetype=`echo "$line"|cut -d"|" -f2`
-        echo "found $Remotetype"
+        echo "Found $Remotetype"
         setupremote
+        found_remote=0
         break
     fi
 done <$BASE/$TEMPLATES/remotes/receiver_usb.id
+if [ $found_remote = 1 ]
+then
+    scan_for_hpg_receiver
+fi
 }
 
 function rest_of_network () {
diff --git a/abs/core-testing/LinHES-config/systemconfig.sh b/abs/core-testing/LinHES-config/systemconfig.sh
index 90405a7..05dfd89 100755
--- a/abs/core-testing/LinHES-config/systemconfig.sh
+++ b/abs/core-testing/LinHES-config/systemconfig.sh
@@ -163,13 +163,20 @@ function setupreceiver {
     Serial) echo "setup serial lirc"
             sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage
             echo "lirc_serial   #lirc" >> ${BASE}/etc/modules.mythvantage
-            /usr/bin/load-modules-mythvantage.sh
+            load-modules-mythvantage.sh
             ;;
     Usb-imon) echo "setup receiver-usb-imon"
               sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage
               echo "lirc_imon     #lirc" >> ${BASE}/etc/modules.mythvantage
-              /usr/bin/load-modules-mythvantage.sh
+              load-modules-mythvantage.sh
               ;;
+   Hauppauge) echo "setup hauppauge reciever (lirc_i2c)"
+              sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage
+              echo "lirc_i2c   #lirc" >> ${BASE}/etc/modules.mythvantage
+              cp $TEMPLATES/modules/lirc_i2c.conf ${BASE}/etc/modprobe.d/lirc_i2c.conf
+              rmmod lirc_i2c 2>/dev/null
+              load-modules-mythvantage.sh
+             ;;
            *)   sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage
               ;;
     esac
@@ -272,7 +279,7 @@ function setupLCD {
             ;;
     xno_lcd) echo "disabling lcd"
             sv down lcdd
-            /usr/bin/load-modules-mythvantage.sh  UNLOAD LCD
+            load-modules-mythvantage.sh  UNLOAD LCD
             sed -i -e '/.*#LCD/d' ${BASE}/etc/modules.mythvantage
             daemon_remove="lcdd $daemon_remove"
             ;;
@@ -292,7 +299,7 @@ function setupLCD {
                 cp -f $TEMPLATES/LCD/$LCDtype/LCDd.conf /etc
                # install="lcdproc $install"
                 daemon_add="lcdd $daemon_add"
-                /usr/bin/load-modules-mythvantage.sh
+                load-modules-mythvantage.sh
                 RESTART_FE="true"
                 RESTART_LCD="true"
             fi
@@ -1277,6 +1284,6 @@ case $SystemType in
             ;;
 esac
 echo $MVRELEASE > /etc/os_myth_release
-echo "systemtype=$smoltsystem" > /data/home/mythtv/.mythtv/smolt.info
-echo "remote=$Remotetype" >> /data/home/mythtv/.mythtv/smolt.info
+echo "systemtype=$smoltsystem" > /home/mythtv/.mythtv/smolt.info 2>/dev/null
+echo "remote=$Remotetype" >> /home/mythtv/.mythtv/smolt.info 2>/dev/null
 
diff --git a/abs/core-testing/LinHES-config/templates/modules/lirc_i2c.conf b/abs/core-testing/LinHES-config/templates/modules/lirc_i2c.conf
new file mode 100644
index 0000000..7b99f78
--- /dev/null
+++ b/abs/core-testing/LinHES-config/templates/modules/lirc_i2c.conf
@@ -0,0 +1,2 @@
+alias char-major-61 lirc_i2c
+options lirc_i2c debug=0 minor=3	
diff --git a/abs/core-testing/LinHES-config/templates/remotes/hauppauge-grey/lircd.conf b/abs/core-testing/LinHES-config/templates/remotes/hauppauge-grey/lircd.conf
new file mode 100644
index 0000000..c0849ef
--- /dev/null
+++ b/abs/core-testing/LinHES-config/templates/remotes/hauppauge-grey/lircd.conf
@@ -0,0 +1,199 @@
+#
+# this config file was automatically generated
+# using lirc-0.5.5pre8 on Sun Apr 18 11:43:45 1999
+#
+# contributed by Jens Leuschner <leuschner@gmx.net>
+#
+# brand:             Hauppauge
+# model:             
+# supported devices: WinTV primo; WinTV pci; WinTV radio
+#
+# This config file will work with both homebrew receivers and 
+# original Hauppauge TV cards !!!
+#
+
+begin remote
+
+  name  Hauppauge
+  bits           13
+  flags SHIFT_ENC
+  eps            30
+  aeps          100
+
+  one           950   830
+  zero          950   830
+  plead         960
+  gap          89584
+  repeat_bit      2
+
+      begin codes
+          TV                       0x000000000000100F
+          RADIO                    0x000000000000100C
+          FULL_SCREEN              0x000000000000102E
+          CH+                      0x0000000000001020
+          CH-                      0x0000000000001021
+          VOL-                     0x0000000000001011
+          VOL+                     0x0000000000001010
+          MUTE                     0x000000000000100D
+          SOURCE                   0x0000000000001022
+          1                        0x0000000000001001
+          2                        0x0000000000001002
+          3                        0x0000000000001003
+          4                        0x0000000000001004
+          5                        0x0000000000001005
+          6                        0x0000000000001006
+          7                        0x0000000000001007
+          8                        0x0000000000001008
+          9                        0x0000000000001009
+          0                        0x0000000000001000
+          RESERVED                 0x000000000000101E
+          MINIMIZE                 0x0000000000001026
+      end codes
+
+end remote
+
+
+#
+# this config file was automatically generated
+# using lirc-0.6.6(animax) on Tue Apr 15 19:50:27 2003
+#
+# contributed by 
+#
+# brand: 				Hauppauge
+# model no. of remote control: 
+# devices being controlled by this remote: PVR 2/350
+#
+
+begin remote
+
+  name  hauppauge_pvr
+  bits           13
+  flags RC5|CONST_LENGTH
+  eps            30
+  aeps          100
+
+  one           969   811
+  zero          969   811
+  plead        1097
+  gap          114605
+  toggle_bit      2
+
+
+      begin codes
+          Power                    0x00000000000017FD
+          Go                       0x00000000000017FB
+          1                        0x00000000000017C1
+          2                        0x00000000000017C2
+          3                        0x00000000000017C3
+          4                        0x00000000000017C4
+          5                        0x00000000000017C5
+          6                        0x00000000000017C6
+          7                        0x00000000000017C7
+          8                        0x00000000000017C8
+          9                        0x00000000000017C9
+          Back/Exit                0x00000000000017DF
+          0                        0x00000000000017C0
+          Menu                     0x00000000000017CD
+          Red                      0x00000000000017CB
+          Green                    0x00000000000017EE
+          Yellow                   0x00000000000017F8
+          Blue                     0x00000000000017E9
+          Ch+                      0x00000000000017E0
+          Ch-                      0x00000000000017E1
+          Vol-                     0x00000000000017D1
+          Vol+                     0x00000000000017D0
+          Ok                       0x00000000000017E5
+          Mute                     0x00000000000017CF
+          Blank                    0x00000000000017CC
+          Full                     0x00000000000017FC
+          Rewind                   0x00000000000017F2
+          Play                     0x00000000000017F5
+          Forward                  0x00000000000017F4
+          Record                   0x00000000000017F7
+          Stop                     0x00000000000017F6
+          Pause                    0x00000000000017F0
+          Replay                   0x00000000000017E4
+          Skip                     0x00000000000017DE
+      end codes
+
+end remote
+
+
+#
+# this config file was automatically generated
+# using lirc-0.7.0(any) on Sun Nov 28 20:25:09 2004
+#
+# contributed by 
+#
+# brand:   Hauppauge 350
+# Created: G.J. Werler (The Netherlands)
+# Project: Mythtv Fedora Pundit-R www.mythtvportal.com
+# Date:    2004/11/28
+# model no. of remote control: Hauppauge A415-HPG
+# devices being controlled by this remote: PVR-350
+#
+
+begin remote
+
+  name  Hauppauge_350
+  bits           13
+  flags RC5|CONST_LENGTH
+  eps            30
+  aeps          100
+
+  one           969   811
+  zero          969   811
+  plead        1097
+  gap          114605
+  toggle_bit      2
+
+
+      begin codes
+          Go                       0x00000000000017BB
+          Power                    0x00000000000017BD
+          TV                       0x000000000000179C
+          Videos                   0x0000000000001798
+          Music                    0x0000000000001799
+          Pictures                 0x000000000000179A
+          Guide                    0x000000000000179B
+          Radio                    0x000000000000178C
+          Up                       0x0000000000001794
+          Left                     0x0000000000001796
+          Right                    0x0000000000001797
+          Down                     0x0000000000001795
+          OK                       0x00000000000017A5
+          Back/Exit                0x000000000000179F
+          Menu/i                   0x000000000000178D
+          Vol+                     0x0000000000001790
+          Vol-                     0x0000000000001791
+          Prev.Ch                  0x0000000000001792
+          Mute                     0x000000000000178F
+          Ch+                      0x00000000000017A0
+          Ch-                      0x00000000000017A1
+          Record                   0x00000000000017B7
+          Stop                     0x00000000000017B6
+          Rewind                   0x00000000000017B2
+          Play                     0x00000000000017B5
+          Forward                  0x00000000000017B4
+          Replay/SkipBackward      0x00000000000017A4
+          Pause                    0x00000000000017B0
+          SkipForward              0x000000000000179E
+          1                        0x0000000000001781
+          2                        0x0000000000001782
+          3                        0x0000000000001783
+          4                        0x0000000000001784
+          5                        0x0000000000001785
+          6                        0x0000000000001786
+          7                        0x0000000000001787
+          8                        0x0000000000001788
+          9                        0x0000000000001789
+          Asterix                  0x000000000000178A
+          0                        0x0000000000001780
+          #                        0x000000000000178E
+          Red                      0x000000000000178B
+          Green                    0x00000000000017AE
+          Yellow                   0x00000000000017B8
+          Blue                     0x00000000000017A9
+      end codes
+
+end remote
diff --git a/abs/core-testing/LinHES-config/templates/remotes/hauppauge-grey/lircrc b/abs/core-testing/LinHES-config/templates/remotes/hauppauge-grey/lircrc
new file mode 100644
index 0000000..2f1e514
--- /dev/null
+++ b/abs/core-testing/LinHES-config/templates/remotes/hauppauge-grey/lircrc
@@ -0,0 +1,505 @@
+# lircrc.example.HauppaugeGrey-nativelirc
+# 2003-09-17, Robert Kulagowski
+# mailto:rkulagow@rocketmail.com
+# Save this file in ~/.mythtv/lircrc
+
+begin
+    prog = mythtv
+    button = Power
+    config = Esc
+end
+
+begin
+    prog = mythtv
+    button = Go
+# Swap the PiP windows
+    config = N
+end
+
+begin
+    prog = mythtv
+    button = 1
+    config = 1
+end
+
+begin
+    prog = mythtv
+    button = 2
+    config = 2
+end
+
+begin
+    prog = mythtv
+    button = 3
+    config = 3
+end
+
+begin
+    prog = mythtv
+    button = 4
+    config = 4
+end
+
+begin
+    prog = mythtv
+    button = 5
+    config = 5
+end
+
+begin
+    prog = mythtv
+    button = 6
+    config = 6
+end
+
+begin
+    prog = mythtv
+    button = 7
+    config = 7
+end
+
+begin
+    prog = mythtv
+    button = 8
+    config = 8
+end
+
+begin
+    prog = mythtv
+    button = 9
+    config = 9
+end
+
+begin
+    prog = mythtv
+    button = Back/Exit
+    config = Esc
+end
+
+begin
+    prog = mythtv
+    button = 0
+    config = 0
+end
+
+begin
+    prog = mythtv
+    button = Menu
+    config = M
+end
+
+# Below are keys used with the Hauppauge Grey remote
+
+begin
+   prog = mythtv
+# This is the Red key
+# We'll use it for "Delete"
+   button = Red
+   config = D
+end
+
+begin
+   prog = mythtv
+# This is the Green key
+# We'll use it for "Information"
+   button = Green
+   config = I
+end
+
+# Note the "repeat = " strings in the volume and channel.
+# This means that if you hold down the key, every nth instance will be
+# passed.  This depends on your system, so you may want to increase or
+# decrease this and see what happens.  repeat = 1 is probably too
+# fast.
+
+begin
+  prog = mythtv
+# This is the Yellow key
+# Use it as a volume key
+  button = Yellow
+  repeat = 3
+  config = F10
+end
+
+begin
+  prog = mythtv
+# This is the Blue key
+# Use it as a volume key
+  button = Blue
+  repeat = 3
+  config = F11
+end
+
+begin
+    prog = mythtv
+    button = Ch+
+# This is the "up" on the central diamond
+    repeat = 3
+    config = Up
+end
+
+begin
+    prog = mythtv
+    button = Ch-
+# This is the "down" on the central diamond
+    repeat = 3
+    config = Down
+end
+
+begin
+    prog = mythtv
+    button = Vol-
+# This is the "left" on the central diamond
+    repeat = 3
+    config = Left
+end
+
+begin
+    prog = mythtv
+    button = Vol+
+# This is the "right" on the central diamond
+    repeat = 3
+    config = Right
+end
+
+begin
+    prog = mythtv
+# Middle button on the diamond
+    button = Ok
+    config = Return
+end
+
+begin
+    prog = mythtv
+    button = Mute
+    config = F9
+end
+
+begin
+   prog = mythtv
+# Change focus for PiP (to change channel in the other window)
+   button = Blank
+   config = B
+end
+
+begin
+   prog = mythtv
+# Toggle PiP on/off
+   button = Full
+   config = V
+end
+
+begin
+    prog = mythtv
+    button = Rewind
+    config = Left
+end
+
+begin
+    prog = mythtv
+    button = Play
+    config = P
+end
+
+begin
+    prog = mythtv
+    button = Forward
+    config = Right
+end
+
+begin
+  prog = mythtv
+  button = Record
+  config = R
+end
+
+begin
+   prog = mythtv
+# Teletext
+   button = Stop
+   config = T
+end
+
+begin
+    prog = mythtv
+    button = Pause
+    config = P
+end
+
+begin
+   prog = mythtv
+   button = Replay
+# Use for backwards commercial skip
+    config = Q
+end
+
+begin
+   prog = mythtv
+   button = Skip
+# Use for forward commercial skip
+    config = Z
+end
+
+#MPlayer
+begin
+   prog = mplayer
+   button = Power
+   config = quit
+end
+
+begin
+   prog = mplayer
+   button = Menu
+   config = osd
+end
+
+begin
+   prog = mplayer
+   button = Rewind
+   config = seek -10
+   repeat = 1
+end
+
+begin
+   prog = mplayer
+   button = Forward
+   config = seek +10
+   repeat = 1
+end
+
+begin
+   prog = mplayer
+   button = Replay
+   config = seek -60
+   repeat = 1
+end
+
+begin
+   prog = mplayer
+   button = Skip
+   config = seek +60
+   repeat = 1
+end
+
+begin
+    prog = mplayer
+    button = Pause
+    config = pause
+end
+
+begin
+    prog = mplayer
+    button = Play
+    config = pause
+end
+
+begin
+   prog = mplayer
+   button = Back/Exit
+   config = quit
+end
+
+begin
+   prog = mplayer
+   button = Vol+
+   config = volume +1
+   repeat = 1
+end
+
+begin
+   prog = mplayer
+   button = Vol-
+   config = volume -1
+   repeat = 1
+end
+
+begin
+   prog = mplayer
+   button = Mute
+   config = mute
+end
+##XINE
+
+ begin
+ prog = xine
+ button = Play
+ repeat = 3
+ config = Play
+ end
+
+ begin
+ prog = xine
+ button = Stop
+ repeat = 3
+ config = Stop
+ end
+
+ begin
+ prog = xine
+ button = Back/Exit
+ config = Quit
+ end
+
+ begin
+ prog = xine
+ button = Pause
+ repeat = 3
+ config = Pause
+ end
+
+ begin
+ prog = xine
+ button = Ch+
+ repeat = 4
+ config = EventUp
+ end
+
+ begin
+ prog = xine
+ button = Ch-
+ repeat = 4
+ config = EventDown
+ end
+
+ begin
+ prog = xine
+ button = Vol-
+ repeat = 4
+ config = EventLeft
+ end
+
+ begin
+ prog = xine
+ button = Vol+
+ repeat = 4
+ config = EventRight
+ end
+
+ begin
+ prog = xine
+ button = Ok
+ repeat = 0
+ config = EventSelect
+ end
+
+ begin
+ prog = xine
+ button = Menu
+ repeat = 0
+ config = Menu
+ end
+
+ #vol down
+ begin
+ prog = xine
+ button = Yellow
+ repeat = 1
+ config = Volume-
+ end
+
+ #vol up
+ begin
+ prog = xine
+ button = Red
+ repeat = 1
+ config = Volume+
+ end
+
+ begin
+ prog = xine
+ button = Forward
+ repeat = 2
+ config = SeekRelative+30
+ end
+
+ begin
+ prog = xine
+ button = Rewind
+ repeat = 2
+ config = SeekRelative-30
+ end
+
+ #ch up
+ begin
+ prog = xine
+ button = Green
+ repeat = 1
+ config = SeekRelative+60
+ end
+
+ #ch down
+ begin
+ prog = xine
+ button = Blue
+ repeat = 1
+ config = SeekRelative-60
+ end
+
+ #sleep
+ begin
+ prog = xine
+ button = Go
+ repeat = 1
+ config = ZoomIn
+ end
+
+ #display
+ begin
+ prog = xine
+ button = Skip
+ repeat = 1
+ config = ZoomOut
+ end
+
+ #skip chapter forward
+ begin
+ prog = xine
+ button = Skip
+ repeat = 1
+ config = EventNext
+ end
+
+ #skip chapter backward
+ begin
+ prog = xine
+ button = Replay
+ repeat = 1
+ config = EventPrior
+ end
+
+ begin
+ prog = lircnav
+ button = Vol-
+ config = page_down
+ end
+
+ begin
+ prog = lircnav
+ button = Vol+
+ config = page_up
+ end
+
+ begin
+ prog = lircnav
+ button = Ch+
+ config = up
+ end
+
+ begin
+ prog = lircnav
+ button = Ch-
+ config = down
+ end
+
+ begin
+ prog = lircnav
+ button = Ok
+ config = select
+ end
+
+ begin
+ prog = lircnav
+ button = Power
+ config = quit
+ end
+
diff --git a/abs/core-testing/LinHES-config/templates/remotes/hauppauge-grey/preview.jpg b/abs/core-testing/LinHES-config/templates/remotes/hauppauge-grey/preview.jpg
new file mode 100644
index 0000000..a40a1e8
Binary files /dev/null and b/abs/core-testing/LinHES-config/templates/remotes/hauppauge-grey/preview.jpg differ
diff --git a/abs/core-testing/LinHES-config/templates/remotes/i2c.id b/abs/core-testing/LinHES-config/templates/remotes/i2c.id
new file mode 100644
index 0000000..50e89e9
--- /dev/null
+++ b/abs/core-testing/LinHES-config/templates/remotes/i2c.id
@@ -0,0 +1,5 @@
+0070:4000|Hauppauge|WinTV PVR 250|hauppauge-grey
+0070:4009|Hauppauge|WinTV PVR 250|hauppauge-grey
+0070:4801|Hauppauge|WinTV PVR 250|hauppauge-grey
+0070:4803|Hauppauge|WinTV PVR 250|hauppauge-grey
+0070:0003|Hauppauge|WinTV PVR 250|hauppauge-grey
\ No newline at end of file
diff --git a/abs/core-testing/LinHES-system/PKGBUILD b/abs/core-testing/LinHES-system/PKGBUILD
index 6403dbd..cad31f3 100644
--- a/abs/core-testing/LinHES-system/PKGBUILD
+++ b/abs/core-testing/LinHES-system/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=LinHES-system
 pkgver=1.0
-pkgrel=14
+pkgrel=17
 arch=('i686')
 MVDIR=$startdir/pkg/usr/LH
 BINDIR=$startdir/pkg/usr/bin
@@ -8,7 +8,7 @@ install=LinHES.install
 pkgdesc="scripts and things related to having a automated system"
 depends=()
 
-binfiles="LinHES-start optimize_mythdb.py myth_mtc.py myth_mtc.sh LinHES-run firstboot.sh"
+binfiles="LinHES-start optimize_mythdb.py myth_mtc.py myth_mtc.sh LinHES-run firstboot.sh load-modules-mythvantage.sh"
 
 source=(LinHES-session LinHES-profile.sh $binfiles)
 
diff --git a/abs/core-testing/LinHES-system/load-modules-mythvantage.sh b/abs/core-testing/LinHES-system/load-modules-mythvantage.sh
new file mode 100755
index 0000000..8382a29
--- /dev/null
+++ b/abs/core-testing/LinHES-system/load-modules-mythvantage.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+#/usr/bin/load-modules-mythvantage.sh  UNLOAD LCD
+. /etc/systemconfig
+
+case $1 in
+UNLOAD|unload )
+            MODULELIST=`grep /etc/modules.mythvantage $2`
+            for i in $MODULELIST
+            do
+                /sbin/rmmod $i
+            done
+
+            ;;
+
+   *)   echo "- Loading MythVantage-modules"
+        #try to load the cx88 modules
+        if [ ! x$SystemType = xFrontend_only ]
+        then
+        	/sbin/modprobe cx88-dvb 2>/dev/null
+        fi
+
+        if [ -f /etc/modules.mythvantage ]
+        then
+	       while read line
+	       do
+                module=`echo $line |cut -d# -f1`
+	           /sbin/modprobe $module
+
+	       done < /etc/modules.mythvantage
+        fi
+esac
+
diff --git a/abs/core-testing/runit-scripts/PKGBUILD b/abs/core-testing/runit-scripts/PKGBUILD
index 6df1bae..cc00956 100755
--- a/abs/core-testing/runit-scripts/PKGBUILD
+++ b/abs/core-testing/runit-scripts/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=runit-scripts
 pkgver=1.8.0
-pkgrel=18
+pkgrel=21
 pkgdesc="collection of startup scripts for runit"
 url="http://smarden.org/runit/"
 license="BSD"
diff --git a/abs/core-testing/runit-scripts/runitscripts/1 b/abs/core-testing/runit-scripts/runitscripts/1
index 748930f..b9ff184 100755
--- a/abs/core-testing/runit-scripts/runitscripts/1
+++ b/abs/core-testing/runit-scripts/runitscripts/1
@@ -2,7 +2,7 @@
 /etc/rc.sysinit
 hostname `cat /etc/hostname`
 /sbin/sysctl -p 2>/dev/null >/dev/null
-#/usr/bin/load-modules-mythvantage.sh
+/usr/LH/bin/load-modules-mythvantage.sh
 rm /etc/dhcpc/dhcpcd*.pid  2>/dev/null
 rm -f /etc/sv/frontend/.runtime/* 2>/dev/null
 rm -f /etc/runit/reboot 2>/dev/null
diff --git a/abs/core-testing/runit-scripts/runitscripts/services/lircd/run b/abs/core-testing/runit-scripts/runitscripts/services/lircd/run
index 9908256..ceda8db 100755
--- a/abs/core-testing/runit-scripts/runitscripts/services/lircd/run
+++ b/abs/core-testing/runit-scripts/runitscripts/services/lircd/run
@@ -33,7 +33,9 @@ case $ReceiverType in
 	Usb-imon)
 		DEVICE=/dev/lirc_imon	
 	;;
-
+    Hauppauge)
+        DEVICE=/dev/lirc3
+        ;;
 	*) 
 
 		DEVICE=`ls  /dev/lirc[0-9] 2>/dev/null |sort |sed '/./,$!d'|head -n 1 `
diff --git a/abs/mv-core/MythVantage-config/install_functions.sh b/abs/mv-core/MythVantage-config/install_functions.sh
index 84f9c94..1d217e9 100755
--- a/abs/mv-core/MythVantage-config/install_functions.sh
+++ b/abs/mv-core/MythVantage-config/install_functions.sh
@@ -49,9 +49,31 @@ function setupremote {
             /usr/sbin/lircd  -d /dev/lirc0
         mkdir /root/.mythtv
         ln -s /etc/lircrc /root/.mythtv/lircrc
+     else
+        echo "Couldn't open directory $TEMPLATES/remotes/$Remotetype"
     fi
 }
 
+function scan_for_hpg_receiver() {
+echo "Scanning for Hauppauge receiver"
+for hpgid in `lspci -nm  -d4444: |cut -d" " -f6-  |tr -d '"'|tr " " :`
+do
+    line=`grep $hpgid $TEMPLATES/remotes/i2c.id`
+    if [ $? = 0 ]
+    then
+        modprobe lirc_i2c
+        FoundReceiverType=`echo "$line"|cut -d"|" -f2`
+        Remotetype=`echo "$line"|cut -d"|" -f4`
+        statusline=`echo "$line"|cut -d"|" -f2,4`
+        echo "Found $statusline , $Remotetype"
+        update_db_settings  HostReceiverType $FoundReceiverType
+        setupremote
+        break
+    fi
+
+done
+}
+
 function scan_for_usb_remote () {
 echo "Scanning for usb receiver/remote"
 while read line
@@ -67,6 +89,7 @@ do
         break
     fi
 done <$BASE/$TEMPLATES/remotes/receiver_usb.id
+scan_for_hpg_receiver
 }
 
 function rest_of_network () {
diff --git a/abs/mv-core/MythVantage-config/systemconfig.sh b/abs/mv-core/MythVantage-config/systemconfig.sh
index 3fbf9b1..4885f5a 100755
--- a/abs/mv-core/MythVantage-config/systemconfig.sh
+++ b/abs/mv-core/MythVantage-config/systemconfig.sh
@@ -21,23 +21,23 @@ postfix=`cat ${BASE}/usr/local/share/mythtv/.releasetype`
 PKGBLACKLIST=$BASE/etc/blacklist.package
 
 if [ x$1 = x"Mysql_only" ]
-    then
-	rm -f /tmp/mysql.txt
-        sed -e "s/^DBHostName=.*$/DBHostName=$2/" $TEMPLATES/mysql.txt > /tmp/mysql.txt
-        exit 0
-    fi
+then
+    rm -f /tmp/mysql.txt
+    sed -e "s/^DBHostName=.*$/DBHostName=$2/" $TEMPLATES/mysql.txt > /tmp/mysql.txt
+    exit 0
+fi
 
 
 if [ -f /etc/systemconfig ]
 then
-	. /etc/systemconfig
-setup_MYTH_vars
-TEMPNET="Hostip"$default_interface
-echo $TEMPNET
-eval MYTHIP=\$${TEMPNET}
+    . /etc/systemconfig
+    setup_MYTH_vars
+    TEMPNET="Hostip"$default_interface
+    echo $TEMPNET
+    eval MYTHIP=\$${TEMPNET}
 else
-	echo "could not find /etc/systemconfig"
-	exit 1
+    echo "could not find /etc/systemconfig"
+    exit 1
 fi
 
 
@@ -47,60 +47,60 @@ fi
 
 function setupmysql  {
 #setup mysql.txt to find the database servers
-        if [ $SystemType = "Master_backend" ]
-        then
-            if [ $MYTHDHCP = 0 ]
-            then
-                #this grabs eth0, as that is all thats supported.
-#                dbhost=`ifconfig  | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'|head -n1`
-                dbhost=`ifconfig  | grep -C1 $default_interface| grep -v $default_interface | cut -d: -f2 | awk '{ print $1}'`
-                sed -e "s/^dbhost=.*$/dbhost=\"$dbhost\"/" /etc/systemconfig >/tmp/systemconfig.old
-                cp /tmp/systemconfig.old ${BASE}/etc/systemconfig
-                ##logic to change master_serverip and backend_serverip  in db
-                ${BASE}${MV_ROOT}/bin/restore_default_settings.sh  -c BECONFIG -s master -a $dbhost
-            else
+if [ $SystemType = "Master_backend" ]
+then
+    if [ $MYTHDHCP = 0 ]
+    then
+        #this grabs eth0, as that is all thats supported.
+        #                dbhost=`ifconfig  | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'|head -n1`
+        dbhost=`ifconfig  | grep -C1 $default_interface| grep -v $default_interface | cut -d: -f2 | awk '{ print $1}'`
+        sed -e "s/^dbhost=.*$/dbhost=\"$dbhost\"/" /etc/systemconfig >/tmp/systemconfig.old
+        cp /tmp/systemconfig.old ${BASE}/etc/systemconfig
+        ##logic to change master_serverip and backend_serverip  in db
+        ${BASE}${MV_ROOT}/bin/restore_default_settings.sh  -c BECONFIG -s master -a $dbhost
+    else
 
-                dbhost=$MYTHIP
-                sed -e "s/^dbhost=.*$/dbhost=\"$dbhost\"/" /etc/systemconfig >/tmp/systemconfig.old
-                cp /tmp/systemconfig.old ${BASE}/etc/systemconfig
-                #logic to change dbhost in db
-                ${BASE}${MV_ROOT}/bin/restore_default_settings.sh -c BECONFIG -s master -a $dbhost
-            fi
-        fi
+        dbhost=$MYTHIP
+        sed -e "s/^dbhost=.*$/dbhost=\"$dbhost\"/" /etc/systemconfig >/tmp/systemconfig.old
+        cp /tmp/systemconfig.old ${BASE}/etc/systemconfig
+        #logic to change dbhost in db
+        ${BASE}${MV_ROOT}/bin/restore_default_settings.sh -c BECONFIG -s master -a $dbhost
+    fi
+fi
 
-        if [ $SystemType = "Slave_backend" ]
-        then
-            if [ $MYTHDHCP = 0 ]
-            then
-                #this grabs eth0, as that is all thats supported.
-                #slavehost=`ifconfig  | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'|head -n1`
-                slavehost=`ifconfig  | grep -C1 $default_interface| grep -v $default_interface | cut -d: -f2 | awk '{ print $1}'`
-                ##logic to change backend_serverip in db
-                ${BASE}${MV_ROOT}/bin/restore_default_settings.sh  -c BECONFIG -s slave  -a $slavehost
-            else
-                slavehost=$MYTHIP
+if [ $SystemType = "Slave_backend" ]
+then
+    if [ $MYTHDHCP = 0 ]
+    then
+        #this grabs eth0, as that is all thats supported.
+        #slavehost=`ifconfig  | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'|head -n1`
+        slavehost=`ifconfig  | grep -C1 $default_interface| grep -v $default_interface | cut -d: -f2 | awk '{ print $1}'`
+        ##logic to change backend_serverip in db
+        ${BASE}${MV_ROOT}/bin/restore_default_settings.sh  -c BECONFIG -s slave  -a $slavehost
+    else
+        slavehost=$MYTHIP
 
-                #logic to change backend_serverif in db
-                ${BASE}${MV_ROOT}/bin/restore_default_settings.sh -c BECONFIG -s slave  -a $slavehost
-            fi
-        fi
+        #logic to change backend_serverif in db
+        ${BASE}${MV_ROOT}/bin/restore_default_settings.sh -c BECONFIG -s slave  -a $slavehost
+    fi
+fi
 
-        MYSQLTXT=${BASE}/usr/local/share/mythtv/mysql.txt
-        if [ $SystemType = "Standalone" ]
-        then
-            sed -e "s/^DBHostName=.*$/DBHostName="localhost"/" $TEMPLATES/mysql.txt > $MYSQLTXT
-        else
-            sed -e "s/^DBHostName=.*$/DBHostName=$dbhost/" $TEMPLATES/mysql.txt > $MYSQLTXT
-        fi
-        rm ${BASE}/data/home/mythtv/.mythtv/mysql.txt
-        rm ${BASE}${MV_ROOT}/bin/mythtv/.mythtv/mysql.txt
-        if [ -f ${BASE}/data/home/mythtv/templates/mysql.txt ]
-        then
-            cp ${BASE}/data/home/mythtv/templates/mysql.txt $MYSQLTXT
-        fi
+MYSQLTXT=${BASE}/usr/local/share/mythtv/mysql.txt
+if [ $SystemType = "Standalone" ]
+then
+    sed -e "s/^DBHostName=.*$/DBHostName="localhost"/" $TEMPLATES/mysql.txt > $MYSQLTXT
+else
+    sed -e "s/^DBHostName=.*$/DBHostName=$dbhost/" $TEMPLATES/mysql.txt > $MYSQLTXT
+fi
+rm ${BASE}/data/home/mythtv/.mythtv/mysql.txt
+rm ${BASE}${MV_ROOT}/bin/mythtv/.mythtv/mysql.txt
+if [ -f ${BASE}/data/home/mythtv/templates/mysql.txt ]
+then
+    cp ${BASE}/data/home/mythtv/templates/mysql.txt $MYSQLTXT
+fi
 
-        chmod 755 $MYSQLTXT
-        chown mythtv $MYSQLTXT
+chmod 755 $MYSQLTXT
+chown mythtv $MYSQLTXT
 
 }
 
@@ -111,28 +111,28 @@ status=$?
 
 
 
-    if [ $SystemType = "Standalone" ]
-         then
-            sed -ie "s/^#skip-networking/skip-networking/g" $BASE/$MFILE
-            if [ $status = 0 ]
-            then
-                sudo sv restart mysql
-	        echo "restarting mysql with   no network"
-            fi
+if [ $SystemType = "Standalone" ]
+then
+    sed -ie "s/^#skip-networking/skip-networking/g" $BASE/$MFILE
+    if [ $status = 0 ]
+    then
+        sudo sv restart mysql
+        echo "restarting mysql with   no network"
+    fi
 
-        fi
+fi
 
-    if [ $SystemType = "Master_backend" ]
+if [ $SystemType = "Master_backend" ]
+then
+    sed -ie "s/^skip-networking/#skip-networking/g" $BASE/$MFILE
+    if [ $status = 1 ]
     then
-          sed -ie "s/^skip-networking/#skip-networking/g" $BASE/$MFILE
-            if [ $status = 1 ]
-            then
-                sudo sv restart mysql
-		        echo "restarting mysql with network"
-            fi
-
+        sudo sv restart mysql
+        echo "restarting mysql with network"
     fi
 
+fi
+
 
 }
 
@@ -146,102 +146,110 @@ fi
 rm ${BASE}/etc/localtime
 echo $timezone
 ln -s "/usr/share/zoneinfo/$timezone"  ${BASE}/etc/localtime
-        sed -e "s~^TIMEZONE=.*$~TIMEZONE=\"${timezone}\"~" ${BASE}/etc/rc.conf > $TEMPLATES/rc.conf
+sed -e "s~^TIMEZONE=.*$~TIMEZONE=\"${timezone}\"~" ${BASE}/etc/rc.conf > $TEMPLATES/rc.conf
 
-       # echo CLOCK="UTC" > ${BASE}/etc/conf.dclock
-       # echo CLOCK_SYSTOCH="yes" >> ${BASE}/etc/conf.d/clock
-       # echo TIMEZONE="$timezone" >> ${BASE}/etc/conf.d/clock
+# echo CLOCK="UTC" > ${BASE}/etc/conf.dclock
+# echo CLOCK_SYSTOCH="yes" >> ${BASE}/etc/conf.d/clock
+# echo TIMEZONE="$timezone" >> ${BASE}/etc/conf.d/clock
 cp $TEMPLATES/rc.conf /etc/rc.conf
 
 }
 
 
 function setupreceiver {
-   case $ReceiverType in
+case $ReceiverType in
     tinker) echo "do nothing"
-            ;;
+    ;;
     Serial) echo "setup serial lirc"
-            sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage
-            echo "lirc_serial   #lirc" >> ${BASE}/etc/modules.mythvantage
-            /usr/bin/load-modules-mythvantage.sh
-            ;;
+    sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage
+    echo "lirc_serial   #lirc" >> ${BASE}/etc/modules.mythvantage
+    /usr/bin/load-modules-mythvantage.sh
+    ;;
     Usb-imon) echo "setup receiver-usb-imon"
-              sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage
-              echo "lirc_imon     #lirc" >> ${BASE}/etc/modules.mythvantage
-              /usr/bin/load-modules-mythvantage.sh
-              ;;
-           *)   sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage
-              ;;
-    esac
+    sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage
+    echo "lirc_imon     #lirc" >> ${BASE}/etc/modules.mythvantage
+    /usr/bin/load-modules-mythvantage.sh
+    ;;
+    Hauppauge) echo "setup hauppauge reciever (lirc_i2c)"
+    sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage
+    echo "lirc_i2c   #lirc" >> ${BASE}/etc/modules.mythvantage
+    cp $TEMPLATES/modules/lirc_i2c.conf ${BASE}/etc/modprobe.d/lirc_i2c.conf
+    rmmod lirc_i2c 2>/dev/null
+    load-modules-mythvantage.sh
+    ;;
+
+    *)   sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage
+    ;;
+esac
 
 
 }
 
 function setupremote {
-     case $Remotetype in
-        no_remote) echo "No remote selected"
-                daemon_remove="lircd $daemon_remove"
-                ;;
-        tinker) echo "Remote in tinker mode"
-                ;;
-            *)  echo "Setup remote"
-                mv ${BASE}/etc/lircd.conf ${BASE}/etc/lircd.conf.`date +%Y-%m-%d-%H-%M`
-                cd $TEMPLATES/remotes/$Remotetype
-                for i in lircd*
-                do
-                        cat $i >> ${BASE}/etc/lircd.conf
-                done
-                cp lircrc ${BASE}/etc/lircrc
-                if [ -f $TEMPLATES/LCD/$LCDtype/lircrc ]
-                then
-                    cat $TEMPLATES/LCD/$LCDtype/lircrc >> /etc/lircrc
-                    cat $TEMPLATES/LCD/$LCDtype/lircd.conf >> /etc/lircd.conf
-                fi
-                if [ -f $TEMPLATES/transmit/$Blastertype/lircd.conf ]
-                then
-                    cat $TEMPLATES/transmit/$Blastertype/lircd.conf  >> ${BASE}/etc/lircd.conf
-                fi
-                chmod 755 /etc/lircrc
-                daemon_add="lircd $daemon_add"
-                sv hup lircd
-                ;;
+case $Remotetype in
+    no_remote) echo "No remote selected"
+    daemon_remove="lircd $daemon_remove"
+    ;;
+    tinker) echo "Remote in tinker mode"
+    ;;
+    *)  echo "Setup remote"
+    mv ${BASE}/etc/lircd.conf ${BASE}/etc/lircd.conf.`date +%Y-%m-%d-%H-%M`
+    cd $TEMPLATES/remotes/$Remotetype
+    for i in lircd*
+    do
+        cat $i >> ${BASE}/etc/lircd.conf
+    done
+    cp lircrc ${BASE}/etc/lircrc
+    if [ -f $TEMPLATES/LCD/$LCDtype/lircrc ]
+    then
+        cat $TEMPLATES/LCD/$LCDtype/lircrc >> /etc/lircrc
+        cat $TEMPLATES/LCD/$LCDtype/lircd.conf >> /etc/lircd.conf
+    fi
+    if [ -f $TEMPLATES/transmit/$Blastertype/lircd.conf ]
+    then
+        cat $TEMPLATES/transmit/$Blastertype/lircd.conf  >> ${BASE}/etc/lircd.conf
+    fi
+    chmod 755 /etc/lircrc
+    daemon_add="lircd $daemon_add"
+    sv hup lircd
+    ;;
 esac
 
 }
 
 function setupblaster {
-        #cd $TEMPLATES/transmit/$Blastertype
-        #for i in lircd*
-        #do
-         #       cat lircd.conf  >> ${BASE}/etc/lircd.conf
-        #done
-      #  REMOTE_NAME${BASE}/usr/bin/change_chan.sh=`grep name lircd.conf* |awk -F" " ' { print $2 } '`
-         sed -e "s/^REMOTE_NAME=.*$/REMOTE_NAME=${Blastertype} /" $TEMPLATES/change_chan.sh > ${BASE}/usr/bin/change_chan.sh
-          chmod 755 ${BASE}/usr/bin/change_chan.sh
-        #channel change script change
-        setupremote
+#cd $TEMPLATES/transmit/$Blastertype
+#for i in lircd*
+#do
+#       cat lircd.conf  >> ${BASE}/etc/lircd.conf
+#done
+#  REMOTE_NAME${BASE}/usr/bin/change_chan.sh=`grep name lircd.conf* |awk -F" " ' { print $2 } '`
+sed -e "s/^REMOTE_NAME=.*$/REMOTE_NAME=${Blastertype} /" $TEMPLATES/change_chan.sh > ${BASE}/usr/bin/change_chan.sh
+chmod 755 ${BASE}/usr/bin/change_chan.sh
+#channel change script change
+setupremote
 
 }
 
 function setupevrouter {
-    if [  x$UseEvrouter  = x1 ]
-    then
-        case x$EvrouterConfig in
-            xtinker )
-                    echo "do nothing for evrouter"
-                    ;;
-                x ) echo "empty evrouter"
-                    ;;
-                * ) echo "setup evrouter for $EvrouterConfig "
-                    cp $TEMPLATES/evrouter/$EvrouterConfig /etc/evrouter.cfg
-                    daemon_add="evrouter Xvfb $daemon_remove"
-
-                    ;;
-        esac
-    else
+if [  x$UseEvrouter  = x1 ]
+then
+    case x$EvrouterConfig in
+        xtinker )
+        echo "do nothing for evrouter"
+        ;;
+        x ) echo "empty evrouter"
+        ;;
+        * ) echo "setup evrouter for $EvrouterConfig "
+        cp $TEMPLATES/evrouter/$EvrouterConfig /etc/evrouter.cfg
+        daemon_add="evrouter Xvfb $daemon_remove"
+
+        ;;
+    esac
+else
     # disable evrouter
     daemon_remove="evrouter Xvfb $daemon_remove"
-    fi
+fi
 
 
 
@@ -249,64 +257,64 @@ function setupevrouter {
 }
 
 function setupLCD {
-   case x$LCDtype in
+case x$LCDtype in
     xtinker) echo "do nothing"
-            ;;
+    ;;
     xno_lcd) echo "disabling lcd"
-            sv down lcdd
-            /usr/bin/load-modules-mythvantage.sh  UNLOAD LCD
-            sed -i -e '/.*#LCD/d' ${BASE}/etc/modules.mythvantage
-            daemon_remove="lcdd $daemon_remove"
-            ;;
-        x) echo "empty lcd" ;;
+    sv down lcdd
+    /usr/bin/load-modules-mythvantage.sh  UNLOAD LCD
+    sed -i -e '/.*#LCD/d' ${BASE}/etc/modules.mythvantage
+    daemon_remove="lcdd $daemon_remove"
+    ;;
+    x) echo "empty lcd" ;;
 
-         *) echo "setup lcd"
-            if [ -f $TEMPLATES/LCD/$LCDtype/modules  ]
-            then
-              sed -i -e '/.*#LCD/d' ${BASE}/etc/modules.mythvantage
-              cat $TEMPLATES/LCD/$LCDtype/modules >> ${BASE}/etc/modules.mythvantage
-              #should also modprobe
-            fi
+    *) echo "setup lcd"
+    if [ -f $TEMPLATES/LCD/$LCDtype/modules  ]
+    then
+        sed -i -e '/.*#LCD/d' ${BASE}/etc/modules.mythvantage
+        cat $TEMPLATES/LCD/$LCDtype/modules >> ${BASE}/etc/modules.mythvantage
+        #should also modprobe
+    fi
 
 
-            if [ -f $TEMPLATES/LCD/$LCDtype/LCDd.conf ]
-            then
-                cp -f $TEMPLATES/LCD/$LCDtype/LCDd.conf /etc
-               # install="lcdproc $install"
-                daemon_add="lcdd $daemon_add"
-                /usr/bin/load-modules-mythvantage.sh
-                RESTART_FE="true"
-                RESTART_LCD="true"
-            fi
-            #check if lirc capable,if so then call setupremote
-            if [ -f $TEMPLATES/LCD/$LCDtype/lircrc ]
-            then
-                setupremote
-            fi
-            ;;
-    esac
+    if [ -f $TEMPLATES/LCD/$LCDtype/LCDd.conf ]
+    then
+        cp -f $TEMPLATES/LCD/$LCDtype/LCDd.conf /etc
+        # install="lcdproc $install"
+        daemon_add="lcdd $daemon_add"
+        /usr/bin/load-modules-mythvantage.sh
+        RESTART_FE="true"
+        RESTART_LCD="true"
+    fi
+    #check if lirc capable,if so then call setupremote
+    if [ -f $TEMPLATES/LCD/$LCDtype/lircrc ]
+    then
+        setupremote
+    fi
+    ;;
+esac
 
 }
 
 
 
 function scrubnfs {
-	   cp /etc/fstab $TEMPLATES/fstab.conf.template
-       grep -v nfs   $TEMPLATES/fstab.conf.template > ${BASE}/etc/fstab
+cp /etc/fstab $TEMPLATES/fstab.conf.template
+grep -v nfs   $TEMPLATES/fstab.conf.template > ${BASE}/etc/fstab
    }
 
-function setupfstab () {
-#    	setupfstab $NFSserver $NFSshare $NFSmount
-         echo "$1 $2  nfs" >> ${BASE}/etc/fstab
-         if [ ! -e "$2" ]
-         then
-           mkdir -p "$2"
-           chown mythtv:mythtv "$2"
-         fi
-         if [ x$DCONFIG = x  ]
-         then
-            mount $2 &
-        fi
+   function setupfstab () {
+   #    	setupfstab $NFSserver $NFSshare $NFSmount
+   echo "$1 $2  nfs" >> ${BASE}/etc/fstab
+   if [ ! -e "$2" ]
+   then
+       mkdir -p "$2"
+       chown mythtv:mythtv "$2"
+   fi
+   if [ x$DCONFIG = x  ]
+   then
+       mount $2 &
+   fi
 
 }
 
@@ -316,8 +324,8 @@ function setupncidclient
 }
 
 function setupnciddaemon {
-    cp -f /etc/ncid/ncidd.conf $TEMPLATES/ncidd.conf.template
-    sed -e "s/.*set ttyport.*$/set ttyport =  \/dev\/$nciddSerialPort /" $TEMPLATES/ncidd.conf.template >${BASE}/etc/ncid/ncidd.conf
+cp -f /etc/ncid/ncidd.conf $TEMPLATES/ncidd.conf.template
+sed -e "s/.*set ttyport.*$/set ttyport =  \/dev\/$nciddSerialPort /" $TEMPLATES/ncidd.conf.template >${BASE}/etc/ncid/ncidd.conf
 
 }
 
@@ -337,18 +345,18 @@ restrict 10.0.0.0 mask 255.0.00 nomodify
 
 #servers to sync with
 EOF
-        #this is used for backend or standlone types
-        if [ $1 = "1" ]
-                then
-                        echo "server ntp1.cs.wisc.edu" >> ${BASE}/etc/ntp.conf
-                        echo "server ntp3.sf-bay.org"  >> ${BASE}/etc/ntp.conf
-                        echo "restrict ntp1.cs.wisc.edu noquery nomodify" >> ${BASE}/etc/ntp.conf
-                        echo "restrict ntp3.sf-bay.org noquery nomodify" >> ${BASE}/etc/ntp.conf
+#this is used for backend or standlone types
+if [ $1 = "1" ]
+then
+    echo "server ntp1.cs.wisc.edu" >> ${BASE}/etc/ntp.conf
+    echo "server ntp3.sf-bay.org"  >> ${BASE}/etc/ntp.conf
+    echo "restrict ntp1.cs.wisc.edu noquery nomodify" >> ${BASE}/etc/ntp.conf
+    echo "restrict ntp3.sf-bay.org noquery nomodify" >> ${BASE}/etc/ntp.conf
 
-                else
-                        echo "server $dbhost" >> ${BASE}/etc/ntp.conf
-                        echo "restrict $dbhost noquery nomodify" >> ${BASE}/etc/ntp.conf
-                fi
+else
+    echo "server $dbhost" >> ${BASE}/etc/ntp.conf
+    echo "restrict $dbhost noquery nomodify" >> ${BASE}/etc/ntp.conf
+fi
 
 
 }
@@ -360,19 +368,19 @@ pkglistremove=""
 #default enabled
 for i in mythcontrols mythgallery mythmovietime mythmusic mythsmolt mythvideo
 do
-eval pkgvalue=\$${i}
+    eval pkgvalue=\$${i}
 
-if [ x$pkgvalue = x ]
- then
-     pkglistinstall="$pkglistinstall $i$postfix"
-     else
-     if [ x$pkgvalue = x1 ]
-     then
-         pkglistinstall="$pkglistinstall $i$postfix"
-     else
-         pkglistremove="$pkglistremove $i$postfix"
-     fi
- fi
+    if [ x$pkgvalue = x ]
+    then
+        pkglistinstall="$pkglistinstall $i$postfix"
+    else
+        if [ x$pkgvalue = x1 ]
+        then
+            pkglistinstall="$pkglistinstall $i$postfix"
+        else
+            pkglistremove="$pkglistremove $i$postfix"
+        fi
+    fi
 
 
 
@@ -381,38 +389,38 @@ done
 
 
 #default disabled
- for i in mythphone mytharchive mythbrowser mythnews mythgame mythflix mythweather
- do
-eval pkgvalue=\$${i}
-
-if [ x$pkgvalue = x ]
- then
-     pkglistremove="$pkglistremove $i$postfix"
-     else
-     if [ x$pkgvalue = x1 ]
-     then
-         pkglistinstall="$pkglistinstall $i$postfix"
-     else
-         pkglistremove="$pkglistremove $i$postfix"
-     fi
- fi
- done
+for i in mythphone mytharchive mythbrowser mythnews mythgame mythflix mythweather
+do
+    eval pkgvalue=\$${i}
+
+    if [ x$pkgvalue = x ]
+    then
+        pkglistremove="$pkglistremove $i$postfix"
+    else
+        if [ x$pkgvalue = x1 ]
+        then
+            pkglistinstall="$pkglistinstall $i$postfix"
+        else
+            pkglistremove="$pkglistremove $i$postfix"
+        fi
+    fi
+done
 install="$pkglistinstall $install"
 remove="$pkglistremove $remove"
 
 }
 function LCDcheck () {
- case x$LCDtype in
+case x$LCDtype in
     xtinker) echo "do nothing lcd "
-            ;;
+    ;;
     xno_lcd) echo "no  lcd "
-                       ;;
+    ;;
     xxosd) install="xosd lcdproc $install"
-            ;;
-        x) echo "lcd empty "
-        ;;
- *)
-     install="lcdproc $install"
+    ;;
+    x) echo "lcd empty "
+    ;;
+    *)
+    install="lcdproc $install"
     ;;
 esac
 }
@@ -427,164 +435,164 @@ if [ ! -f $PKGBLACKLIST ]
 then
     touch $PKGBLACKLIST
 fi
-    for i in $remove
-    do
+for i in $remove
+do
     echo "-----------$i --------------"
     grep -q $i $PKGBLACKLIST
     if [ $? = 1 ]
     then
         pacman -Q $i 2>/dev/null
         #VAR=`pacman -Q $i  2>&1 `
-            if [ $? = 0 ]
+        if [ $? = 0 ]
+        then
+            if [ $i = "mythweb$postfix" ]
             then
-                    if [ $i = "mythweb$postfix" ]
-                    then
-                    pacman --noconfirm -R mythweb$postfix
-                    echo removed $i
-                    else
-                    pacman --noconfirm -Rs $i
-                    echo removed $i
-                    fi
+                pacman --noconfirm -R mythweb$postfix
+                echo removed $i
+            else
+                pacman --noconfirm -Rs $i
+                echo removed $i
             fi
+        fi
     else
         echo "$i is black listed"
     fi
-    done
- # fi
+done
+# fi
 
-    for i in $install
-    do
+for i in $install
+do
     echo "-----------$i --------------"
     grep -q $i $PKGBLACKLIST
     if [ $? = 1 ]
     then
-            pacman -Q $i 2>/dev/null
-            #VAR=`pacman -Q $i  2>&1 `
-  #            echo $VAR |grep -vq error:
+        pacman -Q $i 2>/dev/null
+        #VAR=`pacman -Q $i  2>&1 `
+        #            echo $VAR |grep -vq error:
 
-            if [ ! $? = 0 ]
-            then
-                    pacman --noconfirm -Sf $i
-                    echo installed $i
-	    else
-		    echo "$i already installed"
-            fi
+        if [ ! $? = 0 ]
+        then
+            pacman --noconfirm -Sf $i
+            echo installed $i
+        else
+            echo "$i already installed"
+        fi
     else
-      echo "$i is black listed"
+        echo "$i is black listed"
     fi
-    done
+done
 }
 
 function daemons {
 echo "Daemons on boot"
 
-     for i in $daemon_remove
-     do
-    	   sv check $i 1>/dev/null
-            status=$?
-	   if [ $status -eq 0 ]
-	   then
-		sv down $i
-	   fi
-	        remove_service.sh $i
-     done
+for i in $daemon_remove
+do
+    sv check $i 1>/dev/null
+    status=$?
+    if [ $status -eq 0 ]
+    then
+        sv down $i
+    fi
+    remove_service.sh $i
+done
 
 
-    for i in $daemon_add
-    do
-        sv check $i 1>/dev/null
-        status=$?
-        add_service.sh $i
-
-		if [ $status -eq 0 ]
-		then
-                    case $i in
-                        mysql*) sv hup $i
-                                        ;;
-                        mythback*) sv hup $i
-                                        ;;
-                        lirc* ) sv hup $i
-                                        ;;
-                        frontend) sv check frontend 1>/dev/null
-                                        ;;
-
-                        smbd ) sv hup $i
-                                        ;;
-                        nmbd ) sv hup $i
-                                        ;;
-                        evrouter) sv restart $i
-                                    ;;
-                    *)     sv down $i
-                            sleep 1
-                            sv up $i
-                        ;;
-	           esac
-                 fi
-
-        done
+for i in $daemon_add
+do
+    sv check $i 1>/dev/null
+    status=$?
+    add_service.sh $i
+
+    if [ $status -eq 0 ]
+    then
+        case $i in
+            mysql*) sv hup $i
+            ;;
+            mythback*) sv hup $i
+            ;;
+            lirc* ) sv hup $i
+            ;;
+            frontend) sv check frontend 1>/dev/null
+            ;;
+
+            smbd ) sv hup $i
+            ;;
+            nmbd ) sv hup $i
+            ;;
+            evrouter) sv restart $i
+            ;;
+            *)     sv down $i
+            sleep 1
+            sv up $i
+            ;;
+        esac
+    fi
+
+done
 
 }
 
 
 function services
 {
-ser_install=""
-ser_daemon_add=""
-ser_remove=""
-ser_daemon_remove=""
-if [ x$UseEvrouter = x1 ]
-then
-    ser_daemon_add="evrouter Xvfb $ser_daemon_add"
-else
-    ser_daemon_remove="evrouter Xvfb $ser_remove"
-fi
+    ser_install=""
+    ser_daemon_add=""
+    ser_remove=""
+    ser_daemon_remove=""
+    if [ x$UseEvrouter = x1 ]
+    then
+        ser_daemon_add="evrouter Xvfb $ser_daemon_add"
+    else
+        ser_daemon_remove="evrouter Xvfb $ser_remove"
+    fi
 
-if [ x$RunDHCP = x1 ]
-then
-           ser_daemon_add="dnsmasq  $ser_daemon_add"
-           ser_install="dnsmasq mvpmc  $ser_install"
+    if [ x$RunDHCP = x1 ]
+    then
+        ser_daemon_add="dnsmasq  $ser_daemon_add"
+        ser_install="dnsmasq mvpmc  $ser_install"
 
-else
-           ser_daemon_remove="dnsmasq  $ser_daemon_remove"
-           ser_remove="dnsmasq mvpmc  $ser_remove"
-fi
+    else
+        ser_daemon_remove="dnsmasq  $ser_daemon_remove"
+        ser_remove="dnsmasq mvpmc  $ser_remove"
+    fi
 
-if [ x$RunFrontend = x1 ]
-then
-           ser_daemon_add="frontend hal ghosd  $ser_daemon_add"
-           ser_install="ghosd $ser_install"
-           showX=true
- else
-           ser_daemon_remove="frontend hal  $ser_daemon_remove"
-           ser_remove="$ser_remove"
- fi
-
-if [ x$UseMythWEB = x1 ]
-then
-            ser_install="lighttpd  mythweb$postfix $ser_install"
-            ser_daemon_add="lighttpd $ser_daemon_add"
- else
-           ser_remove="mythweb$postfix $ser_remove"
-           ser_daemon_remove="$ser_daemon_remove"
- fi
-
-#samba
-if [ x$UseSamba = x1 ]
-then
+    if [ x$RunFrontend = x1 ]
+    then
+        ser_daemon_add="frontend hal ghosd  $ser_daemon_add"
+        ser_install="ghosd $ser_install"
+        showX=true
+    else
+        ser_daemon_remove="frontend hal  $ser_daemon_remove"
+        ser_remove="$ser_remove"
+    fi
+
+    if [ x$UseMythWEB = x1 ]
+    then
+        ser_install="lighttpd  mythweb$postfix $ser_install"
+        ser_daemon_add="lighttpd $ser_daemon_add"
+    else
+        ser_remove="mythweb$postfix $ser_remove"
+        ser_daemon_remove="$ser_daemon_remove"
+    fi
+
+    #samba
+    if [ x$UseSamba = x1 ]
+    then
         ser_install="samba $ser_install"
         ser_daemon_add="nmbd smbd $ser_daemon_add "
         if [ x$Samba_mediareadonly = x1 ]
-            then
-                smreadonly="no"
-                else
-                smreadonly="yes"
+        then
+            smreadonly="no"
+        else
+            smreadonly="yes"
         fi
 
         if [ x$Samba_homereadonly = x1 ]
-            then
-                shreadonly="no"
-                else
-                shreadonly="yes"
+        then
+            shreadonly="no"
+        else
+            shreadonly="yes"
         fi
 
         if [ ! -d ${BASE}/etc/samba ]
@@ -597,7 +605,7 @@ then
             install -D -m755  ${BASE}/data/home/mythtv/templates/smb.conf   ${BASE}/etc/samba/smb.conf
         else
             sed -e "s/^.*workgroup =.*$/ workgroup = $Samba_domain/g " \
-                -e "s/^.*server string = .*$/ server string = $hostname/g" $TEMPLATES/samba/smb.conf.template > ${BASE}/etc/samba/smb.conf
+            -e "s/^.*server string = .*$/ server string = $hostname/g" $TEMPLATES/samba/smb.conf.template > ${BASE}/etc/samba/smb.conf
 
             if [ x$Samba_media = "x1" ]
             then
@@ -613,62 +621,62 @@ then
             fi
 
         fi
-else
+    else
         ser_remove="samba $ser_remove"
         ser_install="smbclient $ser_install"
         ser_daemon_remove="smbd nmbd  $ser_daemon_remove"
-fi
+    fi
 
 
-if [ x$UseNFS = x1 ]
-then
-      ser_install="nfs-utils portmap $ser_install"
-      ser_daemon_add="nfsd nfslock portmap $ser_daemon_add"
-       sed -e "s/REPLACEME/*/g" $TEMPLATES/exports.template > ${BASE}/etc/exports
+    if [ x$UseNFS = x1 ]
+    then
+        ser_install="nfs-utils portmap $ser_install"
+        ser_daemon_add="nfsd nfslock portmap $ser_daemon_add"
+        sed -e "s/REPLACEME/*/g" $TEMPLATES/exports.template > ${BASE}/etc/exports
 
-else
-      ser_remove="$ser_remove"
-      ser_daemon_remove="nfsd nfslock  $ser_daemon_remove"
-fi
+    else
+        ser_remove="$ser_remove"
+        ser_daemon_remove="nfsd nfslock  $ser_daemon_remove"
+    fi
 
-if [ x$Runncidd = x1 ]
-then
-           ser_daemon_add="ncidd ncid $ser_daemon_add"
-           ser_install="ncid $ser_install"
-  else
-           ser_daemon_remove="ncidd ncid $ser_daemon_remove"
-           ser_remove="ncid $ser_remove"
- fi
-if [ x$UseEvrouter = x1 ]
-then
-           ser_install="evrouter Xvfb $ser_install"
-  else
-           ser_remove="evrouter $ser_remove"
-fi
-#Setting the default, just to avoid the or statement..
-if [ x$UseHobbit = x ]
-then
-    UseHobbit=1
-fi
+    if [ x$Runncidd = x1 ]
+    then
+        ser_daemon_add="ncidd ncid $ser_daemon_add"
+        ser_install="ncid $ser_install"
+    else
+        ser_daemon_remove="ncidd ncid $ser_daemon_remove"
+        ser_remove="ncid $ser_remove"
+    fi
+    if [ x$UseEvrouter = x1 ]
+    then
+        ser_install="evrouter Xvfb $ser_install"
+    else
+        ser_remove="evrouter $ser_remove"
+    fi
+    #Setting the default, just to avoid the or statement..
+    if [ x$UseHobbit = x ]
+    then
+        UseHobbit=1
+    fi
 
-if [ x$UseHobbit = x1 ]
-then
-    case $SystemType in
-        Standalone|Master_backend )
-           ser_daemon_add="hobbit $ser_daemon_add"
-           ser_install="hobbitserver $ser_install"
-        ;;
+    if [ x$UseHobbit = x1 ]
+    then
+        case $SystemType in
+            Standalone|Master_backend )
+            ser_daemon_add="hobbit $ser_daemon_add"
+            ser_install="hobbitserver $ser_install"
+            ;;
 
-        *)   ser_daemon_add="hobbit-client $ser_daemon_add"
-              ser_install="hobbit-client $ser_install"
-        ;;
+            *)   ser_daemon_add="hobbit-client $ser_daemon_add"
+            ser_install="hobbit-client $ser_install"
+            ;;
         esac
-else
-           ser_daemon_remove="hobbit hobbit-client $ser_daemon_remove"
-           ser_remove="hobbit-client hobbitserver $ser_remove"
-            rm -f /data/srv/httpd/htdocs/hobbit/index.html
+    else
+        ser_daemon_remove="hobbit hobbit-client $ser_daemon_remove"
+        ser_remove="hobbit-client hobbitserver $ser_remove"
+        rm -f /data/srv/httpd/htdocs/hobbit/index.html
 
- fi
+    fi
 
 
 
@@ -705,42 +713,42 @@ fi
 function setuppacman () {
 #setup link to httpd dir
 echo "Configuring pacman"
-  if [ ! x$1 = x ]
+if [ ! x$1 = x ]
+then
+    ln -s ${BASE}/data/var ${BASE}/data/srv/httpd/htdocs/repo
+    echo "creating the link for the pacman repo mirror"
+fi
+
+for i in mv-core mv-core-testing mv-extra mv-extra-testing
+do
+    echo "[$i]"  > ${BASE}/etc/pacman.d/$i
+    #add mirror if needed
+    if [ x$PKG_MIRROR = x1 ]
     then
-        ln -s ${BASE}/data/var ${BASE}/data/srv/httpd/htdocs/repo
-        echo "creating the link for the pacman repo mirror"
+        echo " Server = http://$dbhost/repo/$i " >> ${BASE}/etc/pacman.d/$i
     fi
+    #add user templates
+    USERTEMPLATES="/data/home/mythtv/templates"
+    if [ -f $USERTEMPLATES/sources/$i ]
+    then
+        echo "Adding user  $i"
+        cat $USERTEMPLATES/sources/$i  >> ${BASE}/etc/pacman.d/$i
+    fi
+    cat $TEMPLATES/sources/$i  >> ${BASE}/etc/pacman.d/$i
+    echo "setting local mirror to $dbhost for $i "
+done
 
-    for i in mv-core mv-core-testing mv-extra mv-extra-testing
-    do
-        echo "[$i]"  > ${BASE}/etc/pacman.d/$i
-        #add mirror if needed
-        if [ x$PKG_MIRROR = x1 ]
-        then
-            echo " Server = http://$dbhost/repo/$i " >> ${BASE}/etc/pacman.d/$i
-        fi
-        #add user templates
-        USERTEMPLATES="/data/home/mythtv/templates"
-        if [ -f $USERTEMPLATES/sources/$i ]
-        then
-             echo "Adding user  $i"
-            cat $USERTEMPLATES/sources/$i  >> ${BASE}/etc/pacman.d/$i
-        fi
-        cat $TEMPLATES/sources/$i  >> ${BASE}/etc/pacman.d/$i
-        echo "setting local mirror to $dbhost for $i "
-    done
-
-     #sed -e "s/REPLACEME/$dbhost/g"  $TEMPLATES/sources/svc_pkg > /etc/pacman.d/svc_pkg
+#sed -e "s/REPLACEME/$dbhost/g"  $TEMPLATES/sources/svc_pkg > /etc/pacman.d/svc_pkg
 
 
 }
 
 
 function setupzipcode () {
-    if [ ! x$zipcode = x ]
-    then
-        ${MV_ROOT}/bin/restore_default_settings.sh -c ZIP  -z $zipcode
-    fi
+if [ ! x$zipcode = x ]
+then
+    ${MV_ROOT}/bin/restore_default_settings.sh -c ZIP  -z $zipcode
+fi
 }
 
 function process_nfsmap () {
@@ -759,58 +767,58 @@ then
         fi
     fi
 else
-        mv -f /tmp/nfsmap /tmp/nfsmap.old
-        wget -O /tmp/nfsmap http://$1:1337/templates/nfsmap
-        if [ $? = 0 ]
-        then
-            NFSMAP="/tmp/nfsmap"
-        fi
+    mv -f /tmp/nfsmap /tmp/nfsmap.old
+    wget -O /tmp/nfsmap http://$1:1337/templates/nfsmap
+    if [ $? = 0 ]
+    then
+        NFSMAP="/tmp/nfsmap"
+    fi
 fi
 
-    if [ -f $NFSMAP ]
-    then
-        #read in file
-        while read line
-        do
-            NFSserver=`echo "$line"|cut -d" " -f1`
-            NFSmount=`echo "$line"|cut  -d" " -f2`
-            setupfstab $NFSserver $NFSmount
-        done <$NFSMAP
-    else
-        echo "couldn't find nfsmap"
+if [ -f $NFSMAP ]
+then
+    #read in file
+    while read line
+    do
+        NFSserver=`echo "$line"|cut -d" " -f1`
+        NFSmount=`echo "$line"|cut  -d" " -f2`
+        setupfstab $NFSserver $NFSmount
+    done <$NFSMAP
+else
+    echo "couldn't find nfsmap"
 
-    fi
+fi
 }
 
 function setupcnfs () {
-     scrubnfs
-        if [ $HaveCentralNFS = "yes" ]
-	then
-            case x$NFSserver in
-                xfile:nfsmap )
-                                process_nfsmap noip
-                                ;;
-               *:nfsmap )
-                                nfsmapip=`echo "$NFSserver" | cut -d: -f1 `
-                                process_nfsmap $nfsmapip
-                                ;;
-                *)  setupfstab $NFSserver $NFSmount
-                esac
-
-	    #if [ ! x"$NFSserver" = "xfile:nfsmap" ]
-            #then
-            #    setupfstab $NFSserver $NFSmount
-            #else
-            #    process_nfsmap
-            #fi
-        else
-            echo "fe_nfs"
-            #if no central nfs found, then use the mbe.
-            if [ $SystemType = "Frontend_only" ]
-            then
-                setupfstab ${dbhost}:/data/media /data/media
-            fi
-	fi
+scrubnfs
+if [ $HaveCentralNFS = "yes" ]
+then
+    case x$NFSserver in
+        xfile:nfsmap )
+        process_nfsmap noip
+        ;;
+        *:nfsmap )
+        nfsmapip=`echo "$NFSserver" | cut -d: -f1 `
+        process_nfsmap $nfsmapip
+        ;;
+        *)  setupfstab $NFSserver $NFSmount
+    esac
+
+    #if [ ! x"$NFSserver" = "xfile:nfsmap" ]
+    #then
+    #    setupfstab $NFSserver $NFSmount
+    #else
+    #    process_nfsmap
+    #fi
+else
+    echo "fe_nfs"
+    #if no central nfs found, then use the mbe.
+    if [ $SystemType = "Frontend_only" ]
+    then
+        setupfstab ${dbhost}:/data/media /data/media
+    fi
+fi
 
 }
 
@@ -866,32 +874,32 @@ if [ x$RunDHCP = x1   ]
 then
     echo "DNSMASQ setup"
 
-#set default route to my GW
-COMMAND="%s/^dhcp-option=3.*$/dhcp-option=3,${route}/"
-ex ${BASE}/etc/dnsmasq.conf <<EOF
-:$COMMAND
-:wq
-EOF
-
-#setup dns to my ip
-COMMAND="%s/^dhcp-option=6.*$/dhcp-option=6,${MYTHIP}/"
-ex ${BASE}/etc/dnsmasq.conf <<EOF
-:$COMMAND
-:wq
-EOF
-
-
-#change nfsroot to my ip
-COMMAND="%s/nfsroot=.*:/nfsroot=${MYTHIP}:/"
-ex ${BASE}/data/srv/tftp/pxelinux.cfg/default <<EOF
-:$COMMAND
-:wq
-EOF
-
-#add 127.0.0.1 to /etc/resolv.conf
-        echo "search lan" > ${BASE}/etc/resolv.conf
-        echo "nameserver 127.0.0.1" >> ${BASE}/etc/resolv.conf
-        echo "nameserver $nameserver" >> ${BASE}/etc/resolv.conf
+    #set default route to my GW
+    COMMAND="%s/^dhcp-option=3.*$/dhcp-option=3,${route}/"
+    ex ${BASE}/etc/dnsmasq.conf <<EOF
+    :$COMMAND
+    :wq
+    EOF
+
+    #setup dns to my ip
+    COMMAND="%s/^dhcp-option=6.*$/dhcp-option=6,${MYTHIP}/"
+    ex ${BASE}/etc/dnsmasq.conf <<EOF
+    :$COMMAND
+    :wq
+    EOF
+
+
+    #change nfsroot to my ip
+    COMMAND="%s/nfsroot=.*:/nfsroot=${MYTHIP}:/"
+    ex ${BASE}/data/srv/tftp/pxelinux.cfg/default <<EOF
+    :$COMMAND
+    :wq
+    EOF
+
+    #add 127.0.0.1 to /etc/resolv.conf
+    echo "search lan" > ${BASE}/etc/resolv.conf
+    echo "nameserver 127.0.0.1" >> ${BASE}/etc/resolv.conf
+    echo "nameserver $nameserver" >> ${BASE}/etc/resolv.conf
 fi
 
 #setup dongle.config
@@ -908,23 +916,23 @@ EOF
 }
 
 function reloadfe(){
-   PID=`ps -ef |grep mythfrontend|grep -v grep |awk  '{print $2 }'`
-   /usr/bin/backend_control.sh  clearcache  behost $dbhost
-   if [ x$RESTART_LCD = xtrue ]
-   then
+PID=`ps -ef |grep mythfrontend|grep -v grep |awk  '{print $2 }'`
+/usr/bin/backend_control.sh  clearcache  behost $dbhost
+if [ x$RESTART_LCD = xtrue ]
+then
     killall -9 mythlcdserver
-   fi
-   kill -s USR1 $PID
+fi
+kill -s USR1 $PID
 
 }
 
 
 function setup_db (){
 
-            install="mysql avahli"
-            daemon_add="mysql"
-            packages
-            daemons
+install="mysql avahli"
+daemon_add="mysql"
+packages
+daemons
 status=1
 mysqlstatus=1
 while [ ! $status = 0  ]
@@ -935,7 +943,7 @@ do
     mysqlstatus=$?
     if [ $mysqlstatus = 0 ]
     then
-   	mysql -e "show databases;"
+        mysql -e "show databases;"
         showstatus=$?
         if [ $showstatus = 0 ]
         then
@@ -949,13 +957,13 @@ do
             #update database to allow user jobs on this host.
             $MV_ROOT/bin/restore_default_settings.sh  -c  USERJOBALLOW
             $MV_ROOT/bin/restore_default_settings.sh  -c  ACCESSCONTROL
-	   if [ -d /data/srv/mysql/mythconverg ]
-	   then
-	    pacman --noconfirm -R webcalendar
-            pacman --noconfirm --nodeps  -S webcalendar
-	    status=0
-	   fi
-   	fi
+            if [ -d /data/srv/mysql/mythconverg ]
+            then
+                pacman --noconfirm -R webcalendar
+                pacman --noconfirm --nodeps  -S webcalendar
+                status=0
+            fi
+        fi
     fi
 done
 }
@@ -970,45 +978,45 @@ hosttypechange="false"
 
 
 for i in  $LIST
-  do
-   echo $i
-   case $i in
-	   misc) showmisc="true"
-	   	;;
-	  sleep) showsleep="true"
-		;;
-	  hostype) showhost="true"
-                      showX="true"
-	  	;;
-         hostypec) hosttypechange="true"
-                ;;
-	 advanced) showadvanced="true"
-                      #showhost="true"
-		;;
-	audio) showaudio="true"
-		;;
-	network) shownetwork="true"
-		;;
-    advancedX)  showX="true"
-      ;;
-    restartfe)  killall -9 mythfrontend
-                    killall -9 mythwelcome
-                    exit 0
-    ;;
-    reloadfe)  reloadfe
-            ;;
+do
+    echo $i
+    case $i in
+        misc) showmisc="true"
+        ;;
+        sleep) showsleep="true"
+        ;;
+        hostype) showhost="true"
+        showX="true"
+        ;;
+        hostypec) hosttypechange="true"
+        ;;
+        advanced) showadvanced="true"
+        #showhost="true"
+        ;;
+        audio) showaudio="true"
+        ;;
+        network) shownetwork="true"
+        ;;
+        advancedX)  showX="true"
+        ;;
+        restartfe)  killall -9 mythfrontend
+        killall -9 mythwelcome
+        exit 0
+        ;;
+        reloadfe)  reloadfe
+        ;;
 
-    this_is_install) MV_NEW_INSTALL="true"
-		;;
-    NETINSTALL) RESTART_NETWORK="false"
-                NET_INSTALL="true"
+        this_is_install) MV_NEW_INSTALL="true"
+        ;;
+        NETINSTALL) RESTART_NETWORK="false"
+        NET_INSTALL="true"
 
-	esac
-  done
+    esac
+done
 
 if [ x$MV_NEW_INSTALL = xtrue ]
 then
-	hosttypechange="false"
+    hosttypechange="false"
 fi
 
 
@@ -1037,96 +1045,96 @@ then
     setup_network
     vnc_check
     if [   x$USEVNC = x1  ]
-        then
-            echo "reloading network"
-            ${BASE}/etc/net/scripts/network.init reload
-        else
-            echo "netboot/vnc, will not restart network"
-        fi
+    then
+        echo "reloading network"
+        ${BASE}/etc/net/scripts/network.init reload
+    else
+        echo "netboot/vnc, will not restart network"
+    fi
 fi
 
 
 if [ x$showhost = "xtrue" ]
 then
-case $SystemType in
-    Standalone)
-            setupntp 1
-            services
-            if [ x$hosttypechange = "xtrue" ]
-            then
-             setup_db
-            fi
-            if [ -f   ${BASE}/etc/avahi/services/mysql.service     ]
-            then
-                        rm -f ${BASE}/etc/avahi/services/mysql.service
-                        sudo sv restart avahi
-            fi
+    case $SystemType in
+        Standalone)
+        setupntp 1
+        services
+        if [ x$hosttypechange = "xtrue" ]
+        then
+            setup_db
+        fi
+        if [ -f   ${BASE}/etc/avahi/services/mysql.service     ]
+        then
+            rm -f ${BASE}/etc/avahi/services/mysql.service
+            sudo sv restart avahi
+        fi
 
-            install="lighttpd mysql mythdb-initial  avahli  myth2ipod mythtv-status  portmap local-website webcalendar  php $ser_install"
-            remove="none $ser_remove"
+        install="lighttpd mysql mythdb-initial  avahli  myth2ipod mythtv-status  portmap local-website webcalendar  php $ser_install"
+        remove="none $ser_remove"
 
-            daemon_add="lighttpd mysql  mythbackend  avahi portmap $ser_daemon_add"
-            daemon_remove="none $ser_daemon_remove"
+        daemon_add="lighttpd mysql  mythbackend  avahi portmap $ser_daemon_add"
+        daemon_remove="none $ser_daemon_remove"
 
-    ;;
-   Master_backend)
-            setupntp 1
-            services
+        ;;
+        Master_backend)
+        setupntp 1
+        services
 
-            if [  !  -f   ${BASE}/etc/avahi/services/mysql.service     ]
-            then
-                        mkdir  ${BASE}/etc/avahi/services
-                        cp $TEMPLATES/mysql.service  ${BASE}/etc/avahi/services/mysql.service
-                        sudo sv restart  avahi
-            fi
+        if [  !  -f   ${BASE}/etc/avahi/services/mysql.service     ]
+        then
+            mkdir  ${BASE}/etc/avahi/services
+            cp $TEMPLATES/mysql.service  ${BASE}/etc/avahi/services/mysql.service
+            sudo sv restart  avahi
+        fi
 
-            install="lighttpd  local-website mysql  mythdb-initial webcalendar   php avahi portmap myth2ipod mythtv-status func $ser_install  "
-            remove="$ser_remove"
+        install="lighttpd  local-website mysql  mythdb-initial webcalendar   php avahi portmap myth2ipod mythtv-status func $ser_install  "
+        remove="$ser_remove"
 
-            daemon_add="lighttpd mysql mythbackend  avahi   portmap certmaster $ser_daemon_add"
-            daemon_remove="$ser_daemon_remove"
-    ;;
-    Slave_backend)
-            setupntp 0
-            services
-            if [ x$hosttypechange = "xtrue" ]
-            then
-             setup_db
-            fi
-            if [    -f   ${BASE}/etc/avahi/services/mysql.service     ]
-            then
-                        rm -f ${BASE}/etc/avahi/services/mysql.service
-                        sudo sv restart  avahi
-            fi
+        daemon_add="lighttpd mysql mythbackend  avahi   portmap certmaster $ser_daemon_add"
+        daemon_remove="$ser_daemon_remove"
+        ;;
+        Slave_backend)
+        setupntp 0
+        services
+        if [ x$hosttypechange = "xtrue" ]
+        then
+            setup_db
+        fi
+        if [    -f   ${BASE}/etc/avahi/services/mysql.service     ]
+        then
+            rm -f ${BASE}/etc/avahi/services/mysql.service
+            sudo sv restart  avahi
+        fi
 
-            #cp $TEMPLATES/mysql.service  ${BASE}/etc/avahi/services/mysql.service
-            install="mysql  avahi func $ser_install  "
-            remove=" $ser_remove"
+        #cp $TEMPLATES/mysql.service  ${BASE}/etc/avahi/services/mysql.service
+        install="mysql  avahi func $ser_install  "
+        remove=" $ser_remove"
 
-            daemon_add="mythbackend avahi portmap  mythtv-status  funcd $ser_daemon_add"
-            daemon_remove="$ser_daemon_remove"
-    ;;
-    Frontend_only)
+        daemon_add="mythbackend avahi portmap  mythtv-status  funcd $ser_daemon_add"
+        daemon_remove="$ser_daemon_remove"
+        ;;
+        Frontend_only)
         #Add values for services
         setupntp 0
         services
         if [  -f   ${BASE}/etc/avahi/services/mysql.service     ]
-            then
-                        rm -f ${BASE}/etc/avahi/services/mysql.service
-                        sudo sv restart  avahi
-            fi
+        then
+            rm -f ${BASE}/etc/avahi/services/mysql.service
+            sudo sv restart  avahi
+        fi
 
         install="libmysqlclient mysql-clients portmap avahi func  $ser_install"
         remove="mysql local-website lighttpd php mythweb$postfix $ser_remove"
 
         daemon_add="avahi portmap funcd $ser_daemon_add "
         daemon_remove="mysql lighttpd  mythbackend  $ser_daemon_remove"
-   ;;
+        ;;
 
 
-esac
-setupSyslog
-setupfuncminion
+    esac
+    setupSyslog
+    setupfuncminion
 fi
 
 #apply these to ALL types
@@ -1149,7 +1157,7 @@ fi
 
 if [ x$showaudio = "xtrue" ]
 then
-	#setupsoundtype
+    #setupsoundtype
     if [ ! x$Audiotype = xtinker  ]
     then
         ${MV_ROOT}/bin/soundconfig.sh -t real -i $Audiotype -d $SoundDevice
@@ -1163,15 +1171,15 @@ packages
 
 if [ x$showmisc = "xtrue" ]
 then
-	setupzipcode
-	settimezone
+    setupzipcode
+    settimezone
     setupcnfs
 fi
 
 #sleep
 if [ x$showsleep = "xtrue" ]
 then
-	setupsleep
+    setupsleep
 fi
 
 if [ x$showX = "xtrue" ]
@@ -1195,10 +1203,10 @@ then
         if [ x$SystemType = xMaster_backend ]
         then
             setuppacman link
-            else
+        else
             setuppacman
         fi
-     fi
+    fi
     setupncidclient
     setupnciddaemon
     setupbootsplash
@@ -1227,34 +1235,34 @@ fi
 
 case $SystemType in
     Standalone)  smoltsystem=6
-                     MVRELEASE="$MVRELEASE  (Standalone)"
-                    ;;
-   Master_backend)
-            if [ x$RunFrontend = x1 ]
-            then
-                smoltsystem=2
-                MVRELEASE="$MVRELEASE  (MBE with Frontend)"
-            else
-                smoltsystem=1
-                MVRELEASE="$MVRELEASE  (MBE)"
-            fi
-            ;;
-   Slave_backend)
-            if [ x$RunFrontend = x1 ]
-            then
-                smoltsystem=5
-                MVRELEASE="$MVRELEASE  (SLAVE  with Frontend)"
-            else
-                smoltsystem=5
-                MVRELEASE="$MVRELEASE  (SLAVE)"
-            fi
-            ;;
-     Frontend_only)
-          smoltsystem=3
-          MVRELEASE="$MVRELEASE  ( Frontend only)"
-            ;;
+    MVRELEASE="$MVRELEASE  (Standalone)"
+    ;;
+    Master_backend)
+    if [ x$RunFrontend = x1 ]
+    then
+        smoltsystem=2
+        MVRELEASE="$MVRELEASE  (MBE with Frontend)"
+    else
+        smoltsystem=1
+        MVRELEASE="$MVRELEASE  (MBE)"
+    fi
+    ;;
+    Slave_backend)
+    if [ x$RunFrontend = x1 ]
+    then
+        smoltsystem=5
+        MVRELEASE="$MVRELEASE  (SLAVE  with Frontend)"
+    else
+        smoltsystem=5
+        MVRELEASE="$MVRELEASE  (SLAVE)"
+    fi
+    ;;
+    Frontend_only)
+    smoltsystem=3
+    MVRELEASE="$MVRELEASE  ( Frontend only)"
+    ;;
 esac
 echo $MVRELEASE > /etc/os_myth_release
-echo "systemtype=$smoltsystem" > /data/home/mythtv/.mythtv/smolt.info
-echo "remote=$Remotetype" >> /data/home/mythtv/.mythtv/smolt.info
+echo "systemtype=$smoltsystem" > /data/home/mythtv/.mythtv/smolt.info 2>/dev/null
+echo "remote=$Remotetype" >> /data/home/mythtv/.mythtv/smolt.info 2>/dev/null
 
diff --git a/abs/mv-core/MythVantage-config/templates/modules/lirc_i2c.conf b/abs/mv-core/MythVantage-config/templates/modules/lirc_i2c.conf
new file mode 100644
index 0000000..7b99f78
--- /dev/null
+++ b/abs/mv-core/MythVantage-config/templates/modules/lirc_i2c.conf
@@ -0,0 +1,2 @@
+alias char-major-61 lirc_i2c
+options lirc_i2c debug=0 minor=3	
diff --git a/abs/mv-core/MythVantage-config/templates/remotes/i2c.id b/abs/mv-core/MythVantage-config/templates/remotes/i2c.id
new file mode 100644
index 0000000..50e89e9
--- /dev/null
+++ b/abs/mv-core/MythVantage-config/templates/remotes/i2c.id
@@ -0,0 +1,5 @@
+0070:4000|Hauppauge|WinTV PVR 250|hauppauge-grey
+0070:4009|Hauppauge|WinTV PVR 250|hauppauge-grey
+0070:4801|Hauppauge|WinTV PVR 250|hauppauge-grey
+0070:4803|Hauppauge|WinTV PVR 250|hauppauge-grey
+0070:0003|Hauppauge|WinTV PVR 250|hauppauge-grey
\ No newline at end of file
diff --git a/abs/mv-core/runit-scripts-mv/runitscripts/services/lircd/run b/abs/mv-core/runit-scripts-mv/runitscripts/services/lircd/run
index 0adfdc1..ceda8db 100755
--- a/abs/mv-core/runit-scripts-mv/runitscripts/services/lircd/run
+++ b/abs/mv-core/runit-scripts-mv/runitscripts/services/lircd/run
@@ -7,7 +7,7 @@ run_lircd2=false
 function dvico_detect {
 
 
-  if [ x$Remotetype = "dvico" ]
+  if [ x$Remotetype = "xdvico" ]
   then
                 DEVICE="/dev/usb/hiddev0"
   fi
@@ -33,7 +33,9 @@ case $ReceiverType in
 	Usb-imon)
 		DEVICE=/dev/lirc_imon	
 	;;
-
+    Hauppauge)
+        DEVICE=/dev/lirc3
+        ;;
 	*) 
 
 		DEVICE=`ls  /dev/lirc[0-9] 2>/dev/null |sort |sed '/./,$!d'|head -n 1 `
-- 
cgit v0.12