]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
cloud-init: Move detection functions into initscript function library
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 15 Jun 2019 10:22:28 +0000 (11:22 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 1 Jul 2019 06:53:58 +0000 (07:53 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/initscripts/system/cloud-init
src/initscripts/system/functions

index f385ce5d19916e5e606cd319644f4f9147b99988..79a762b2d1089012514ed2bc9055a8a831450a42 100644 (file)
@@ -6,44 +6,6 @@
 . /etc/sysconfig/rc
 . ${rc_functions}
 
-# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/identify_ec2_instances.html
-running_on_ec2() {
-       local uuid
-
-       # Check if the hypervisor UUID starts with ec2
-       if [ -r "/sys/hypervisor/uuid" ]; then
-               uuid=$(</sys/hypervisor/uuid)
-
-               [ "${uuid:0:3}" = "ec2" ] && return 0
-       fi
-
-       # Check if the DMI product UUID starts with EC2
-       if [ -r "/sys/devices/virtual/dmi/id/product_uuid" ]; then
-               uuid=$(</sys/devices/virtual/dmi/id/product_uuid)
-
-               [ "${uuid:0:3}" = "EC2" ] && return 0
-       fi
-
-       # We are not running on AWS EC2
-       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
        start)
                # Check if we are running in the cloud
index c00f65922c97450e74aae3cc3f0c28f9c36f2251..2870729a50a3fb4a6162ff0270876d1bced60abb 100644 (file)
@@ -784,4 +784,42 @@ umount_ramdisk() {
        rm -rf "${path_tmpfs}"
 }
 
+# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/identify_ec2_instances.html
+running_on_ec2() {
+       local uuid
+
+       # Check if the hypervisor UUID starts with ec2
+       if [ -r "/sys/hypervisor/uuid" ]; then
+               uuid=$(</sys/hypervisor/uuid)
+
+               [ "${uuid:0:3}" = "ec2" ] && return 0
+       fi
+
+       # Check if the DMI product UUID starts with EC2
+       if [ -r "/sys/devices/virtual/dmi/id/product_uuid" ]; then
+               uuid=$(</sys/devices/virtual/dmi/id/product_uuid)
+
+               [ "${uuid:0:3}" = "EC2" ] && return 0
+       fi
+
+       # We are not running on AWS EC2
+       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
+}
+
 # End $rc_base/init.d/functions