aboutsummaryrefslogtreecommitdiffstats
path: root/testing/apt-dater-host/try-to-use-virt-what.patch
blob: 96aa1de5c30a911eae044d75fc78165692b2f198 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
From 7e48746242b55da3fb215d74f0eb69ea0afddc81 Mon Sep 17 00:00:00 2001
From: Henrik Riomar <henrik.riomar@gmail.com>
Date: Thu, 16 Feb 2017 23:22:09 +0100
Subject: [PATCH] apk; try to use virt-what

If searching dmesg for Hypervisor info fails, try
virt-what detection (if installed).

While at it fix the sudoers file

Upstream-Issue: https://github.com/DE-IBH/apt-dater-host/pull/17
---
 apk/apt-dater-host         | 9 ++++++++-
 apk/apt-dater-host-sudoers | 2 +-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/apk/apt-dater-host b/apk/apt-dater-host
index a5862ae..2164dea 100755
--- a/apk/apt-dater-host
+++ b/apk/apt-dater-host
@@ -31,6 +31,7 @@
 ADP_VERSION="0.6"
 ROOT_CMD="sudo"
 APK_CMD="/sbin/apk"
+VIRT_WHAT_CMD="/usr/sbin/virt-what --test-root=/"
 
 err=255 # exit code returned by Perl from die()
 
@@ -97,7 +98,13 @@ get_virt()
 	if [ -n "$virt" ]; then
 		echo "VIRT: $virt"
 	else
-		echo "VIRT: Unknown"
+		virt=$($VIRT_WHAT_CMD 2> /dev/null)
+		ret=$?
+		if [ -z "$virt" ]; then
+			[ $ret -eq 0 ] && echo "VIRT: Physical" || echo "VIRT: Unknown"
+		else
+			echo "VIRT: $(echo $virt | awk '{print $1}')"
+		fi
 	fi
 }
 
diff --git a/apk/apt-dater-host-sudoers b/apk/apt-dater-host-sudoers
index 6fc868c..ba3dd3d 100644
--- a/apk/apt-dater-host-sudoers
+++ b/apk/apt-dater-host-sudoers
@@ -6,4 +6,4 @@
 #Defaults	env_keep += http_proxy
 
 # Allow members of group adm to execute the apk command
-%adm		ALL=NOPASSWD: /sbin/apk
+#%adm		ALL=NOPASSWD: /sbin/apk
-- 
2.11.1