From e3afd33ec2f97c4682191ec2584bba900b8bf436 Mon Sep 17 00:00:00 2001 From: jmcneill Date: Wed, 9 Sep 2020 13:25:48 +0000 Subject: [PATCH] Look for the string "amazon" in a few different sysctl nodes. There doesn't seem to be a single spot to check that works with both XenPVHVM and KVM instances. --- distrib/amd64/liveimage/emuimage/ec2_init | 27 ++++++++++++++--------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/distrib/amd64/liveimage/emuimage/ec2_init b/distrib/amd64/liveimage/emuimage/ec2_init index 69f458629b21..53a9e7035f8d 100644 --- a/distrib/amd64/liveimage/emuimage/ec2_init +++ b/distrib/amd64/liveimage/emuimage/ec2_init @@ -1,15 +1,22 @@ -# $NetBSD: ec2_init,v 1.1 2020/08/05 01:35:18 jmcneill Exp $ +# $NetBSD: ec2_init,v 1.2 2020/09/09 13:25:48 jmcneill Exp $ is_ec2() { - dmi_vendor="$(/sbin/sysctl -qn machdep.dmi.system-vendor | tr '[A-Z]' '[a-z]')" - case "$dmi_vendor" in - amazon*) - printf YES - ;; - *) - printf NO - ;; - esac + val=NO + # Look for the string "amazon" in one of these sysctl nodes + for node in machdep.dmi.system-vendor \ + machdep.dmi.system-version \ + machdep.dmi.bios-version \ + machdep.xen.version ; do + if /sbin/sysctl -q $node; then + nodeval="$(/sbin/sysctl -n $node | tr '[A-Z]' '[a-z]')" + case "$nodeval" in + *amazon*) + val=YES + ;; + esac + fi + done + printf $val } ec2_init=$(is_ec2)