[PC-BSD Commits] r6548 - pcbsd/trunk/pc-sysinstall/backend-query

svn at pcbsd.org svn at pcbsd.org
Wed Apr 14 15:29:18 PDT 2010


Author: kris
Date: 2010-04-14 15:29:17 -0700 (Wed, 14 Apr 2010)
New Revision: 6548

Modified:
   pcbsd/trunk/pc-sysinstall/backend-query/update-part-list.sh
Log:

Cleanup update-part-list



Modified: pcbsd/trunk/pc-sysinstall/backend-query/update-part-list.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend-query/update-part-list.sh	2010-04-13 14:19:49 UTC (rev 6547)
+++ pcbsd/trunk/pc-sysinstall/backend-query/update-part-list.sh	2010-04-14 22:29:17 UTC (rev 6548)
@@ -6,6 +6,21 @@
 
 FSMNT="/mnt"
 
+# Get the freebsd version on this partition
+get_fbsd_ver() {
+
+  VER="`file ${FSMNT}/bin/sh | grep 'for FreeBSD' | sed 's|for FreeBSD |;|g' | cut -d ';' -f 2 | cut -d ',' -f 1`"
+  if [ "$?" = "0" ] ; then
+      file ${FSMNT}/bin/sh | grep '32-bit' >/dev/null 2>/dev/null
+      if [ "${?}" = "0" ] ; then
+        echo "${1}: FreeBSD ${VER} (32bit)"
+      else
+        echo "${1}: FreeBSD ${VER} (64bit)"
+      fi
+  fi
+
+}
+
 # Create our device listing
 SYSDISK="`sysctl kern.disks | cut -d ':' -f 2 | sed 's/^[ \t]*//'`"
 DEVS=""
@@ -18,8 +33,7 @@
   DEV="${i}"
   # Make sure we don't find any cd devices
   echo "${DEV}" | grep -e "^acd[0-9]" -e "^cd[0-9]" -e "^scd[0-9]" >/dev/null 2>/dev/null
-  if [ "$?" != "0" ]
-  then
+  if [ "$?" != "0" ] ; then
    DEVS="${DEVS} `ls /dev/${i}s*`" 
   fi
 
@@ -30,117 +44,28 @@
 
 for i in $DEVS
 do
-    # Set our flag that we have not found any mounts
-    FOUNDMNT="0"
-    ZROOT=""
-
-    if [ -e "${i}a.journal" ]
-    then
+    if [ -e "${i}a.journal" ] ; then
       mount ${i}a.journal ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
-      if [ "${?}" = "0" ]
-      then
-        FOUNDMNT="1"
+      if [ "${?}" = "0" ] ; then
+	get_fbsd_ver ${i}
+        umount -f ${FSMNT} >/dev/null 2>/dev/null
       fi
     elif [ -e "${i}a" ]
     then
       mount ${i}a ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
-      if [ "${?}" = "0" ]
-      then
-        FOUNDMNT="1"
+      if [ "${?}" = "0" ] ; then
+	get_fbsd_ver ${i}
+        umount -f ${FSMNT} >/dev/null 2>/dev/null
       else
         # Lets try ZFS of this device
         ZNAME=`echo ${i} | cut -d '/' -f 3`
         mount -t zfs ${ZNAME}a ${FSMNT}
-        if [ "${?}" = "0" ]
-        then
-          FOUNDMNT="1"
+        if [ "${?}" = "0" ] ; then
+	  get_fbsd_ver ${i}
+          umount -f ${FSMNT} >/dev/null 2>/dev/null
         fi
       fi
     fi
-
-    # First see if we can even run scripts on this system
-    if [ "${FOUNDMNT}" = "1" ] ; then
-      chroot ${FSMNT} /bin/csh --version >/dev/null 2>/dev/null
-      if [ "$?" != "0" ] ; then
-        FOUNDMNT="0"
-        umount -f ${FSMNT}
-      fi
-    fi 
-
-    # We have a good mount-point, query for some data
-    if [ "${FOUNDMNT}" = "1" ] ; then
-      PART="${i}"
-
-
-      mount -t devfs devfs ${FSMNT}/dev
-
-      chroot ${FSMNT} /sbin/mount -a
-
-      # Now lets see what type of system we've found here
-      # Create Script
-      echo '#!/bin/sh
-/etc/rc.d/ldconfig start
-PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/local/sbin:/usr/PCBSD/local/bin" ; export PATH
-LD_LIBRARY_PATH="/usr/local/lib:/usr/local/lib/qt4:/usr/local/kde4/lib:/usr/PCBSD/local/lib:/usr/PCBSD/local/kde4/lib" ; export LD_LIBRARY_PATH
-
-which pbreg
-if [ "$?" = "0" ]
-then
-  pbreg get /PC-BSD/Version >/.pcver 2>/.pcver
-fi
-
-file /bin/sh | sed "s/for FreeBSD/#/" | cut -d "#" -f 2 | cut -d "," -f 1 >/.fbver 2>/.fbver' >${FSMNT}/getver.sh 
-
-      chmod 755 ${FSMNT}/getver.sh >/dev/null 2>/dev/null
-      chroot ${FSMNT} /getver.sh >/dev/null 2>/dev/null
-      PCVER="`cat ${FSMNT}/.pcver 2>/dev/null`"
-      FBVER="`cat ${FSMNT}/.fbver 2>/dev/null`"
-       
-      # Remove old files
-      rm ${FSMNT}/.pcver >/dev/null 2>/dev/null
-      rm ${FSMNT}/.fbver >/dev/null 2>/dev/null
-      rm ${FSMNT}/getver.sh 2>/dev/null 
-
-      # Echo our found partition / version
-      if [ -z "${PCVER}" ]
-      then
-        echo "${i}: FreeBSD ${FBVER}"
-      else
-        echo "${i}: PC-BSD ${PCVER}"
-      fi
-
-
-      # If we are on ZFS, cleanup after the mount
-      if [ ! -z "${ZROOT}" ]
-      then
-        umount ${FSMNT}/bootdir >/dev/null 2>/dev/null
-
-        # Unmount any extra fs from the zfs pool
-        zfs unmount -a >/dev/null 2>/dev/null
-      fi
-
-      # Unmount FS
-      chroot ${FSMNT} /sbin/umount -a >/dev/null 2>/dev/null
-
-      mount | tail -r > /tmp/.upmounts 
-      while read line
-      do
-        UMNT="`echo $line | cut -d ' ' -f 1`"  
-        if [ "${UMNT}" = "devfs" ] ; then
-          break
-        fi
-      
-        umount -f ${UMNT}
-      done < /tmp/.upmounts
-      rm /tmp/.upmounts
-
-      umount -f ${FSMNT}/proc >/dev/null 2>/dev/null
-      umount -f ${FSMNT}/compat/linux/proc >/dev/null 2>/dev/null
-      umount -f ${FSMNT}/dev >/dev/null 2>/dev/null
-      umount -f ${FSMNT} >/dev/null 2>/dev/null
-    
-    fi # End of if ${i}a
-
 done
 
 # Export all zpools again, so that we can overwrite these partitions potentially



More information about the Commits mailing list