Make domain configurable with default and interactive prompt

- Replace hardcoded domain in template.cfg with DOMAIN_NAME placeholder
- Add DEFAULT_DOMAIN constant and prompt in unattended.sh
- Support DOMAIN_NAME env var with fallback to default/interactive input
- Apply DOMAIN_NAME substitution to preseed.cfg
This commit is contained in:
2026-08-20 10:16:02 +02:00
parent 7ddaa79589
commit f8cbeaf20e
2 changed files with 14 additions and 3 deletions

View File

@@ -67,7 +67,7 @@ d-i netcfg/dhcpv6_timeout string 1
# values set here. However, setting the values still prevents the questions
# from being shown, even if values come from dhcp.
d-i netcfg/get_hostname string debian
d-i netcfg/get_domain string home.bjphoster.cloud
d-i netcfg/get_domain string DOMAIN_NAME
# If you want to force a hostname, regardless of what either the DHCP
# server returns or what the reverse DNS entry for the IP is, uncomment

View File

@@ -1,11 +1,22 @@
#!/usr/bin/env bash
# Get password from user prompt and set it in preseed
DEFAULT_ROOT_PASSWORD='IamGr00t!'
DEFAULT_DOMAIN="home.bjphoster.cloud"
# Get password from user prompt (empty input keeps the default) and set it in preseed
if [ -z "$ROOT_PASSWORD" ]; then
read -sp "Enter the root password: " ROOT_PASSWORD
read -sp "Enter the root password [${DEFAULT_ROOT_PASSWORD}]: " ROOT_PASSWORD
echo
fi
ROOT_PASSWORD="${ROOT_PASSWORD:-${DEFAULT_ROOT_PASSWORD}}"
# Get the domain from user prompt (empty input keeps the default) and set it in preseed
if [ -z "$DOMAIN_NAME" ]; then
read -p "Enter the domain [${DEFAULT_DOMAIN}]: " DOMAIN_NAME
fi
DOMAIN_NAME="${DOMAIN_NAME:-${DEFAULT_DOMAIN}}"
cp -f template.cfg preseed.cfg
sed -i "s/ROOT_PASSWORD/${ROOT_PASSWORD}/" preseed.cfg
sed -i "s/DOMAIN_NAME/${DOMAIN_NAME}/" preseed.cfg
# Get the file name
ISONAME=$(ls | grep "netinst.iso" | sort | tail -n1)