diff options
| author | Stefan Kreutz <mail@skreutz.com> | 2026-04-11 23:36:17 +0200 |
|---|---|---|
| committer | Stefan Kreutz <mail@skreutz.com> | 2026-04-11 23:36:17 +0200 |
| commit | e583e2cd9b622bbd7c165767554f7debc7c042fb (patch) | |
| tree | 4bfeecdf96bc9c4440918c7bd6a2af5421080891 | |
| parent | 68725a3001488067b36cf143972900a9e94c50f1 (diff) | |
| download | autoinstall-openbsd-on-qemu-e583e2cd9b622bbd7c165767554f7debc7c042fb.tar.gz | |
Add option to override OpenBSD release
| -rwxr-xr-x | autoinstall-openbsd-on-qemu | 66 |
1 files changed, 38 insertions, 28 deletions
diff --git a/autoinstall-openbsd-on-qemu b/autoinstall-openbsd-on-qemu index efe94af..3b01c8e 100755 --- a/autoinstall-openbsd-on-qemu +++ b/autoinstall-openbsd-on-qemu @@ -1,6 +1,6 @@ #! /bin/sh -# Auto-install OpenBSD/amd64 7.8 on QEMU. +# Auto-install OpenBSD/amd64 on QEMU. # # First published at https://www.skreutz.com/posts/autoinstall-openbsd-on-qemu/ # on 22 July 2020. @@ -22,6 +22,9 @@ set -o errexit set -o nounset +# Supported OpenBSD release. +RELEASE="7.8" + # Trusted HTTPS OpenBSD mirror to fetch the base public key from. # See <https://www.openbsd.org/ftp.html#http>. HTTPS_MIRROR="${HTTPS_MIRROR-https://ftp.openbsd.org/pub/OpenBSD/}" @@ -45,6 +48,13 @@ MEMORY_SIZE="${MEMORY_SIZE-4G}" # File name of the public SSH key to authorize. SSH_KEY="${SSH_KEY-${HOME}/.ssh/id_ed25519.pub}" +# Check OpenBSD release. +dotless_release="$( echo "$RELEASE" | sed -n 's/^\([0-9]\)\.\([0-9]\)$/\1\2/p' )" +if [ -z "$dotless_release" ] ; then + ( >&2 printf 'failed to parse RELEASE\n' ) + exit 2 +fi + # Check required commands. for cmd in curl qemu-img qemu-system-x86_64 rsync signify socat ssh do @@ -56,46 +66,46 @@ do done # Fetch base public key from trusted HTTPS mirror. -mkdir -p mirror/pub/OpenBSD/7.8 -if [ ! -e mirror/pub/OpenBSD/7.8/openbsd-78-base.pub ] +mkdir -p "mirror/pub/OpenBSD/${RELEASE}" +if [ ! -e "mirror/pub/OpenBSD/${RELEASE}/openbsd-${dotless_release}-base.pub" ] then curl \ --silent \ - --output mirror/pub/OpenBSD/7.8/openbsd-78-base.pub \ - "${HTTPS_MIRROR}7.8/openbsd-78-base.pub" + --output "mirror/pub/OpenBSD/${RELEASE}/openbsd-${dotless_release}-base.pub" \ + "${HTTPS_MIRROR}${RELEASE}/openbsd-${dotless_release}-base.pub" printf "Fetched base public key from %s\\n" "${HTTPS_MIRROR}" fi # Fetch kernel, PXE bootstrap program, and file sets from untrusted rsync # mirror. -if [ ! -d mirror/pub/OpenBSD/7.8/amd64 ] +if [ ! -d "mirror/pub/OpenBSD/${RELEASE}/amd64" ] then mkdir -p tmp printf "Fetching installation files ...\\n" rsync --archive --files-from=- --quiet \ - "${RSYNC_MIRROR}7.8/amd64/" \ + "${RSYNC_MIRROR}${RELEASE}/amd64/" \ tmp/ \ << EOF SHA256.sig -base78.tgz +base${dotless_release}.tgz bsd bsd.mp bsd.rd -comp78.tgz -game78.tgz -man78.tgz +comp${dotless_release}.tgz +game${dotless_release}.tgz +man${dotless_release}.tgz pxeboot -xbase78.tgz -xfont78.tgz -xserv78.tgz -xshare78.tgz +xbase${dotless_release}.tgz +xfont${dotless_release}.tgz +xserv${dotless_release}.tgz +xshare${dotless_release}.tgz BUILDINFO EOF ( cd tmp && signify -C -q \ - -p ../mirror/pub/OpenBSD/7.8/openbsd-78-base.pub \ + -p "../mirror/pub/OpenBSD/${RELEASE}/openbsd-${dotless_release}-base.pub" \ -x SHA256.sig \ - -- bsd bsd.* pxeboot *78.tgz ) - mv tmp mirror/pub/OpenBSD/7.8/amd64 + -- bsd bsd.* pxeboot *"${dotless_release}.tgz" ) + mv tmp "mirror/pub/OpenBSD/${RELEASE}/amd64" printf "Fetched kernel, PXE bootstrap program, and file sets from %s\\n" "${RSYNC_MIRROR}" fi @@ -116,9 +126,9 @@ Location of sets = http HTTP Server = 10.0.2.2 Unable to connect using https. Use http instead = yes URL to autopartitioning template for disklabel = http://10.0.2.2/disklabel -Set name(s) = site78.tgz -Checksum test for site78.tgz failed. Continue anyway = yes -Unverified sets: site78.tgz. Continue without verification = yes +Set name(s) = site${dotless_release}.tgz +Checksum test for site${dotless_release}.tgz failed. Continue anyway = yes +Unverified sets: site${dotless_release}.tgz. Continue without verification = yes EOF printf "Created example response file for autoinstall(8) at ./mirror/install.conf\\n" fi @@ -171,19 +181,19 @@ fi # Package site-specific file set if not exists or changed. site_dir_changed="$( find site -exec stat -c %Y {} \; | sort -r | head -n 1 )" -if [ ! -e mirror/pub/OpenBSD/7.8/amd64/site78.tgz ] || [ "$( stat -c %Y mirror/pub/OpenBSD/7.8/amd64/site78.tgz )" -lt "${site_dir_changed}" ] +if [ ! -e "mirror/pub/OpenBSD/${RELEASE}/amd64/site${dotless_release}.tgz" ] || [ "$( stat -c %Y "mirror/pub/OpenBSD/${RELEASE}/amd64/site${dotless_release}.tgz" )" -lt "${site_dir_changed}" ] then - rm -f mirror/pub/OpenBSD/7.8/amd64/site78.tgz - ( cd site && tar -czf ../mirror/pub/OpenBSD/7.8/amd64/site78.tgz . ) - ( cd mirror/pub/OpenBSD/7.8/amd64 && ls -l > index.txt ) + rm -f "mirror/pub/OpenBSD/${RELEASE}/amd64/site${dotless_release}.tgz" + ( cd site && tar -czf "../mirror/pub/OpenBSD/${RELEASE}/amd64/site${dotless_release}.tgz" . ) + ( cd "mirror/pub/OpenBSD/${RELEASE}/amd64" && ls -l > index.txt ) fi # Create TFTP directory if not exists. if [ ! -d tftp ] then mkdir tftp - ln -s ../mirror/pub/OpenBSD/7.8/amd64/pxeboot tftp/auto_install - ln -s ../mirror/pub/OpenBSD/7.8/amd64/bsd.rd tftp/bsd.rd + ln -s "../mirror/pub/OpenBSD/${RELEASE}/amd64/pxeboot" tftp/auto_install + ln -s "../mirror/pub/OpenBSD/${RELEASE}/amd64/bsd.rd" tftp/bsd.rd mkdir tftp/etc cat << EOF > tftp/etc/boot.conf stty com0 115200 @@ -197,7 +207,7 @@ fi if [ -e "${DISK_FILE}" ] then vm_created="$( stat -c %W "${DISK_FILE}" )" - for f in mirror/install.conf mirror/disklabel mirror/pub/OpenBSD/7.8/amd64/site78.tgz tftp/etc/boot.conf + for f in mirror/install.conf mirror/disklabel "mirror/pub/OpenBSD/${RELEASE}/amd64/site${dotless_release}.tgz" tftp/etc/boot.conf do if [ "${vm_created}" -lt "$( stat -c %Y "$f" )" ] then |