From 8defa50e7395714930dd3a813ad4c509711c0b57 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Mon, 13 Aug 2018 12:14:49 +0100 Subject: [PATCH] aws: Execute user-data script while we have networking up Signed-off-by: Michael Tremer --- src/initscripts/helper/aws-setup | 25 +++++++++++++++++-------- src/initscripts/system/aws | 8 -------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/initscripts/helper/aws-setup b/src/initscripts/helper/aws-setup index 122e5a31dd..955583c029 100644 --- a/src/initscripts/helper/aws-setup +++ b/src/initscripts/helper/aws-setup @@ -109,8 +109,23 @@ import_aws_configuration() { fi done - # Download user-data - local user_data="$(get user-data)" + # Download the user-data script only on the first boot + if [ ! -e "/var/ipfire/main/firstsetup_ok" ]; then + # Download user-data + local user_data="$(get user-data)" + + # Save user-data script to be executed later + if [ "${user_data:0:2}" = "#!" ]; then + echo "${user_data}" > /tmp/aws-user-data.script + chmod 700 /tmp/aws-user-data.script + + # Run the user-data script + /tmp/aws-user-data.script + + # Delete the script right away + rm /tmp/aws-user-data.script + fi + fi # Import any DNS server settings eval $(/usr/local/bin/readhash <(grep -E "^DNS([0-9])=" /var/ipfire/ethernet/settings 2>/dev/null)) @@ -252,12 +267,6 @@ import_aws_configuration() { # This script has now completed the first steps of setup touch /var/ipfire/main/firstsetup_ok - - # Save user-data script to be executed later - if [ "${user_data:0:2}" = "#!" ]; then - echo "${user_data}" > /tmp/aws-user-data.script - chmod 700 /tmp/aws-user-data.script - fi fi # All done diff --git a/src/initscripts/system/aws b/src/initscripts/system/aws index 896b3b17a1..6fce670a03 100644 --- a/src/initscripts/system/aws +++ b/src/initscripts/system/aws @@ -60,14 +60,6 @@ case "${1}" in # End DHCP client immediately dhclient -sf /etc/rc.d/helper/aws-setup -r "${intf}" &>/dev/null - # Run AWS user-data script - if [ -x "/tmp/aws-user-data.script" ]; then - /tmp/aws-user-data.script - - # Delete the script right away - rm /tmp/aws-user-data.script - fi - exit 0 ;; -- 2.39.5