summaryrefslogtreecommitdiff
path: root/scripts/disk-util
diff options
context:
space:
mode:
authorNicolas Zingilé <nicolas.zingile@open.eurogiciel.org>2014-10-27 17:53:55 +0100
committerStephane Desneux <stephane.desneux@open.eurogiciel.org>2014-10-27 17:41:00 +0100
commit849cf3840a1feae5710b71e74a480ff7e3e3a4fd (patch)
tree57d66513b55c156dc79ed4073f0fe77dc7948bad /scripts/disk-util
parentb0461ebffb78765aad7e613fbbdc85bcc3e275a9 (diff)
downloadsystem-installer-849cf3840a1feae5710b71e74a480ff7e3e3a4fd.tar.gz
system-installer-849cf3840a1feae5710b71e74a480ff7e3e3a4fd.tar.bz2
system-installer-849cf3840a1feae5710b71e74a480ff7e3e3a4fd.zip
Signed-off-by: Nicolas Zingilé <nicolas.zingile@open.eurogiciel.org>
Diffstat (limited to 'scripts/disk-util')
-rwxr-xr-xscripts/disk-util38
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