]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
cloud-init: Launch custom script when detecting Google Cloud
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 28 Aug 2019 11:51:22 +0000 (11:51 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 19 Jun 2020 17:14:58 +0000 (17:14 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/initscripts/system/cloud-init
src/initscripts/system/functions

index 79a762b2d1089012514ed2bc9055a8a831450a42..284e24d7b9fb4ac93ed95417fa51934faad6306c 100644 (file)
@@ -13,6 +13,8 @@ case "${1}" in
                        scriptname="/etc/rc.d/helper/aws-setup"
                elif running_on_azure; then
                        scriptname="/etc/rc.d/helper/azure-setup"
+               elif running_on_gcp; then
+                       scriptname="/etc/rc.d/helper/gcp-setup"
                else
                        # This system is not running in the cloud
                        exit 0
@@ -63,6 +65,11 @@ case "${1}" in
                        echo "This system is running on Microsoft Azure"
                        exit 0
 
+               # Check Google
+               elif running_on_gcp; then
+                       echo "This system is running on Google Cloud"
+                       exit 0
+
                # The rest
                else
                        echo "This system is NOT running in the cloud"
index 2127a58995d576a33dd930b34ed595182f1a0d56..b6e6507d6067dd2c87da54bb7cc38a082b0af0d4 100644 (file)
@@ -822,4 +822,16 @@ running_on_azure() {
        return 1
 }
 
+running_on_gcp() {
+       # Check if the BIOS vendor is "Google"
+       if [ -r "/sys/devices/virtual/dmi/id/bios_vendor" ]; then
+               local bios_vendor="$(</sys/devices/virtual/dmi/id/bios_vendor)"
+
+               [ "${bios_vendor}" = "Google" ] && return 0
+       fi
+
+       # We are not running on GCP
+       return 1
+}
+
 # End $rc_base/init.d/functions