Add confirmation for drive selection

This commit is contained in:
Tseng Wynn 2022-05-10 15:23:34 +08:00 committed by GitHub
parent 817256cf76
commit 277dc65124
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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}