Skip to content

Instantly share code, notes, and snippets.

@pfandl
Last active June 23, 2021 00:20
Show Gist options
  • Save pfandl/1dddb99d8f5637ad933ac32c9073d32e to your computer and use it in GitHub Desktop.
Save pfandl/1dddb99d8f5637ad933ac32c9073d32e to your computer and use it in GitHub Desktop.
Create OPNsense ISO with custom config.xml on linux for installation.
#!/usr/bin/env bash
# ------------------
# IT DOES NOT WORK, cannot create a sane ISO with mkisofs
# ------------------
config="${1:?please pass the config file path as argument}"
keymap="${2:-NO}" # keymap in /usr/share/{syscons,vt}/keymaps/* (or NO).
set -euo pipefail
set -x
version=21.1
url=https://mirror.dns-root.de/opnsense/releases/$version/OPNsense-$version-OpenSSL-dvd-amd64.iso.bz2
if [ ! -f opnsense.iso.bz2 ]; then
curl -L $url -o opnsense.iso.bz2
fi
if [ ! -f opnsense.iso ]; then
bzip2 -d -k opnsense.iso.bz2
fi
sudo mkdir -p /mnt/opnsense
if [ ! $(lsblk | grep /mnt/opnsense) ]; then
sudo mount -t iso9660 -o loop opnsense.iso /mnt/opnsense
fi
mkdir -p opnsense
sudo rsync -a /mnt/opnsense/ opnsense/
sudo cp "$config" opnsense/usr/local/etc/config.xml
xmllint --noout opnsense/usr/local/etc/config.xml
sudo sed -i 's/keymap=".*"/keymap="'$keymap'"/' opnsense/etc/defaults/rc.conf
sudo mkisofs -D -R -b boot/cdboot \
-allow-leading-dots -no-emul-boot \
-V OPNSENSE_INSTALL -o rockridge \
-o opnsense_patched.iso opnsense
sudo umount /mnt/opnsense
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment