Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/distrib/amd64/liveimage/emuimage Look for the string "amazon...



details:   https://anonhg.NetBSD.org/src/rev/87c3ebaeb7a2
branches:  trunk
changeset: 975958:87c3ebaeb7a2
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Wed Sep 09 13:25:48 2020 +0000

description:
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.

diffstat:

 distrib/amd64/liveimage/emuimage/ec2_init |  27 +++++++++++++++++----------
 1 files changed, 17 insertions(+), 10 deletions(-)

diffs (36 lines):

diff -r 88388aae93c3 -r 87c3ebaeb7a2 distrib/amd64/liveimage/emuimage/ec2_init
--- a/distrib/amd64/liveimage/emuimage/ec2_init Wed Sep 09 12:06:02 2020 +0000
+++ b/distrib/amd64/liveimage/emuimage/ec2_init Wed Sep 09 13:25:48 2020 +0000
@@ -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)



Home | Main Index | Thread Index | Old Index