From efc152b6a64241fde0da554ac408e35e789ada3e Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Fri, 1 Sep 2023 15:41:58 -0400 Subject: [PATCH] Ensure defaults are always set --- templates/host-preseed.j2 | 10 ++++++++++ templates/install.sh | 17 ++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/templates/host-preseed.j2 b/templates/host-preseed.j2 index 9dca9a4..3fd66e2 100644 --- a/templates/host-preseed.j2 +++ b/templates/host-preseed.j2 @@ -11,13 +11,17 @@ ### General definitions/overrides ### +{% if debrelease is defined and debrelease %} # The Debian release to use (overrides the default) #debrelease="buster" debrelease="{debrelease}" +{% endif %} +{% if debmirror is defined and debmirror %} # The Debian mirror to use (overrides the default) #debmirror="http://debian.mirror.rafal.ca/debian" debmirror="{debmirror}" +{% endif %} {% if addpkglist is defined and addpkglist %} # Additional packages (comma-separated) to install in the base system @@ -25,6 +29,12 @@ debmirror="{debmirror}" addpkglist="{addpkglist}" {% endif %} +{% if filesystem is defined and filesystem %} +# Alternate filesystem for system volumes (/, /var/lib/ceph, /var/lib/zookeeper) +#filesystem=ext4 +filesystem="{filesystem}" +{% endif %} + {% if skip_blockcheck is defined and skip_blockcheck %} # Skip block zeroing; only recommended for testing, slow, low-endurance, or known-zeroed block devices. skip_blockcheck="y" diff --git a/templates/install.sh b/templates/install.sh index ef80190..cf477e3 100755 --- a/templates/install.sh +++ b/templates/install.sh @@ -133,9 +133,24 @@ seed_config() { # Fetch the seed config tftp -m binary "${seed_host}" -c get "${seed_file}" /tmp/install.seed + # Load the variables from the seed config . /tmp/install.seed || exit 1 - if [[ -n "${addpkglist}" ]]; then + # Ensure optional configurations are set to defaults if unset + if [[ -z ${filesystem} ]]; then + filesystem="${default_filesystem}" + fi + + if [[ -z ${debrelease} ]]; then + debrelease="${default_debrelease}" + fi + + if [[ -z ${debmirror} ]]; then + debmirror="${default_debmirror}" + fi + + # Append the addpkglist to the suppkglist if present + if [[ -n ${addpkglist} ]]; then suppkglist="${suppkglist},${addpkglist}" fi