diff options
author | doc <doc@filenotfound.org> | 2025-06-28 15:19:43 +0000 |
---|---|---|
committer | doc <doc@filenotfound.org> | 2025-06-28 15:19:43 +0000 |
commit | 6c7cbbcd5d9140bd7db9d75abcdb687a8beadf2b (patch) | |
tree | a73c3b2adecb44dd6eae209ce42e4afcbb777a83 |
-rwxr-xr-x | burnit.sh | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/burnit.sh b/burnit.sh new file mode 100755 index 0000000..f6792ab --- /dev/null +++ b/burnit.sh @@ -0,0 +1,72 @@ +#!/bin/bash +# burnit.sh - Interactive ISO-to-USB writer with menu + +set -euo pipefail + +ISO_DIR="/gigapool/vms/isos" # Change this to wherever you keep ISOs + +echo "๐ฅ Welcome to burnit.sh โ ISO burner for Unix junkies." +echo + +# Step 1: List ISOs in ISO_DIR +echo "๐ Scanning for ISOs in: $ISO_DIR" +mapfile -t isos < <(find "$ISO_DIR" -maxdepth 1 -type f \( -iname "*.iso" -o -iname "*.img" \) | sort) + +if [[ ${#isos[@]} -eq 0 ]]; then + echo "โ No ISO or IMG files found in $ISO_DIR." + exit 1 +fi + +echo "๐ฆ Available ISO/IMG files:" +for i in "${!isos[@]}"; do + printf " [%d] %s\n" "$i" "$(basename "${isos[$i]}")" +done + +echo +read -rp "๐ฏ Pick an image number: " index + +if ! [[ "$index" =~ ^[0-9]+$ ]] || (( index < 0 || index >= ${#isos[@]} )); then + echo "โ Invalid selection." + exit 1 +fi + +iso="${isos[$index]}" +echo "โ
Selected: $(basename "$iso")" +echo + +# Step 2: List available removable devices +echo "๐ฝ Scanning removable block devices..." +lsblk -o NAME,SIZE,MODEL,MOUNTPOINT,TRAN,VENDOR,HOTPLUG | grep -E '1$' || true +echo + +read -rp "๐งจ Enter the target device (e.g., /dev/sdX): " target +if [[ ! -b "$target" ]]; then + echo "โ Device not found: $target" + exit 1 +fi + +echo +read -rp "โ ๏ธ ARE YOU SURE you want to overwrite $target with $iso? [y/N]: " confirm +if [[ "$confirm" != "y" && "$confirm" != "Y" ]]; then + echo "๐ Aborted." + exit 1 +fi + +echo +echo "๐ Flashing image..." +sleep 1 + +pv "$iso" | sudo dd of="$target" bs=4M status=progress oflag=sync + +echo +echo "โ
Done writing to $target." + +# Optional: Eject +if mount | grep "$target" > /dev/null; then + sudo umount "${target}"* || true +fi +if command -v eject &> /dev/null; then + sudo eject "$target" || true +fi + +echo "๐ฟ Bootable media is ready to rock." |