diff options
author | Nicolas Zingilé <nicolas.zingile@open.eurogiciel.org> | 2014-10-27 17:53:55 +0100 |
---|---|---|
committer | Stephane Desneux <stephane.desneux@open.eurogiciel.org> | 2014-10-27 17:41:00 +0100 |
commit | 849cf3840a1feae5710b71e74a480ff7e3e3a4fd (patch) | |
tree | 57d66513b55c156dc79ed4073f0fe77dc7948bad /scripts/disk-util | |
parent | b0461ebffb78765aad7e613fbbdc85bcc3e275a9 (diff) | |
download | system-installer-849cf3840a1feae5710b71e74a480ff7e3e3a4fd.tar.gz system-installer-849cf3840a1feae5710b71e74a480ff7e3e3a4fd.tar.bz2 system-installer-849cf3840a1feae5710b71e74a480ff7e3e3a4fd.zip |
initial packagingsubmit/tizen_common/20141027.182159submit/tizen_3.0.2014.q3_common/20141027.182244accepted/tizen/common/20141027.182351accepted/tizen/3.0.2014.q3/common/20141027.182404tizen_3.0.2014.q3_common
Signed-off-by: Nicolas Zingilé <nicolas.zingile@open.eurogiciel.org>
Diffstat (limited to 'scripts/disk-util')
-rwxr-xr-x | scripts/disk-util | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/scripts/disk-util b/scripts/disk-util new file mode 100755 index 0000000..a4bdaa0 --- /dev/null +++ b/scripts/disk-util @@ -0,0 +1,38 @@ +#!/bin/bash + +# List block devices that are not removable, +# if multiple devices are found, the user will be invited to choose one. +# If no devices are found, the program exit with error code 1 + +outfile=${1:-/dev/stdout} +utilspath=/usr/lib/system-installer + +. $utilspath/dialog-helper + +target_array=() +for i in /sys/block/*/device; do + [ -d "$i/slaves" ] && continue + dev=$(echo $i | cut -d'/' -f-4) + outdev=$(echo $i | cut -d'/' -f4) + grep -q 1 "$dev/removable" + if [ "$?" = "1" ]; then + target_array+=("/dev/$outdev") + fi +done + +if (( "${#target_array[@]}" == "1" )); then + TARGET="${target_array[0]}" +elif (( "${#target_array[@]}" > "1" )); then + install_dest="Installation destination device :" + dialog_helper --no-items --menu "${install_dest}" 10 40 3 $( for i in "${target_array[@]}"; do echo "$i"; done ) + TARGET="$DIALOGRES" +else + $DIALOG --msgbox "No devices could be found, no installation possible" 24 70 + exit 1 +fi + +cat << EOC > $outfile +$TARGET +EOC + +exit 0 |