]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - src/initscripts/helper/gcp-setup
cloud: Execute user-data scripts at the end of initialization
[ipfire-2.x.git] / src / initscripts / helper / gcp-setup
index 9351949317e49267d1dba058dfc93733098ab72d..4f5148c3e2447a5772b04e2d2dee0bef13a6ebc3 100644 (file)
@@ -118,25 +118,6 @@ import_gcp_configuration() {
                fi
        done <<<"$(get instance/attributes/ssh-keys)"
 
-       # Download the user-data script only on the first boot
-       if [ ! -e "/var/ipfire/main/firstsetup_ok" ]; then
-               # Download a startup script
-               local script="$(get instance/attributes/startup-script)"
-
-               # Execute the script
-               if [ "${script:0:2}" = "#!" ]; then
-                       echo "${script}" > /tmp/gcp-startup.script
-                       chmod 700 /tmp/gcp-startup.script
-
-                       # Run the script
-                       local now="$(date -u +"%s")"
-                       /tmp/gcp-startup.script &>/var/log/startup-script.log.${now}
-
-                       # Delete the script right away
-                       rm /tmp/gcp-startup.script
-               fi
-       fi
-
        # Import network configuration
        # After this, no network connectivity will be available from this script due to the
        # renaming of the network interfaces for which they have to be shut down
@@ -249,6 +230,22 @@ import_gcp_configuration() {
                        echo "2,ACCEPT,INPUTFW,ON,std_net_src,ALL,ipfire,RED1,,TCP,,,ON,,,TGT_PORT,444,,,,,,,,,,,00:00,00:00,,AUTO,,dnat,,,,,second"
                ) >> /var/ipfire/firewall/input
 
+               # Download a startup script
+               local script="$(get instance/attributes/startup-script)"
+
+               # Execute the script
+               if [ "${script:0:2}" = "#!" ]; then
+                       echo "${script}" > /tmp/gcp-startup.script
+                       chmod 700 /tmp/gcp-startup.script
+
+                       # Run the script
+                       local now="$(date -u +"%s")"
+                       /tmp/gcp-startup.script &>/var/log/startup-script.log.${now}
+
+                       # Delete the script right away
+                       rm /tmp/gcp-startup.script
+               fi
+
                # This script has now completed the first steps of setup
                touch /var/ipfire/main/firstsetup_ok
        fi