From 6c7cbbcd5d9140bd7db9d75abcdb687a8beadf2b Mon Sep 17 00:00:00 2001 From: doc Date: Sat, 28 Jun 2025 15:19:43 +0000 Subject: Initial commit of burnit.sh --- burnit.sh | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100755 burnit.sh 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." -- cgit v1.2.3