You've already forked debian-unattended
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user