From 277dc65124c12fe0fd74cbf4d4f05edd1f822f83 Mon Sep 17 00:00:00 2001 From: Tseng Wynn Date: Tue, 10 May 2022 15:23:34 +0800 Subject: [PATCH] Add confirmation for drive selection --- airootfs/usr/local/bin/holoinstall | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/airootfs/usr/local/bin/holoinstall b/airootfs/usr/local/bin/holoinstall index 3152aa7..7ec6e20 100755 --- a/airootfs/usr/local/bin/holoinstall +++ b/airootfs/usr/local/bin/holoinstall @@ -27,16 +27,32 @@ fi base_os_install() { lsblk read "?Enter your desired drive node here (for example, sda or nvme0n1): " DRIVEDEVICE - read "?WARNING: This drive is going to be erased fully. Press enter to continue, or CTRL+Z to terminate" + #read "?WARNING: This drive is going to be erased fully. Press enter to continue, or CTRL+Z to terminate" DEVICE="/dev/${DRIVEDEVICE}" INSTALLDEVICE="${DEVICE}" + echo ${DEVICE} | grep -q -P "^/dev/(nvme|loop|mmcblk)" if [ $? -eq 0 ]; then INSTALLDEVICE="${DEVICE}p" fi + if [ ! -b $DEVICE ]; then + echo "$DEVICE not found! Installation Aborted!" + exit 1 + fi + + echo "\n\nWARNING: The following drive is going to be erased fully. ALL DATA ON DRIVE $DEVICE WILL BE LOST!" + lsblk $DEVICE + echo -n "Erase $DEVICE and begin installation(y/N): " + read ANS + + if [[ ! ($ANS = 'y' || $ANS = 'Y') ]]; then + echo "Installation Aborted!" + exit 1 + fi + echo "\nCreating partitions..." sfdisk --delete ${DEVICE} wipefs -a ${DEVICE}