[1/3] oci: Add detection for Oracle Cloud

Message ID 20200721103641.30305-1-michael.tremer@ipfire.org
State New
Headers show
Series
  • [1/3] oci: Add detection for Oracle Cloud
Related show

Commit Message

Michael Tremer July 21, 2020, 10:36 a.m. UTC
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
 src/initscripts/system/cloud-init |  2 ++
 src/initscripts/system/functions  | 11 +++++++++++
 2 files changed, 13 insertions(+)

Patch

diff --git a/src/initscripts/system/cloud-init b/src/initscripts/system/cloud-init
index 284e24d7b..d39552b01 100644
--- a/src/initscripts/system/cloud-init
+++ b/src/initscripts/system/cloud-init
@@ -15,6 +15,8 @@  case "${1}" in
 			scriptname="/etc/rc.d/helper/azure-setup"
 		elif running_on_gcp; then
 			scriptname="/etc/rc.d/helper/gcp-setup"
+		elif running_on_oci; then
+			scriptname="/etc/rc.d/helper/oci-setup"
 		else
 			# This system is not running in the cloud
 			exit 0
diff --git a/src/initscripts/system/functions b/src/initscripts/system/functions
index b6e6507d6..30119918c 100644
--- a/src/initscripts/system/functions
+++ b/src/initscripts/system/functions
@@ -834,4 +834,15 @@  running_on_gcp() {
 	return 1
 }
 
+running_on_oci() {
+	if [ -r "/sys/devices/virtual/dmi/id/chassis_asset_tag" ]; then
+		local asset_tag="$(</sys/devices/virtual/dmi/id/chassis_asset_tag)"
+
+		[ "${asset_tag}" = "OracleCloud.com" ] && return 0
+	fi
+
+	# We are not running on OCI
+	return 1
+}
+
 # End $rc_base/init.d/functions