[or-cvs] r12017: Fix selection of multiple drives/partitions. Allow other blo (incognito/trunk/root_overlay/usr/sbin)

double at seul.org double at seul.org
Thu Oct 18 13:43:30 UTC 2007


Author: double
Date: 2007-10-18 09:43:29 -0400 (Thu, 18 Oct 2007)
New Revision: 12017

Modified:
   incognito/trunk/root_overlay/usr/sbin/create-usb
Log:
Fix selection of multiple drives/partitions.
Allow other block devices if OTHER_BLOCK is defined.


Modified: incognito/trunk/root_overlay/usr/sbin/create-usb
===================================================================
--- incognito/trunk/root_overlay/usr/sbin/create-usb	2007-10-18 13:22:21 UTC (rev 12016)
+++ incognito/trunk/root_overlay/usr/sbin/create-usb	2007-10-18 13:43:29 UTC (rev 12017)
@@ -5,6 +5,7 @@
 #
 
 DEFAULT_WIDTH=80
+# declare OTHER_BLOCK to allow block devices besides USB
 
 # show an xdialog of available USB drives. the one which the user choses is partitioned into
 # a single big partition. USBPART will stored the new partition and USBDEV the device.
@@ -18,12 +19,16 @@
 
     I=0
 
-    for DEV in $(ls /sys/block/sd*/dev); do
+    for DEV in $(ls /sys/block/sd*/dev) ${OTHER_BLOCK:+$(ls /sys/block/hd*/dev)}; do
         DEV_DIR="$(dirname ${DEV})"
-        ON_USB="$(ls -l ${DEV_DIR}/device | grep -c usb)"
-        REM="$(cat ${DEV_DIR}/removable)"
+	if [[ -z "${OTHER_BLOCK}" ]]; then
+	        ON_USB="$(ls -l ${DEV_DIR}/device | grep -c usb)"
+	        REM="$(cat ${DEV_DIR}/removable)"
+	else
+		ON_USB="1"
+		REM="1"
+	fi
         DEV_NODE="$(find /dev -type b | xargs stat --format 'echo %n $(( 0x%t )):$(( 0x%T ))' | bash -s | grep [^0-9]$(<${DEV_DIR}/dev)$ | awk '{ print $1 }')"
-	
         if [ "${ON_USB}" -eq 1 -a "${REM}" -eq 1 -a -w "${DEV_NODE}" ]; then
 	    DEVICES[$I]="${DEV_NODE}"
 	    SYSPATH[$I]="${DEV_DIR}"
@@ -39,7 +44,7 @@
 	exit 1
     fi
     
-    USBDEV="$( ${DIALOG} --stdout --combobox "Please select a USB drive to copy the CD onto. Please note that this process will destroy all data on the selected USB drive, it is your responsibility to ensure any important data is backed up elsewhere." 0 ${DEFAULT_WIDTH} "${LIST}" | awk '{ print $1 }' )"
+    USBDEV="$( ${DIALOG} --stdout --combobox "Please select a USB drive to copy the CD onto. Please note that this process will destroy all data on the selected USB drive, it is your responsibility to ensure any important data is backed up elsewhere." 0 ${DEFAULT_WIDTH} "${LIST[@]}" | awk '{ print $1 }' )"
 
     if [[ -z "${USBDEV}" ]]; then
 	${DIALOG} --msgbox "No USB drive selected, exiting" 0 ${DEFAULT_WIDTH}
@@ -76,11 +81,16 @@
     I=0
 
     # Find available USB drives with vfat partitions
-    for DEV in $(ls /sys/block/sd*/sd*/dev); do
+    for DEV in $(ls /sys/block/sd*/sd*/dev) ${OTHER_BLOCK:+$(ls /sys/block/hd*/hd*/dev)}; do
 	PART_DIR="$(dirname ${DEV})"
 	DEV_DIR="$(dirname ${PART_DIR})"
-	ON_USB="$(ls -l ${DEV_DIR/device} | grep -c usb)"
-	REM="$(cat ${DEV_DIR}/removable)"
+	if [[ -z "${OTHER_BLOCK}" ]]; then
+	        ON_USB="$(ls -l ${DEV_DIR}/device | grep -c usb)"
+	        REM="$(cat ${DEV_DIR}/removable)"
+	else
+		ON_USB="1"
+		REM="1"
+	fi
 	DEV_NODE="$(find /dev -type b | xargs stat --format 'echo %n $(( 0x%t )):$(( 0x%T ))' | bash -s | grep [^0-9]$(<${DEV})$ | awk '{ print $1 }')"
 	FSTYPE="$(/lib/udev/vol_id -t ${DEV_NODE})"
 	if [ "${ON_USB}" -eq 1 -a "${REM}" -eq 1 -a -w "${DEV_NODE}" -a "${FSTYPE}" == "vfat" ]; then
@@ -102,7 +112,7 @@
 	fi
     fi
 
-    USBPART="$( ${DIALOG} --stdout --combobox "Please select a USB partition to copy the CD onto. Please note that this process may destroy the data on your USB drive, it is your responsibility to ensure any important data is backed up elsewhere." 9 ${DEFAULT_WIDTH} "${LIST}" | awk '{ print $1 }' )"
+    USBPART="$( ${DIALOG} --stdout --combobox "Please select a USB partition to copy the CD onto. Please note that this process may destroy the data on your USB drive, it is your responsibility to ensure any important data is backed up elsewhere." 9 ${DEFAULT_WIDTH} "${LIST[@]}" | awk '{ print $1 }' )"
 
     if [[ -z "${USBPART}" ]]; then
 	${DIALOG} --msgbox "No USB drive partition selected, exiting" 0 ${DEFAULT_WIDTH}



More information about the tor-commits mailing list