cloud-init: Launch custom script when detecting Google Cloud

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
Michael Tremer
2019-08-28 11:51:22 +00:00
parent 46bccfc219
commit 86c6459873
2 changed files with 19 additions and 0 deletions

View 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"

View 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