diff --git a/Ventoy/CloneToDisk.sh b/Ventoy/CloneToDisk.sh index 41fe976..a7c0d79 100755 --- a/Ventoy/CloneToDisk.sh +++ b/Ventoy/CloneToDisk.sh @@ -23,42 +23,47 @@ if [[ $EUID -ne 0 ]]; then fi -if [[ $DEBUG == "true" ]]; then - echo "DEBUG is true" -fi # Set your target disk here udevadm trigger lsblk - echo + + + read -rp "Enter the target disk (e.g., sda): " disk_suffix disk_name="/dev/${disk_suffix}" +echo "Chose disk $disk_name" 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 [[ $NO_WRITE == "true" ]]; then + echo "NO_WRITE is true no need for Img no disks will be written to" +else + read -rp "Enter the name of the usb partition in /dev/mapper (e.g., sda1): " disk_suffix -if [[ $user_response != y ]]; then - echo "Exiting script" - exit -fi + usb_name="/dev/mapper/${disk_suffix}" -# Mount Ventoy -echo "Mounting Ventoy..." -mkdir -p /mnt/ventoy -mount $usb_name /mnt/ventoy -cd /mnt/ventoy/Images + user_response = "n" + + 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 + fi + + echo "Mounting Ventoy..." + mkdir -p /mnt/ventoy + mount $usb_name /mnt/ventoy + cd /mnt/ventoy/Images -# Decompress and write image -if [[ $DEBUG != "true" ]]; then echo "Writing image to $disk_name..." lz4 -dc PBX-LVM.img.lz4 | dd of=$disk_name status=progress fi + # Repartition disk using sgdisk echo "Repairing partition tables" sgdisk -e $disk_name