-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwhichBoot
executable file
·97 lines (73 loc) · 2.36 KB
/
whichBoot
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env python3
#
# whichBoot: Is it UEFI or BIOS?
#
import sys
import os
import argparse
import subprocess
from alogging import ALogger
lg = ALogger()
__metadata__ = {
"title" : "whichBoot.py",
"rightsHolder" : "Steven J. DeRose",
"creator" : "http://viaf.org/viaf/50334488",
"type" : "http://purl.org/dc/dcmitype/Software",
"language" : "Python 3.7",
"created" : "2014-08-09",
"modified" : "2020-03-04",
"publisher" : "http://github.com/sderose",
"license" : "https://creativecommons.org/licenses/by-sa/3.0/"
}
__version__ = __metadata__['modified']
descr = """
=head1 Usage
whichBoot: Report whether the machine was booted via UEFI or BIOS.
See: L<http://askubuntu.com/questions/162564>.
=History=
* 2014-08-09: Written by Steven J. DeRose.
* 2020-03-04: Layout, lint.
=Rights=
Copyright 2020-03-04 by Steven J. DeRose. This work is licensed under a
Creative Commons Attribution-Share-alike 3.0 unported license.
See [http://creativecommons.org/licenses/by-sa/3.0/ for more information].
For the most recent version, see L<http://www.derose.net/steve/utilities/>
or L<http://github.com/sderose>.
=Options=
"""
###############################################################################
# Process options
#
parser = argparse.ArgumentParser(
description=descr
)
parser.add_argument(
"-q", action='store_true', dest='quiet',
help='Suppress most messages.')
parser.add_argument(
"-verbose", action='count', default=0,
help='Add more messages (repeatable).')
parser.add_argument(
'-version', action='version', version='Version of '+__version__,
help='Display version information, then exit.')
args = parser.parse_args()
lg.setVerbose(args.verbose)
###############################################################################
# Main
#
print("\n******* Checking for UEFI vs. BIOS.")
uefiFinds = 0
x = subprocess.check_output([ "dmesg" ]).split("\n")
gr = []
for i in range(0, len(x)):
if (x[i].find('EFI v')>=0): gr.append(x[i])
if (len(gr)>0):
print("dmesg | grep 'EFI v' gets %d lines, says UEFI." % (len(gr)))
print("\n".join(gr))
uefiFinds += 1
if (os.path.isdir('/sys/firmware/efi')):
print("/sys/firmware/efi exists, so UEFI.\n")
uefiFinds += 1
if (not uefiFinds):
print("dmesg and /sys/firmware/efi checks failed, which means BIOS.")
sys.exit(0)