Module Name: src Committed By: jmcneill Date: Wed Sep 9 13:25:48 UTC 2020
Modified Files: src/distrib/amd64/liveimage/emuimage: ec2_init Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/distrib/amd64/liveimage/emuimage/ec2_init Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/amd64/liveimage/emuimage/ec2_init diff -u src/distrib/amd64/liveimage/emuimage/ec2_init:1.1 src/distrib/amd64/liveimage/emuimage/ec2_init:1.2 --- src/distrib/amd64/liveimage/emuimage/ec2_init:1.1 Wed Aug 5 01:35:18 2020 +++ src/distrib/amd64/liveimage/emuimage/ec2_init Wed Sep 9 13:25:48 2020 @@ -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)