mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-26 02:42:58 +02:00
cloud-init: Launch custom script when detecting Google Cloud
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user