]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
aws: Write HOSTNAME and DOMAINNAME when not set
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 27 Jun 2018 09:05:55 +0000 (10:05 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 27 Jun 2018 09:05:55 +0000 (10:05 +0100)
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 <michael.tremer@ipfire.org>
src/initscripts/helper/aws-setup

index 8097ad9ef7327b5895d4100c809f1072e5fcda9f..db9e1846e71814ddb4c5a2e3eba1f9bbb621e55e 100644 (file)
@@ -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//\//}"