aboutsummaryrefslogtreecommitdiffstats
path: root/build-openbsd-image.sh
diff options
context:
space:
mode:
Diffstat (limited to 'build-openbsd-image.sh')
-rwxr-xr-xbuild-openbsd-image.sh58
1 files changed, 58 insertions, 0 deletions
diff --git a/build-openbsd-image.sh b/build-openbsd-image.sh
new file mode 100755
index 0000000..b31ebfa
--- /dev/null
+++ b/build-openbsd-image.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+#
+# DESCRIPTION:
+# Create an OpenBSD image with Packer and QEMU.
+#
+# USAGE:
+# ./build-openbsd-image.sh
+set -o nounset
+set -o errexit
+
+VERSION=7.9
+ARCH=amd64
+DISK_SIZE_GB=36
+PUBLIC_SSH_KEY="$HOME/.ssh/id_rsa.pub"
+
+export PACKER_LOG=1
+
+main() (
+ parse_args "$@"
+ cd openbsd-image/
+ packer init .
+ packer build \
+ -only "qemu.openbsd-$ARCH" \
+ -var "arch=$ARCH" \
+ -var "disk_size=$DISK_SIZE_GB" \
+ -var "version=$VERSION" \
+ -var "ssh_key=$(cat "$PUBLIC_SSH_KEY")" \
+ .
+)
+
+parse_args() {
+ while [ $# -gt 0 ]; do
+ case "$1" in
+ --version)
+ VERSION="$2"
+ shift 2
+ ;;
+ --arch)
+ ARCH="$2"
+ shift 2
+ ;;
+ --disk-size-gb)
+ DISK_SIZE_GB="$2"
+ shift 2
+ ;;
+ --public-ssh-key)
+ PUBLIC_SSH_KEY="$2"
+ shift 2
+ ;;
+ *)
+ echo "Unknown option: $1"
+ shift
+ ;;
+ esac
+ done
+}
+
+main "$@"