blob: f6792ab75ccdfe36882acc260903501f1abd95dd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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."
|