From 3273ff48f04fe01364eb413966d7afb351a9cb41 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 27 Jun 2018 10:05:55 +0100 Subject: [PATCH] aws: Write HOSTNAME and DOMAINNAME when not set Previously we expected the entire settings file to be empty but since we are now shipping some defaults for other settings. Signed-off-by: Michael Tremer --- src/initscripts/helper/aws-setup | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/initscripts/helper/aws-setup b/src/initscripts/helper/aws-setup index 8097ad9ef7..db9e1846e7 100644 --- a/src/initscripts/helper/aws-setup +++ b/src/initscripts/helper/aws-setup @@ -53,13 +53,16 @@ import_aws_configuration() { boot_mesg "Importing AWS configuration for instance ${instance_id}..." # Initialise system settings - if [ ! -s "/var/ipfire/main/settings" ]; then - local hostname=$(get local-hostname) + local hostname=$(get local-hostname) - ( - echo "HOSTNAME=${hostname%%.*}" - echo "DOMAINNAME=${hostname#*.}" - ) > /var/ipfire/main/settings + # Set hostname + if ! grep -q "^HOSTNAME=" /var/ipfire/main/settings; then + echo "HOSTNAME=${hostname%%.*}" >> /var/ipfire/main/settings + fi + + # Set domainname + if ! grep -q "^DOMAINNAME=" /var/ipfire/main/settings; then + echo "DOMAINNAME=${hostname#*.}" >> /var/ipfire/main/settings fi # Import any DNS server settings @@ -71,6 +74,7 @@ import_aws_configuration() { echo "CONFIG_TYPE=1" ) > /var/ipfire/ethernet/settings + local mac for mac in $(get network/interfaces/macs/); do # Remove trailing slash mac="${mac//\//}" -- 2.39.2