-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvirt-check.func
executable file
·29 lines (29 loc) · 1.07 KB
/
virt-check.func
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
#!/bin/bash
#
# Virtual Function
# Detect if a server is virtual or not, without root access
#
# 1. check for "virtual" in /var/log/dmesg
# 2. check for "virtual" in /proc/scsi/scsi
#
virt () {
if [ -e /var/log/dmesg ] && [ -r /var/log/dmesg ]; then
DMESG="$(grep -i dmi /var/log/dmesg | grep -i virtual)"
if [ -n "$DMESG" ]; then
if [ -e /proc/scsi/scsi ] && [ -r /proc/scsi/scsi ]; then
SCSI="$(grep -i virtual /proc/scsi/scsi)"
if [ -n "$SCSI" ]; then
echo "Virtual"
else
echo "Not Virtual"
fi
else
echo "Not Virtual"
fi
else
echo "/proc/scsi/scsi is not accessible (permission denied)"
fi
else
echo "/var/log/dmesg is not accessible (permission denied)"
fi
}