2022-05-31 14:54:02 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
set -exo pipefail
|
|
|
|
|
|
|
|
|
|
distro="${1}"
|
|
|
|
|
|
|
|
|
|
# Find URL
|
2023-12-06 08:21:32 -08:00
|
|
|
url="$(grep -e url "${distro}" | cut -f2 -d'"')"
|
2022-05-31 14:54:02 -05:00
|
|
|
curl -C - -O "${url}"
|
|
|
|
|
|
2022-06-08 01:39:37 -05:00
|
|
|
# Mount and extract
|
2023-12-06 08:21:32 -08:00
|
|
|
file=$(printf '%s' "${url}" | sed -E -e 's#.*/(.*)$#\1#')
|
2022-06-08 01:39:37 -05:00
|
|
|
work="$(mktemp -d)"
|
|
|
|
|
xorriso -osirrox on -indev "${file}" -extract / "${work}"
|
2022-05-31 14:54:02 -05:00
|
|
|
|
|
|
|
|
# Modify timeout
|
2022-06-08 01:39:37 -05:00
|
|
|
chmod -R +w "${work}"
|
|
|
|
|
sed -i -e 's/set timeout=.*/set timeout=30/' "${work}/boot/grub/grub.cfg"
|
|
|
|
|
sed -i -e 's/timeout.*/timeout 300/' "${work}/isolinux/isolinux.cfg" # Uses 10ths of a second
|
|
|
|
|
chmod -R -w "${work}"
|
2022-05-31 14:54:02 -05:00
|
|
|
|
|
|
|
|
# Create new ISO file
|
|
|
|
|
rm "${file}"
|
2022-06-08 01:39:37 -05:00
|
|
|
chmod +w "${work}/ubuntu" "${work}/isolinux/isolinux.bin"
|
|
|
|
|
mkisofs -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -J -R -V "Boot" -r -iso-level 3 -chrp-boot -o "${file}" "${work}"
|
2022-05-31 14:54:02 -05:00
|
|
|
new_sum=$(sha256sum "${file}" | cut -f1 -d' ')
|
|
|
|
|
|
|
|
|
|
# Update distro file
|
2022-06-08 01:39:37 -05:00
|
|
|
if [ "$(uname)" == "Darwin" ]; then
|
|
|
|
|
SED=$(which gsed)
|
|
|
|
|
else
|
|
|
|
|
SED=$(which sed)
|
|
|
|
|
fi
|
|
|
|
|
"${SED}" -i -e "s/checksum = \".*\"/checksum = \"${new_sum}\"/" "${distro}"
|
|
|
|
|
"${SED}" -i -e "s/url = \".*\"/url = \"${file}\"/" "${distro}"
|
|
|
|
|
"${SED}" -i -e "s/boot_wait = \".*\"/boot_wait = \"15s\"/" "${distro}"
|
2022-05-31 14:54:02 -05:00
|
|
|
|
|
|
|
|
# Cleanup remaining directories
|
2022-06-08 01:39:37 -05:00
|
|
|
rm -r "${work}" || true
|