[PC-BSD Commits] r4796 - in pcbsd/trunk/pc-sysinstall: . backend examples

svn at pcbsd.org svn at pcbsd.org
Wed Oct 28 07:31:48 PST 2009


Author: kris
Date: 2009-10-28 08:31:48 -0700 (Wed, 28 Oct 2009)
New Revision: 4796

Added:
   pcbsd/trunk/pc-sysinstall/examples/
   pcbsd/trunk/pc-sysinstall/examples/pcinstall.cfg.gmirror
   pcbsd/trunk/pc-sysinstall/examples/pcinstall.cfg.zfs
Removed:
   pcbsd/trunk/pc-sysinstall/pcinstall.cfg.zfs
Modified:
   pcbsd/trunk/pc-sysinstall/backend/functions-disk.sh
   pcbsd/trunk/pc-sysinstall/backend/functions-parse.sh
   pcbsd/trunk/pc-sysinstall/backend/parseconfig.sh
   pcbsd/trunk/pc-sysinstall/pcinstall.cfg
Log:

Cleanup some gmirror functionality, correctly remove mirror when doing
a fresh install to a system and disk we want to blow away is mirrored.

Also added examples directory, where we can store specific examples of install configs



Modified: pcbsd/trunk/pc-sysinstall/backend/functions-disk.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-disk.sh	2009-10-28 14:44:53 UTC (rev 4795)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-disk.sh	2009-10-28 15:31:48 UTC (rev 4796)
@@ -5,27 +5,25 @@
 # Function which stops all gmirrors before doing any disk manipulation
 stop_all_gmirror()
 {
-  gmirror list | grep "mirror/" | cut -d "." -f 1 >${TMPDIR}/.oldgnum
-  while read num
+  DISK="${1}"
+  GPROV="`gmirror list | grep ". Name: mirror/" | cut -d '/' -f 2`"
+  for gprov in $GPROV 
   do
-    GPROV="`gmirror list | grep "^${num}. Name" | grep mirror | cut -d '/' -f 2`"
-    GDEV="`gmirror list | grep "^${num}. Name" | grep -v mirror  | cut -d ':' -f 2 | sed 's|^ ||g'`"
-    for i in $GDEV
-    do
-      gmirror remove $GPROV $i #>>${LOGOUT} 2>>${LOGOUT}
-    done
-  done <${TMPDIR}/.oldgnum
-
-  rm ${TMPDIR}/.oldgnum
+    gmirror list | grep "Name: ${DISK}" >/dev/null 2>/dev/null
+    if [ "$?" = "0" ]
+    then
+      echo "gmirror remove $gprov $DISK" >>${LOGOUT} 2>>${LOGOUT}
+      gmirror remove $gprov $DISK >>${LOGOUT} 2>>${LOGOUT}
+      echo "dd if=/dev/zero of=/dev/${DISK} count=4096" >>${LOGOUT} 2>>${LOGOUT}
+      dd if=/dev/zero of=/dev/${DISK} count=4096 >>${LOGOUT} 2>>${LOGOUT}
+    fi
+  done
 };
 
 # Function which reads in the disk slice config, and performs it
 setup_disk_slice()
 {
 
-  # Make sure we stop any gmirrors before doing the install, wrecks havoc with fdisk and such
-  stop_all_gmirror
-
   # Cleanup any slice / mirror dirs
   rm -rf ${SLICECFGDIR} >/dev/null 2>/dev/null
   mkdir ${SLICECFGDIR}
@@ -52,6 +50,10 @@
        then
          exit_err "ERROR: The disk ${DISK} does not exist!"
        fi
+
+       # Make sure we stop any gmirrors on this disk
+       stop_all_gmirror ${DISK}
+
      fi
 
      # Lets look if this device will be mirrored on another disk

Modified: pcbsd/trunk/pc-sysinstall/backend/functions-parse.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-parse.sh	2009-10-28 14:44:53 UTC (rev 4795)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-parse.sh	2009-10-28 15:31:48 UTC (rev 4796)
@@ -23,13 +23,45 @@
     VAL=`grep "^${1}=" ${CFGF} | head -n 1 | cut -d '=' -f 2 | tr -d ' '`
     export VAL
   else
-    echo "Error: Did we forgot to supply a setting to grab?"
-    exit 1
+    exit_err "Error: Did we forgot to supply a setting to grab?"
   fi
 };
 
 # Checks the value of a setting in the provided line with supplied possibilities
 # 1 = setting we are checking,  2 = list of valid values
+if_check_value_exists()
+{
+  if [ ! -z "${1}" -a ! -z "${2}" ]
+  then
+    # Get the first occurance of the setting from the config, strip out whitespace
+
+    VAL=`grep "^${1}" ${CFGF} | head -n 1 | cut -d '=' -f 2 | tr -d ' '`
+    if [ -z "${VAL}" ]
+    then
+      # This value doesn't exist, lets return
+      return 0
+    fi
+
+
+    VALID="1"
+    for i in ${2}
+    do
+      if [ "$VAL" = "${i}" ]
+      then 
+        VALID="0"
+      fi
+    done 
+    if [ "$VALID" = "1" ]
+    then
+      exit_err "Error: ${1} is set to unknown value $VAL"
+    fi
+  else
+    exit_err "Error: Did we forgot to supply a string to parse and setting to grab?"
+  fi
+};
+
+# Checks the value of a setting in the provided line with supplied possibilities
+# 1 = setting we are checking,  2 = list of valid values
 check_value()
 {
   if [ ! -z "${1}" -a ! -z "${2}" ]

Modified: pcbsd/trunk/pc-sysinstall/backend/parseconfig.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/parseconfig.sh	2009-10-28 14:44:53 UTC (rev 4795)
+++ pcbsd/trunk/pc-sysinstall/backend/parseconfig.sh	2009-10-28 15:31:48 UTC (rev 4796)
@@ -44,7 +44,7 @@
 check_value installMedium "dvd usb ftp"
 check_value packageType "lzma uzip tar"
 check_value partition "all s1 s2 s3 s4 free"
-check_value mirrorbal "load prefer round-robin split"
+if_check_value_exists mirrorbal "load prefer round-robin split"
 
 # We passed all sanity checks! Yay, lets start the install
 echo "File Sanity Check -> OK"

Modified: pcbsd/trunk/pc-sysinstall/pcinstall.cfg
===================================================================
--- pcbsd/trunk/pc-sysinstall/pcinstall.cfg	2009-10-28 14:44:53 UTC (rev 4795)
+++ pcbsd/trunk/pc-sysinstall/pcinstall.cfg	2009-10-28 15:31:48 UTC (rev 4796)
@@ -6,8 +6,6 @@
 
 # Set the disk parameters
 disk0=ad0
-mirror=ad1
-mirrorbal=split
 partition=all
 bootManager=bsd
 commitDiskPart



More information about the Commits mailing list