Changed usb mount lcoationa dn write code to be insite if

This commit is contained in:
poslop
2025-07-31 15:00:57 -05:00
parent 7d322f391d
commit 7aea11370c

View File

@@ -23,42 +23,47 @@ if [[ $EUID -ne 0 ]]; then
fi fi
if [[ $DEBUG == "true" ]]; then
echo "DEBUG is true"
fi
# Set your target disk here # Set your target disk here
udevadm trigger udevadm trigger
lsblk lsblk
echo echo
read -rp "Enter the target disk (e.g., sda): " disk_suffix read -rp "Enter the target disk (e.g., sda): " disk_suffix
disk_name="/dev/${disk_suffix}" disk_name="/dev/${disk_suffix}"
echo "Chose disk $disk_name"
echo 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 usb_name="/dev/mapper/${disk_suffix}"
echo "Exiting script"
exit
fi
# Mount Ventoy user_response = "n"
echo "Mounting Ventoy..."
mkdir -p /mnt/ventoy read -rp "You are about to WRITE and ERASE disk ${disk_name} | Are you sure? y/n: " user_response
mount $usb_name /mnt/ventoy
cd /mnt/ventoy/Images 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..." echo "Writing image to $disk_name..."
lz4 -dc PBX-LVM.img.lz4 | dd of=$disk_name status=progress lz4 -dc PBX-LVM.img.lz4 | dd of=$disk_name status=progress
fi fi
# Repartition disk using sgdisk # Repartition disk using sgdisk
echo "Repairing partition tables" echo "Repairing partition tables"
sgdisk -e $disk_name sgdisk -e $disk_name