Files
vms/modify_timeout.sh
T
Greg HellingsandGitHub 634aae8d75 Do some better linting (#13)
* Do some better linting

* Update names, Packer version, and more

* Do not lint on push

* More linting and scripting

* Cleanup shellcheck lint

* Add Packer format check

* Fix Packer formatting

* Limit to only one

* Remove generated HCL files

* Only lint checked files

* Use pipes instead

* Improve attempt to build

Actually go back to attempting to build boxes on GitHub. Maybe it will
work better with this structure

* Change to using environment files

* Initialize plugins, first

* More verbose usage of the file

* Do the output properly this time

* PACKER_LOG set to 1

* No need for python3 anymore

* Limit to only one result

* Choose a specific CPU model

* Init separately

* Update actions version

* Add version outputting

* Correct actions version

* Try to execute qemu properly

* Fix CPU model name

* Do not over-subscribe GitHub runners

* Try type instead of command to guard runs

* Do not write to non-existent folder

* Cache packer plugins

* Use ~ instead of /home/greg

* Try the proper path

* Move to intelligent matrix

* Set global env path

* Add lots of waits for VBoxManage on hosted runners

* Add more waits

* Add more waits
2023-12-06 10:21:32 -06:00

39 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
set -exo pipefail
distro="${1}"
# Find URL
url="$(grep -e url "${distro}" | cut -f2 -d'"')"
curl -C - -O "${url}"
# Mount and extract
file=$(printf '%s' "${url}" | sed -E -e 's#.*/(.*)$#\1#')
work="$(mktemp -d)"
xorriso -osirrox on -indev "${file}" -extract / "${work}"
# Modify timeout
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}"
# Create new ISO file
rm "${file}"
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}"
new_sum=$(sha256sum "${file}" | cut -f1 -d' ')
# Update distro file
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}"
# Cleanup remaining directories
rm -r "${work}" || true