2022-11-23 01:28:30 +00:00
|
|
|
#!/bin/sh -ex
|
2022-01-08 20:47:30 +00:00
|
|
|
# Update an Easy2Boot USB Stick after adding ISOs
|
2022-02-10 15:01:51 +00:00
|
|
|
# Call with Linux ISOs to be copied as args
|
|
|
|
# Need to be around E2B mountpoint if it is not the default
|
2023-05-09 12:02:32 +00:00
|
|
|
if ! dir="$(find . "${MNT:-${XDG_RUNTIME_DIR}/mnt}" -maxdepth 3 -name _ISO -type d | grep --max-count 1 .)"
|
2022-11-09 17:52:27 +00:00
|
|
|
then echo "Please mount your multiboot stick first!"
|
|
|
|
exit 1
|
|
|
|
fi
|
2022-11-23 01:28:30 +00:00
|
|
|
|
2023-05-09 12:02:32 +00:00
|
|
|
cmd=cp
|
2022-11-23 01:28:30 +00:00
|
|
|
case $1 in
|
2023-05-09 12:02:32 +00:00
|
|
|
(-upgrade) upgrade=$2; shift 2;;
|
2022-11-23 01:28:30 +00:00
|
|
|
(-cp) cmd=cp; shift;;
|
2023-05-09 12:02:32 +00:00
|
|
|
(-mv) cmd=mv; shift;;
|
2022-11-23 01:28:30 +00:00
|
|
|
esac
|
|
|
|
test $# -eq 0 || $cmd -vi "$@" "$dir/LINUX"
|
|
|
|
find "$dir" -type f -iname "*32-*.iso" -exec mv -vi {} {}def32 \;
|
2023-02-07 12:19:34 +00:00
|
|
|
find "$dir" -type f -name "*.iso" -exec mv -vi {} {}def64 \;
|
2023-05-09 12:02:32 +00:00
|
|
|
mountdir="$(dirname "$dir")"
|
|
|
|
drive=$(mount | grep "$mountdir" | cut -d' ' -f1)
|
|
|
|
sudo umount "$drive"
|
|
|
|
if test "$upgrade"; then
|
|
|
|
echo "Do you want to reformat $drive as NTFS? (Ctrl-C to abort)"
|
|
|
|
read
|
|
|
|
mkfs -t ntfs "$drive"
|
|
|
|
ntfslabel "$drive" "E2B"
|
|
|
|
sudo mount "$drive" "$mountdir"
|
|
|
|
unzip "$upgrade" -d "$mountdir"
|
|
|
|
touch -v "$dir/nodelay.txt"
|
|
|
|
cp -v /mnt/nas/media/iso/utilities/*.iso "$dir/UTILITIES"
|
|
|
|
else
|
|
|
|
sudo udefrag -m "$drive"
|
|
|
|
fi
|