diff --git a/Ventoy/CloneToDisk.sh b/Ventoy/CloneToDisk.sh index a7c0d79..be1ce47 100755 --- a/Ventoy/CloneToDisk.sh +++ b/Ventoy/CloneToDisk.sh @@ -1,7 +1,36 @@ #!/bin/bash set -e +# root check +if [[ $EUID -ne 0 ]]; then + echo "You must be root to do this." 1>&2 + exit 100 +fi + mount_points=("/dev" "/dev/pts" "/proc" "/sys" "/sys/firmware/efi/efivars" "/run") +NO_WRITE=false + +# arguments +for arg in "$@"; do + case $arg in + --nowrite) + NO_WRITE=true + shift + ;; + -h) + printf "%-20s %s\n" "Flags:" "Description:" + echo + printf "%-20s %s\n" "--nowrite" "Disables Writing to Disk only modifys Existing Partitions" + exit 1 + ;; + *) + echo "Unknown option: $arg" + echo "Try -h" + exit 1 + ;; + esac +done + cleanup() { echo "Cleaning Mounts" @@ -16,14 +45,6 @@ cleanup() { } 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 - exit 100 -fi - - - # Set your target disk here udevadm trigger @@ -38,8 +59,8 @@ disk_name="/dev/${disk_suffix}" echo "Chose disk $disk_name" echo -if [[ $NO_WRITE == "true" ]]; then - echo "NO_WRITE is true no need for Img no disks will be written to" +if [[ $NO_WRITE == true ]]; then + echo "--nowrite is specified 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