azure: Abort script when no instance ID can be retrieved

Message ID 20200120172312.16275-1-michael.tremer@ipfire.org
State Accepted
Commit 26eab1fe3e5ed74013420e077a112a012eeab4f6
Headers
Series azure: Abort script when no instance ID can be retrieved |

Commit Message

Michael Tremer Jan. 20, 2020, 5:23 p.m. UTC
  We cannot reliably determine if a system is running on Hyper-V
on a private server or on the Azure Cloud.

Therefore, we will have to try to retrieve an IP address
with DHCP and try to connect to the metadata service. If either
of those things is not successful, we will just continue with
the setup process as usual.

So cloud instances should be automatically configured now and
all other systems will continue to boot and call the setup
wizard as usual.

Fixes: #12272
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
 src/initscripts/helper/azure-setup | 3 +++
 1 file changed, 3 insertions(+)
  

Patch

diff --git a/src/initscripts/helper/azure-setup b/src/initscripts/helper/azure-setup
index d497c43b2..d84ec3aca 100644
--- a/src/initscripts/helper/azure-setup
+++ b/src/initscripts/helper/azure-setup
@@ -58,6 +58,9 @@  prefix2netmask() {
 
 import_azure_configuration() {
 	local instance_id="$(get compute/vmId)"
+	if [ -z "${instance_id}" ]; then
+		return 0
+	fi
 
 	boot_mesg "Importing Microsoft Azure configuration for instance ${instance_id}..."