From fb1297d921cc57b9cb3b02ec6c279795190429be Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Wed, 14 Jan 2009 18:55:32 -0600
Subject: add support for /myth not mounted on sda3 for upgrades. Includes
 software raid support.

fix invalid temp table names based off hostname.
---
 abs/core-testing/LinHES-config/PKGBUILD            |  2 +-
 abs/core-testing/LinHES-config/install_proxy.sh    | 49 ++++++++++++++++++----
 .../LinHES-config/restore_default_settings.sh      |  4 +-
 3 files changed, 45 insertions(+), 10 deletions(-)

diff --git a/abs/core-testing/LinHES-config/PKGBUILD b/abs/core-testing/LinHES-config/PKGBUILD
index 76754da..8676d36 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=178
+pkgrel=185
 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_proxy.sh b/abs/core-testing/LinHES-config/install_proxy.sh
index 175d7f9..b910ec4 100755
--- a/abs/core-testing/LinHES-config/install_proxy.sh
+++ b/abs/core-testing/LinHES-config/install_proxy.sh
@@ -90,20 +90,55 @@ function backup_sql_check {
     return $rc
 }
 
+function mdadm_assemble_all {
+
+        mdadm_find /tmp
+        mdadm --assemble --scan -c /tmp${MDADM_CONF}
+        MDLIST=`grep ARRAY /tmp${MDADM_CONF}|tr -s [:space:]|cut -d" " -f2`
+        for array in $MDLIST
+        do
+            echo "assembling array $array"
+            mdadm --assemble -c /tmp${MDADM_CONF} $array
+            sleep 2
+            fsck -p $array
+        done
+
+}
+
 function upgrade_mount_search {
 
     MYTH_P=`cat /tmp/etc/fstab |grep -E /myth[[:space:]] | awk ' {print $1 '} `
     umount $mountpoint/myth
+
+    #should probably just mdadm all the time
     echo $MYTH_P |grep -q \/md.
     if [ $? = 0 ]
     then
-        mdadm_find /tmp
-        mdadm --assemble -c /tmp${MDADM_CONF} $MYTH_P
-        sleep 2
-        fsck -p $MYTH_P
+        mdadm_assemble_all
+    fi
+
+    echo $MYTH_P |grep -q UUID
+    if [ $? = 0 ]
+    then
+        MUUID=`echo $MYTH_P|cut -d= -f2|tr -d \"`
+        echo blkid $MUUID
+        blkid -t UUID=$MUUID
+        if [ ! $? = 0 ]
+        then
+            echo "couldn't find $MUUID, starting md support"
+            mdadm_assemble_all
+        fi
+        mount -U $MUUID $mountpoint/myth
+        echo mount -U    $MUUID $mountpoint/myth
+        MYTHMOUNT=`blkid -t UUID=$MUUID|cut -d: -f1`
+        MYTHMOUNT=`basename $MYTHMOUNT`
+        echo "MYTHMOUNT is $MYTHMOUNT"
+    else
+        mount $MYTH_P $mountpoint/myth
+        echo mount $MYTH_P $mountpoint/myth
+        MYTHMOUNT=`basename $MYTH_P`
+        echo "MYTHMOUNT is $MYTHMOUNT"
     fi
-    mount $MYTH_P $mountpoint/myth
-    echo mount $MYTH_P $mountpoint/myth
     sleep 2
     backup_sql_check
     if [ $? = 1  ]
@@ -117,8 +152,6 @@ function upgrade_mount_search {
             BACKUPFILE="/root/backup/mythconverg.sql.gz"
             echo "setting BACKUPFILE to $BACKUPFILE"
         fi
-    else
-    MYTHMOUNT=`basename $MYTH_P`
     fi
     return 0
 }
diff --git a/abs/core-testing/LinHES-config/restore_default_settings.sh b/abs/core-testing/LinHES-config/restore_default_settings.sh
index 46c5fc9..5a02886 100755
--- a/abs/core-testing/LinHES-config/restore_default_settings.sh
+++ b/abs/core-testing/LinHES-config/restore_default_settings.sh
@@ -29,7 +29,9 @@ function CMD_DEFINE () {
 }
 
 function SQL_DEFINE () {
-    thostname=`echo ${hostname}|tr - _`
+    thostname=`echo ${hostname}|tr -C [:alpha:] _`
+    echo "Using $thostname for temp table postfix"
+
 	#$1 is the table name
 	if [ $1 = "settings" ]
 	then
-- 
cgit v0.12