瀏覽代碼

Merge branch 'xen0l-master'

* xen0l-master:
  Clean up array / count handling.
  rmformat detects CD-ROM as a removable media, use disklist -r instead
Jakob Borg 11 年之前
父節點
當前提交
acdc1919e4
共有 1 個文件被更改,包括 7 次插入5 次删除
  1. 7 5
      platform-upgrade

+ 7 - 5
platform-upgrade

@@ -13,13 +13,15 @@ cd "$tmp" || exit -1
 
 echo -n "Checking current boot device..."
 if [[ -z $1 ]] ; then
-        usb=$(rmformat | grep Logical | awk '{print $4}' | sed 's/rdsk/dsk/;s/p0$/p1/')
-        echo -n " detected $usb"
-        usb_count=(${usb})
-        if [ ${#usb_count[@]} -gt 1 ]; then
-                  echo " Warning: more than one removable device detected."
+        removables=($(disklist -r))
+        echo -n " detected ${removables[@]}"
+        if [[ ${#removables[@]} -gt 1 ]]; then
+                  echo
+                  echo "Error: more than one removable device detected."
+		  echo "Specify correct device on the command line."
                   exit -1
         fi
+	usb="/dev/dsk/${removables[0]}p1"
 else   
         usb="$1"
         echo -n " using $usb"