confirm prompt
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
|
||||
cleanup() {
|
||||
echo "Cleaning up mounts..."
|
||||
umount -lfR /mnt 2>/dev/null || true
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
# Ensure the script is run as root
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "You must be root to do this." 1>&2
|
||||
@@ -20,6 +27,13 @@ echo
|
||||
read -rp "Enter the name of the usb partition in /dev/mapper (e.g., sda1): " disk_suffix
|
||||
usb_name="/dev/mapper/${disk_suffix}"
|
||||
|
||||
read -rp "You are about to WRITE and ERASE disk ${disk_name} Are you sure? y/n " user_response
|
||||
|
||||
if [[ $user_response != y ]]; then
|
||||
echo "Exiting script"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Mount Ventoy
|
||||
echo "Mounting Ventoy..."
|
||||
mkdir -p /mnt/ventoy
|
||||
@@ -66,9 +80,10 @@ update-grub
|
||||
"
|
||||
|
||||
# Exit chroot and unmount
|
||||
echo "Cleaning up..."
|
||||
umount -R /mnt
|
||||
#echo "Cleaning up..."
|
||||
#umount -R /mnt
|
||||
|
||||
|
||||
echo "Restore and resize complete!"
|
||||
|
||||
cleanup
|
||||
|
||||
Reference in New Issue
Block a user