[PC-BSD Commits] r1853 - pcbsd/trunk/installcd-overlay/usr/local/pcbsd/scripts

svn at pcbsd.org svn at pcbsd.org
Wed May 7 07:43:18 PDT 2008


Author: melkor
Date: 2008-05-07 07:43:17 -0700 (Wed, 07 May 2008)
New Revision: 1853

Modified:
   pcbsd/trunk/installcd-overlay/usr/local/pcbsd/scripts/PCBSD.FindUpdateParts.sh
Log:

Optimization of too monstrous script :)

M    scripts/PCBSD.FindUpdateParts.sh


Modified: pcbsd/trunk/installcd-overlay/usr/local/pcbsd/scripts/PCBSD.FindUpdateParts.sh
===================================================================
--- pcbsd/trunk/installcd-overlay/usr/local/pcbsd/scripts/PCBSD.FindUpdateParts.sh	2008-05-07 13:03:23 UTC (rev 1852)
+++ pcbsd/trunk/installcd-overlay/usr/local/pcbsd/scripts/PCBSD.FindUpdateParts.sh	2008-05-07 14:43:17 UTC (rev 1853)
@@ -2,215 +2,48 @@
 
 rm /tmp/AvailUpgrades >/dev/null 2>/dev/null
 
-DEVS="ad
-ar
-aacd
-mlxd
-mlyd
-amrd
-idad
-twed
-da"
-
-for i in $DEVS 
+for i in `find -E /dev -regex '/dev/(ad|ar|aacd|mixd|mlyd|amrd|idad|twed|da)[0-9]+s[1-4]' -print`
 do
-  num="0"
+  if [ -e "/dev/${i}a" ]
+  then
+    mount /dev/${i}a /mnt
+    if [ -e "/dev/${i}b" ]
+    then
+      swapon /dev/${i}b
+    fi
 
-  while
-    z=1
-  do
+    touch /tmp/TempUMount
+    for mprt in `ls -1 /dev/${i}[d-h]`
+    do
+      MNT="`cat /mnt/etc/fstab | grep ${mprt} | cut -f 2 | cut -d " " -f 1`"
+      mount ${mprt} /mnt${MNT}\
+      echo "umount ${mprt}" >> /tmp/TempUMount
+    done      
   
-     if [ -e "/dev/${i}${num}s1a" ]
-     then
-        mount /dev/${i}${num}s1a /mnt
-        if [ -e "/dev/${i}${num}s1b" ]
-        then
-           swapon /dev/${i}${num}s1b
-        fi
+    if [ -e "/mnt/PCBSD" ]
+    then
 
-        MNT="`cat /mnt/etc/fstab | grep ${i}${num}s1e | cut -f 2 | cut -d " " -f 1`"
-        mount /dev/${i}${num}s1e /mnt${MNT}
-        
-	MNT1="`cat /mnt/etc/fstab | grep ${i}${num}s1f | cut -f 2 | cut -d " " -f 1`"
-        mount /dev/${i}${num}s1f /mnt${MNT1}
-
-	MNT2="`cat /mnt/etc/fstab | grep ${i}${num}s1g | cut -f 2 | cut -d " " -f 1`"
-        mount /dev/${i}${num}s1g /mnt${MNT2}
-
-
-        if [ -e "/mnt/PCBSD" ]
-        then
-
- 	# Create Script
-        echo "#!/bin/sh
-/usr/local/bin/PBReg get /PC-BSD/Version >/.pcver 2>/.pcver " >/mnt/getver.sh
-        chmod 755 /mnt/getver.sh
-        chroot /mnt /getver.sh
-        VER="`cat /mnt/.pcver`"
+      # Create Script
+      echo "#!/bin/sh
+      /usr/local/bin/PBReg get /PC-BSD/Version >/.pcver 2>/.pcver " >/mnt/getver.sh
+      chmod 755 /mnt/getver.sh
+      chroot /mnt /getver.sh
+      VER="`cat /mnt/.pcver`"
        
-        # Remove old files
-        rm /mnt/.pcver
-        rm /mnt/getver.sh
+      # Remove old files
+      rm /mnt/.pcver
+      rm /mnt/getver.sh
 
-        # Echo our saved info
-        echo "/dev/${i}${num}s1a: Running PC-BSD ${VER}" >> /tmp/AvailUpgrades
+      # Echo our saved info
+      echo "/dev/${i}a: Running PC-BSD ${VER}" >> /tmp/AvailUpgrades
 
-        fi # End of if /mnt/PCBSD
+    fi # End of if /mnt/PCBSD
 
-        # Unmount FS
- 	umount /mnt/${MNT2}
-        umount /mnt/${MNT1}
- 	umount /mnt/${MNT}
-	umount /mnt      
-
+    # Unmount FS
+    /bin/sh /tmp/TempUMount
+    umount /mnt      
+    rm /tmp/TempUMount
         
-     fi # End of if /dev/${i}${num}s1a
+  fi # End of if /dev/${i}a
      
-     if [ -e "/dev/${i}${num}s2a" ]
-     then
-
-        mount /dev/${i}${num}s2a /mnt
-        if [ -e "/dev/${i}${num}s2b" ]
-        then
-           swapon /dev/${i}${num}s2b
-        fi
-
-        MNT="`cat /mnt/etc/fstab | grep ${i}${num}s2e | cut -f 2 | cut -d " " -f 1`"
-        mount /dev/${i}${num}s2e /mnt${MNT}
-        
-	MNT1="`cat /mnt/etc/fstab | grep ${i}${num}s2f | cut -f 2 | cut -d " " -f 1`"
-        mount /dev/${i}${num}s2f /mnt${MNT1}
-
-	MNT2="`cat /mnt/etc/fstab | grep ${i}${num}s2g | cut -f 2 | cut -d " " -f 1`"
-        mount /dev/${i}${num}s2g /mnt${MNT2}
-
-
-        if [ -e "/mnt/PCBSD" ]
-        then
-
- 	# Create Script
-        echo "#!/bin/sh
-/usr/local/bin/PBReg get /PC-BSD/Version >/.pcver 2>/.pcver " >/mnt/getver.sh
-        chmod 755 /mnt/getver.sh
-        chroot /mnt /getver.sh
-        VER="`cat /mnt/.pcver`"
-       
-        # Remove old files
-        rm /mnt/.pcver
-        rm /mnt/getver.sh
-
-        # Echo our saved info
-        echo "/dev/${i}${num}s2a: Running PC-BSD ${VER}" >> /tmp/AvailUpgrades
-
-        fi # End of if /mnt/PCBSD
-
-        # Unmount FS
- 	umount /mnt/$MNT2
-        umount /mnt/$MNT1
- 	umount /mnt/$MNT
-	umount /mnt      
-
-     fi
-
-     if [ -e "/dev/${i}${num}s3a" ]
-     then
-
-        mount /dev/${i}${num}s3a /mnt
-        if [ -e "/dev/${i}${num}s3b" ]
-        then
-           swapon /dev/${i}${num}s3b
-        fi
-
-        MNT="`cat /mnt/etc/fstab | grep ${i}${num}s3e | cut -f 2 | cut -d " " -f 1`"
-        mount /dev/${i}${num}s3e /mnt${MNT}
-        
-	MNT1="`cat /mnt/etc/fstab | grep ${i}${num}s3f | cut -f 2 | cut -d " " -f 1`"
-        mount /dev/${i}${num}s3f /mnt${MNT1}
-
-	MNT2="`cat /mnt/etc/fstab | grep ${i}${num}s3g | cut -f 2 | cut -d " " -f 1`"
-        mount /dev/${i}${num}s3g /mnt${MNT2}
-
-
-        if [ -e "/mnt/PCBSD" ]
-        then
-
- 	# Create Script
-        echo "#!/bin/sh
-/usr/local/bin/PBReg get /PC-BSD/Version >/.pcver 2>/.pcver " >/mnt/getver.sh
-        chmod 755 /mnt/getver.sh
-        chroot /mnt /getver.sh
-        VER="`cat /mnt/.pcver`"
-       
-        # Remove old files
-        rm /mnt/.pcver
-        rm /mnt/getver.sh
-
-        # Echo our saved info
-        echo "/dev/${i}${num}s3a: Running PC-BSD ${VER}" >> /tmp/AvailUpgrades
-
-        fi # End of if /mnt/PCBSD
-
-        # Unmount FS
- 	umount /mnt/$MNT2
-        umount /mnt/$MNT1
- 	umount /mnt/$MNT
-	umount /mnt      
-
-     fi # End of if /dev/s3a
-
-     if [ -e "/dev/${i}${num}s4a" ]
-     then
-
-        mount /dev/${i}${num}s4a /mnt
-        if [ -e "/dev/${i}${num}s4b" ]
-        then
-           swapon /dev/${i}${num}s4b
-        fi
-
-        MNT="`cat /mnt/etc/fstab | grep ${i}${num}s4e | cut -f 2 | cut -d " " -f 1`"
-        mount /dev/${i}${num}s4e /mnt${MNT}
-        
-	MNT1="`cat /mnt/etc/fstab | grep ${i}${num}s4f | cut -f 2 | cut -d " " -f 1`"
-        mount /dev/${i}${num}s4f /mnt${MNT1}
-
-	MNT2="`cat /mnt/etc/fstab | grep ${i}${num}s4g | cut -f 2 | cut -d " " -f 1`"
-        mount /dev/${i}${num}s4g /mnt${MNT2}
-
-
-        if [ -e "/mnt/PCBSD" ]
-        then
-
- 	# Create Script
-        echo "#!/bin/sh
-/usr/local/bin/PBReg get /PC-BSD/Version >/.pcver 2>/.pcver " >/mnt/getver.sh
-        chmod 755 /mnt/getver.sh
-        chroot /mnt /getver.sh
-        VER="`cat /mnt/.pcver`"
-       
-        # Remove old files
-        rm /mnt/.pcver
-        rm /mnt/getver.sh
-
-        # Echo our saved info
-        echo "/dev/${i}${num}s4a: Running PC-BSD ${VER}" >> /tmp/AvailUpgrades
-
-        fi # End of if /mnt/PCBSD
-
-        # Unmount FS
- 	umount /mnt/$MNT2
-        umount /mnt/$MNT1
- 	umount /mnt/$MNT
-	umount /mnt      
-
-     fi
-
-
-     if [ "$num" = "9" ]
-     then
-        break;
-     fi
-    
-    num="`expr ${num} + 1`"
-  done
 done
-



More information about the Commits mailing list