From: Michael Tremer Date: Wed, 27 Jun 2018 09:05:55 +0000 (+0100) Subject: aws: Write HOSTNAME and DOMAINNAME when not set X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3273ff48f04fe01364eb413966d7afb351a9cb41;p=people%2Fmfischer%2Fipfire-2.x.git 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 --- 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//\//}"