mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-28 11:43:25 +02:00
cloud-init: Add function to detect if we are running on Azure
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
@@ -28,6 +28,22 @@ running_on_ec2() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
running_on_azure() {
|
||||||
|
# Check if the vendor is Microsoft
|
||||||
|
if [ -r "/sys/devices/virtual/dmi/id/sys_vendor" ] && \
|
||||||
|
[ "$(</sys/devices/virtual/dmi/id/sys_vendor)" = "Microsoft Corporation" ]; then
|
||||||
|
# Check if this product is a "Virtual Machine"
|
||||||
|
if [ -r "/sys/devices/virtual/dmi/id/product_name" ] && \
|
||||||
|
[ "$(</sys/devices/virtual/dmi/id/product_name)" = "Virtual Machine" ]; then
|
||||||
|
# Yes, we are running on Azure
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# We are not running on Azure
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
start)
|
start)
|
||||||
# Do nothing if we are not running on AWS EC2
|
# Do nothing if we are not running on AWS EC2
|
||||||
@@ -68,11 +84,19 @@ case "${1}" in
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
status)
|
status)
|
||||||
|
# Check Amazon
|
||||||
if running_on_ec2; then
|
if running_on_ec2; then
|
||||||
echo "This system is running on AWS EC2"
|
echo "This system is running on AWS EC2"
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
# Check Microsoft
|
||||||
|
elif running_on_azure; then
|
||||||
|
echo "This system is running on Microsoft Azure"
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
# The rest
|
||||||
else
|
else
|
||||||
echo "This system is NOT running on AWS EC2"
|
echo "This system is NOT running in the cloud"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|||||||
Reference in New Issue
Block a user