You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vcl.apache.org by ar...@apache.org on 2014/03/28 17:11:04 UTC

svn commit: r1582791 - /vcl/sandbox/xcat2partimageng/partimageng

Author: arkurth
Date: Fri Mar 28 16:11:04 2014
New Revision: 1582791

URL: http://svn.apache.org/r1582791
Log:
VCL-757
Added checks to partimageng to detect and ignore USB drives.

Modified:
    vcl/sandbox/xcat2partimageng/partimageng

Modified: vcl/sandbox/xcat2partimageng/partimageng
URL: http://svn.apache.org/viewvc/vcl/sandbox/xcat2partimageng/partimageng?rev=1582791&r1=1582790&r2=1582791&view=diff
==============================================================================
--- vcl/sandbox/xcat2partimageng/partimageng (original)
+++ vcl/sandbox/xcat2partimageng/partimageng Fri Mar 28 16:11:04 2014
@@ -7,11 +7,11 @@ partimageinstall () {
     imgpath=$(dirname $1) # needs to be path to image files
     myimage=$(basename $1 .img) # needs to be image without path or .gz
     disk=$(basename $2) # needs to be disk - i.e. sda
-
+    
     altdisk=$disk
     if [[ "$disk" = "sdb" ]] &&
         dmesg | grep -q 'SCSI device sdb' &&
-        ! dmesg | grep -q 'SCSI device sda' &&
+        (! dmesg | grep -q 'SCSI device sda' || ls /dev/disk/by-id -l | grep -q sda | grep -q usb) &&   # sda doesn't exist or it exists and is usb
         [[ -f $myimage-sda.sfdisk ]] &&
         [[ ! -f $myimage-sdb.sfdisk ]] ; then
             altdisk="sda"
@@ -82,11 +82,11 @@ partimagesave () {
     imgpath=$(dirname $1) # needs to be path to image files
     myimage=$(basename $1 .img) # needs to be image without path or .gz
     disk=$(basename $2) # needs to be disk - i.e. sda
-
+    
     altdisk=$disk
     if [[ "$disk" = "sdb" ]] &&
         dmesg | grep -q 'SCSI device sdb' &&
-        ! dmesg | grep -q 'SCSI device sda' ; then
+        (! dmesg | grep -q 'SCSI device sda' || ls /dev/disk/by-id -l | grep -q sda | grep -q usb) ; then   # sda doesn't exist or it exists and is usb
             altdisk="sda"
     fi
 
@@ -199,21 +199,19 @@ devices=`\ls -l /dev/disk/by-id | awk '{
 logger -t xcat "disks: $devices"
 
 if [ "x$device" == "x" ] ; then
-    device=$(\ls /dev/disk/by-id -l | grep -v total | head -1 | awk '{print $11}' | sed 's/[\.\/]//g')
-    if ! echo $device | egrep -q '(sda|hda)'; then
-        device=$(cat /proc/partitions  | egrep -v '(ram|major)' | egrep '\w' | head -1 | awk '{print $4}')
-    fi
-    if ! echo $device | egrep -q '(sda|hda)'; then
-        device=$(\ls /dev/disk/by-id -l | grep -v total | head -1 | awk '{print $11}' | sed 's/[\.\/]//g')
-        if ! echo $device | egrep -q '(sdb|hdb)'; then
-            device=$(cat /proc/partitions  | egrep -v '(ram|major)' | egrep '\w' | head -1 | awk '{print $4}')
-        fi
+    device=$(\ls /dev/disk/by-id -l | grep -v total | grep -v usb | head -1 | awk '{print $11}' | sed 's/[\.\/]//g')
+    if ! echo $device | egrep -q '(sd[a-f]|hd[a-f])'; then
+        device=$(cat /proc/partitions  | egrep -v '(ram|major)' | egrep '\w' | sort -k 3 -n -r | head -1 | awk '{print $4}')
     fi
-    if ! echo $device | egrep -q '(sda|hda|sdb|hdb)'; then
+    if ! echo $device | egrep -q '(sd[a-f]|hd[a-f])'; then
         echo "No device specified and could not guess a valid device"
         logger -t xcat "partimage failed: no device specified and could not guess a valid device"
-        /xcatpost/updateflag.awk $MASTER 3002
-        /sbin/reboot
+        #/xcatpost/updateflag.awk $MASTER 3002
+        if [ "x$reboot" == "xreboot" ] ; then
+            /sbin/reboot
+        else
+                while : ; do sleep 3600 ; done
+        fi
         exit 1
     else
         echo "No device specified, trying with guessed device /dev/$device"