From 7e10f51870aa10be3b35d7912a7b54e30f608bb8 Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Fri, 31 Jul 2009 22:13:23 -0500
Subject: linhes-config: probe network on install boot for parms

---
 abs/core-testing/LinHES-config/PKGBUILD            |  2 +-
 .../LinHES-config/install_functions.sh             | 35 ++++++++++++++++++----
 2 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/abs/core-testing/LinHES-config/PKGBUILD b/abs/core-testing/LinHES-config/PKGBUILD
index 9486462..ba324ee 100755
--- a/abs/core-testing/LinHES-config/PKGBUILD
+++ b/abs/core-testing/LinHES-config/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=LinHES-config
 pkgver=2.0
-pkgrel=57
+pkgrel=62
 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 ddcxinfo python-pexpect python-netifaces LinHES-timezone python-iplib)
diff --git a/abs/core-testing/LinHES-config/install_functions.sh b/abs/core-testing/LinHES-config/install_functions.sh
index ea9e61c..a5f4122 100755
--- a/abs/core-testing/LinHES-config/install_functions.sh
+++ b/abs/core-testing/LinHES-config/install_functions.sh
@@ -197,6 +197,15 @@ function rest_of_network () {
         else
             printhl "    DNS not found"
     fi
+    echo $CMDLINE | grep -q chostname
+    if [ $? -eq 0 ]
+    then
+        TEMPVAR=${CMDLINE#*chostname=}
+        MYHOST=${TEMPVAR%% *}
+        update_db_settings HostMyhostname "$MYHOST"
+        else
+            printhl "    hostname not found"
+    fi
 }
 
 function init_network {
@@ -256,6 +265,14 @@ function dev_up_check(){
 }
 
 function request_dhcp(){
+    echo $CMDLINE |grep -q cnetdev
+    if [ $? -eq 0 ]
+    then
+        TEMPVAR=${CMDLINE#*cnetdev=}
+        MYTHDEFAULT_NET=${TEMPVAR%% *}
+    else
+        MYTHDEFAULT_NET="eth0"
+    fi
     for ndev in eth0 eth1 wlan0 wlan1 ath0
     do
         dev_up_check $ndev
@@ -263,22 +280,30 @@ function request_dhcp(){
         if [ $status -eq 1 ]
         then
             #interface is down, lets see if dhcp responds
-            dhcpcd -Td -t2 $ndev > /tmp/dhcpinfo.$ndev
-            TEMPVAR=`grep IPADDR /tmp/dhcpinfo.$ndev |cut -d\' -f2`
+            dhcpcd -Td -t2 $ndev -h "" > /tmp/dhcpinfo.$ndev
+            #check for hostname here
+
+            TEMPVAR=`grep new_ip_address /tmp/dhcpinfo.$ndev |cut -d\= -f2`
             if [ ! x$TEMPVAR = x ]
             then
                 update_db_settings HostIP$ndev "$TEMPVAR"
-                TEMPVAR=`grep NETMASK /tmp/dhcpinfo.$ndev |cut -d\' -f2`
+                TEMPVAR=`grep new_subnet_mask /tmp/dhcpinfo.$ndev |cut -d\= -f2`
                 nm=`/usr/bin/nmconv.py -obits  $TEMPVAR`
                 TEMPVAR="/$nm    $TEMPVAR"
                 update_db_settings HostNETMASK$ndev "$TEMPVAR"
-                TEMPVAR=`grep GATEWAYS /tmp/dhcpinfo.$ndev |cut -d\' -f2`
+                TEMPVAR=`grep new_routers /tmp/dhcpinfo.$ndev |cut -d\= -f2`
                 update_db_settings HostGW$ndev "$TEMPVAR"
-                TEMPVAR=`grep DNSSERVERS /tmp/dhcpinfo.$ndev |cut -d\' -f2`
+                TEMPVAR=`grep new_domain_name_servers /tmp/dhcpinfo.$ndev |cut  -d\= -f2`
                 update_db_settings HostDNS$ndev "$TEMPVAR"
             fi
         fi
     done
+    TEMPVAR=`grep new_host_name /tmp/dhcpinfo.$MYTHDEFAULT_NET |cut -d\= -f2`
+    if [ ! x$TEMPVAR = x ]
+    then
+        update_db_settings HostMyhostname "$TEMPVAR"
+    fi
+
 }
 
 function init_remote {
-- 
cgit v0.12

