Merge lp:~lasall/os-prober-efi/cosmetics into lp:os-prober-efi
- cosmetics
- Merge into trunk
Proposed by
Dominique Lasserre
Status: | Approved |
---|---|
Approved by: | RapaNui |
Approved revision: | 2 |
Proposed branch: | lp:~lasall/os-prober-efi/cosmetics |
Merge into: | lp:os-prober-efi |
Diff against target: |
1080 lines (+518/-431) 2 files modified
trunc/30_os_prober_efi (+166/-132) trunc/os-prober-efi (+352/-299) |
To merge this branch: | bzr merge lp:~lasall/os-prober-efi/cosmetics |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
RapaNui | Approve | ||
Review via email:
|
Commit message
Description of the change
I did some cosmetic changes:
* quotes
* indents (2 whitespaces)
* replace tabs by whitespaces
* replace [ conditional ] && with normal if construct to improve readability
There shouldn't be any issues with that because my editor checks for not closed quotes and if contructs.
I placed two FIXME lines in 30_os... because I didn't understand the meaning of the comments.
And some minor changes. Sorry to not split this single commit!
To post a comment you must log in.
Unmerged revisions
- 2. By Dominique Lasserre
-
Quotes, indents, tabs, comment positions.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'trunc/30_os_prober_efi' |
2 | --- trunc/30_os_prober_efi 2012-09-22 01:28:25 +0000 |
3 | +++ trunc/30_os_prober_efi 2012-09-22 14:44:21 +0000 |
4 | @@ -1,5 +1,7 @@ |
5 | -#! /bin/sh -e |
6 | -######################################################################################## |
7 | +#! /bin/sh |
8 | +set -e |
9 | + |
10 | +########################################################################################### |
11 | # This is a grub-mkconfig helper script and for EFI-Systems only! |
12 | #--------------------------------------------------------------------------------------- |
13 | # Copyright (C) 2012 RapaNui https://launchpad.net/~wilstet |
14 | @@ -18,31 +20,31 @@ |
15 | # You should have received a copy of the GNU General Public License |
16 | # along with 30_os_prober_efi. If not, see <http://www.gnu.org/licenses/>. |
17 | # |
18 | -########################################################################################## |
19 | +########################################################################################### |
20 | # Create menuentries of the loaders (*.efi) from the EFI System Partition (ESP) "/boot/efi". |
21 | # This script is controlled by variables in the file "/etc/default/grub" , |
22 | -# they must begin with export, g.G.: |
23 | +# they must begin with export, e.g.: |
24 | # export GRUB_DISABLE_OS_PROBER_EFI=true disable this script |
25 | # INFO: If no ESP found the script always exits! |
26 | # export GRUB_MOUNTPOINT_EFI=/boot/efi only if "/boot/efi" is not the default path |
27 | # export GRUB_DISABLE_EFI_directory_loader disable directory and/or loader |
28 | # blanks (␣), slashes (/) and dots (.) |
29 | # must be changed for underscore (_) |
30 | -# The complete name must be UPPERCASE |
31 | -# e.G. /boot/efi/EFI/Microsoft/Boot/bootmgr.efi |
32 | +# The complete name must be UPPERCASE. |
33 | +# e.g. /boot/efi/EFI/Microsoft/Boot/bootmgr.efi |
34 | # `----v---´`-v-´`------v-----´`-----v-----´ |
35 | # ' ' ' +-> the Loader.efi |
36 | # ' ' +-> Vendor-Directory (directories with subdirectories) |
37 | # ' +-> Root of the ESP - always /EFI/ |
38 | # +-> Standard: /boot/efi/ or GRUB_MOUNTPOINT_EFI= |
39 | -# results e.G.: |
40 | +# results e.g.: |
41 | # export GRUB_DISABLE_EFI_MICROSOFT_BOOT_BOOTMGR.EFI=true => Loader explicitly disabled |
42 | # export GRUB_DISABLE_EFI_MICROSOFT_BOOT=treu => complete subdir /Boot/ disabled |
43 | # export GRUB_DISABLE_EFI_MICROSOFT=true => complete Mircosoft 8incl. subdirs) disabled |
44 | # |
45 | # By default, the following entries should be disabled in the "/etc/default/grub": |
46 | -# export GRUB_DISABLE_EFI_your_own_system see var GRUB_DISTRIBUTOR= |
47 | -# export GRUB_DISABLE_EFI_GRUB=true or GRUB, e.G. Arch |
48 | +# export GRUB_DISABLE_EFI_your_own_system see var GRUB_DISTRIBUTOR= |
49 | +# export GRUB_DISABLE_EFI_GRUB=true or GRUB, e.g. Arch |
50 | # export GRUB_DISABLE_EFI_BOOT=true Unified EFI Forum, Inc., use defined by the UEFI Specification |
51 | # export GRUB_DISABLE_EFI_FIRMWARE_INTEL=true Firmware of Intel |
52 | # export GRUB_DISABLE_EFI_MICROSOFT_BOOT_BOOTMGR.EFI=true the real loader is "bootmgfw.efi" |
53 | @@ -50,146 +52,178 @@ |
54 | # |
55 | ########################################################################################### |
56 | |
57 | -## Default definitions for this type of script ## |
58 | -prefix=/usr |
59 | -exec_prefix=${prefix} |
60 | -bindir=${exec_prefix}/bin |
61 | -sbindir=${exec_prefix}/sbin |
62 | -libdir=${exec_prefix}/lib |
63 | - if [ ! -e ${libdir}/grub/grub-mkconfig_lib ]; then # older versions of grub2 do not have this yet (LP: #459080) |
64 | - echo "no \"grub-mkconfig_lib\", exiting" |
65 | - exit 0 |
66 | - else . ${libdir}/grub/grub-mkconfig_lib |
67 | - fi |
68 | - |
69 | -## 30_os_prober_efi ## |
70 | +## Default definitions for this type of script ## |
71 | +prefix="/usr" |
72 | +exec_prefix="${prefix}" |
73 | +bindir="${exec_prefix}/bin" |
74 | +sbindir="${exec_prefix}/sbin" |
75 | +libdir="${exec_prefix}/lib" |
76 | + |
77 | +# older versions of grub2 do not have this yet (LP: #459080) |
78 | +if [ ! -e "${libdir}/grub/grub-mkconfig_lib" ]; then |
79 | + echo 'no "grub-mkconfig_lib", exiting' |
80 | + exit 0 |
81 | +else |
82 | + . "${libdir}/grub/grub-mkconfig_lib" |
83 | +fi |
84 | + |
85 | +## 30_os_prober_efi ## |
86 | if [ "x${GRUB_DISABLE_OS_PROBER_EFI}" = "xtrue" ]; then |
87 | exit 0 |
88 | fi |
89 | - |
90 | -classos='debian ubuntu fedora suse opensuse redhat arch grub boot microsoft apple' # --class os vendor-specific subdirectory names in the EFI system partition described in the UEFI Specification |
91 | -classos="$classos $GRUB_DISTRIBUTOR" # add system itself |
92 | -classgnu='debian ubuntu fedora opensuse arch grub' # --class gnu --class gnu-linux |
93 | -efiroot="/EFI" # suffix for efimount |
94 | -maxlogicalKB=8 # max. logical sector size for search GPT (8KiB) |
95 | + # --class os vendor-specific subdirectory names |
96 | + # in the EFI system partition described in the |
97 | + # UEFI Specification |
98 | +classos='debian ubuntu fedora suse opensuse redhat arch grub boot microsoft apple' |
99 | +classos="$classos $GRUB_DISTRIBUTOR" # add system itself |
100 | +classgnu='debian ubuntu fedora opensuse arch grub' # --class gnu --class gnu-linux |
101 | +efiroot="/EFI" # suffix for efimount |
102 | +maxlogicalKB=8 # max. logical sector size for search GPT (8KiB) |
103 | |
104 | if [ "x$GRUB_MOUNTPOINT_EFI" = "x" ]; then |
105 | -GRUB_MOUNTPOINT_EFI="/boot/efi" |
106 | -fi |
107 | - |
108 | -## Check: /sys/firmware/efi = EFI loaded ## |
109 | -if [ ! -d /sys/firmware/efi ]; then |
110 | - echo "***** Couldn't find \"/sys/firmware/efi/\" for accessing EFI variables" >&2 |
111 | - HINT1="# NO EFI-Mode found: $(date -R) _EFI=" |
112 | -else HINT1="# System in EFI-Mode: $(date -R) _EFI=" |
113 | -fi |
114 | - |
115 | -GRUB_MOUNTPOINT_EFI=$(dirname "${GRUB_MOUNTPOINT_EFI}/x")"/EFI" |
116 | - if [ ! -d "$GRUB_MOUNTPOINT_EFI" ]; then |
117 | - echo "***** Couldn't find \"$GRUB_MOUNTPOINT_EFI\" (EFI System Partition - ESP)" >&2 |
118 | - exit 0 |
119 | - fi |
120 | - |
121 | -## Get: device, drive and fs_uid with grub-probe ## |
122 | -EFIDEVICE=$(grub-probe -t device "$GRUB_MOUNTPOINT_EFI") # device: /dev/sdXY |
123 | - [ "x$EFIDEVICE" = "x" ] && exit 0 # error = exit & message will be from grub-probe |
124 | -efidev=$(echo $EFIDEVICE | sed -ne 's#\(/dev/[a-zA-Z]\+\)\([0-9]\+$\)#\1#p') # only /dev/alpha e.g. /dev/sda |
125 | -efipart=$(echo $EFIDEVICE | sed -ne 's#\(/dev/[a-zA-Z]\+\)\([0-9]\+$\)#\2#p') # only numeric e.g. 1 |
126 | -EFIROOT=$(grub-probe -t drive "$GRUB_MOUNTPOINT_EFI") # drive: (hdX,parttabY) |
127 | - [ "x$EFIROOT" = "x" ] && exit 0 # error = exit & message will be from grub-probe |
128 | -EFIUUID=$(grub-probe -t fs_uuid "$GRUB_MOUNTPOINT_EFI") # UUID of the partition |
129 | - [ "x$EFIUUID" = "x" ] && exit 0 # error = exit & message will be from grub-probe |
130 | - |
131 | -## Check: check GPT "EFI PART" ## |
132 | -maxlogicalKB=$(expr $maxlogicalKB \* 1024) # max. bytes for scan |
133 | + GRUB_MOUNTPOINT_EFI="/boot/efi" |
134 | +fi |
135 | + |
136 | +## Check: /sys/firmware/efi = EFI loaded ## |
137 | +if [ ! -d "/sys/firmware/efi" ]; then |
138 | + echo "***** Couldn't find \"/sys/firmware/efi/\" for accessing EFI variables" >&2 |
139 | + HINT1="# NO EFI-Mode found: $(date -R) _EFI=" |
140 | +else |
141 | + HINT1="# System in EFI-Mode: $(date -R) _EFI=" |
142 | +fi |
143 | + |
144 | +GRUB_MOUNTPOINT_EFI="$(dirname "${GRUB_MOUNTPOINT_EFI}/x")/EFI" |
145 | +if [ ! -d "$GRUB_MOUNTPOINT_EFI" ]; then |
146 | + echo "***** Couldn't find \"$GRUB_MOUNTPOINT_EFI\" (EFI System Partition - ESP)" >&2 |
147 | + exit 0 |
148 | +fi |
149 | + |
150 | +## Get: device, drive and fs_uid with grub-probe ## |
151 | +EFIDEVICE="$(grub-probe -t device "$GRUB_MOUNTPOINT_EFI")" # device: /dev/sdXY |
152 | +if [ "x$EFIDEVICE" = "x" ]; then |
153 | + # error = exit & message will be from grub-probe |
154 | + exit 0 |
155 | +fi |
156 | +efidev="$(echo "$EFIDEVICE" | sed -ne 's#\(/dev/[a-zA-Z]\+\)\([0-9]\+$\)#\1#p')" # only /dev/alpha e.g. /dev/sda |
157 | +efipart="$(echo "$EFIDEVICE" | sed -ne 's#\(/dev/[a-zA-Z]\+\)\([0-9]\+$\)#\2#p')" # only numeric e.g. 1 |
158 | +EFIROOT="$(grub-probe -t drive "$GRUB_MOUNTPOINT_EFI")" # drive: (hdX,parttabY) |
159 | +if [ "x$EFIROOT" = "x" ]; then |
160 | + # error = exit & message will be from grub-probe |
161 | + exit 0 |
162 | +fi |
163 | +EFIUUID="$(grub-probe -t fs_uuid "$GRUB_MOUNTPOINT_EFI")" # UUID of the partition |
164 | +if [ "x$EFIUUID" = "x" ]; then |
165 | + # error = exit & message will be from grub-probe |
166 | + exit 0 |
167 | +fi |
168 | + |
169 | +## Check: check GPT "EFI PART" ## |
170 | +maxlogicalKB="$(expr $maxlogicalKB \* 1024)" # max. bytes for scan |
171 | gptstart=0 |
172 | - if [ "x$efidev" != "x" ]; then # start position of GPT - start position of partition entires in decimal |
173 | - gptstart=$(printf '%d' 0x0$(hexdump -n$maxlogicalKB -C $efidev | grep "EFI PART"|cut -d ' ' -f1)) |
174 | - fi |
175 | -## Get GPT info: GUID and unique GUID ## |
176 | - if [ $gptstart -ne 0 ] ; then # search for size of a single partition entry (usually 128) |
177 | - gptpartsize=$(hexdump -s$(expr $gptstart + 84) -n4 -e '1/4 "%d"' $efidev) # offset +84 |
178 | - gptstartpart=$(expr $gptstart + 512 - $gptpartsize) # first partition entry - size |
179 | - gptefipart=$(expr $efipart + 0) # at least 0 |
180 | - gptstartguid=$(expr $gptefipart \* $gptpartsize) # offset of partition entry (usually 1024) |
181 | - HINT2=$(hexdump -s$(expr $gptstartpart + $gptstartguid) -n16 -e '/4 "%08x-" /2 "%04x-" /2 "%04x-" 2/1 "%02x" "-" 6/1 "%02x" "\n" ' $efidev) |
182 | - HINT3=$(hexdump -s$(expr $gptstartpart + $gptstartguid + 16) -n16 -e '/4 "%08x-" /2 "%04x-" /2 "%04x-" 2/1 "%02x" "-" 6/1 "%02x" "\n" ' $efidev) |
183 | - if [ "x$HINT2" != "xc12a7328-f81f-11d2-ba4b-00a0c93ec93b" ]; then |
184 | - HINT2='# _EFI= no ESP-GUID: c12a7328-f81f-11d2-ba4b-00a0c93ec93b' |
185 | - echo "***** $HINT2" >&2 |
186 | - fi |
187 | - HINT2="# GUID : $HINT2 _EFI= " |
188 | - HINT3="# unique : $HINT3 _EFI=" |
189 | - else # get the IDs of the four MPT entries |
190 | - HINT2="# _EFI= no GPT found (searched for $maxlogicalKB bytes)" |
191 | - HINT3="# _EFI= MBR/MPT-ID's "$(hexdump -s450 -n1 -e '1/1 "Part 1:%02x "' $efidev 2>/dev/null)\ |
192 | - $(hexdump -s466 -n1 -e '1/1 "Part 2:%02x "' $efidev 2>/dev/null)\ |
193 | - $(hexdump -s482 -n1 -e '1/1 "Part 3:%02x "' $efidev 2>/dev/null)\ |
194 | - $(hexdump -s498 -n1 -e '1/1 "Part 4:%02x"' $efidev 2>/dev/null) |
195 | - echo "***** $HINT2" >&2 |
196 | - fi |
197 | - |
198 | -## Check GRUB_DISABLE_EFI_directory/loader.efi from /etc/default/grub ## |
199 | +if [ "x$efidev" != "x" ]; then |
200 | + # start position of GPT - start position of partition entires in decimal |
201 | + gptstart="$(printf '%d' 0x0$(hexdump -n"$maxlogicalKB" -C "$efidev" | grep "EFI PART"|cut -d ' ' -f1))" |
202 | +fi |
203 | + |
204 | +## Get GPT info: GUID and unique GUID ## |
205 | +if [ "$gptstart" -ne 0 ] ; then |
206 | + # search for size of a single partition entry (usually 128) |
207 | + gptpartsize="$(hexdump -s$(expr "$gptstart" + 84) -n4 -e '1/4 "%d"' "$efidev")" # offset +84 |
208 | + gptstartpart="$(expr "$gptstart" + 512 - "$gptpartsize")" # first partition entry - size |
209 | + gptefipart="$(expr "$efipart" + 0)" # at least 0 |
210 | + gptstartguid="$(expr "$gptefipart" \* "$gptpartsize")" # offset of partition entry (usually 1024) |
211 | + HINT2="$(hexdump -s$(expr "$gptstartpart" + "$gptstartguid") -n16 -e '/4 "%08x-" /2 "%04x-" /2 "%04x-" 2/1 "%02x" "-" 6/1 "%02x" "\n" ' "$efidev")" |
212 | + HINT3="$(hexdump -s$(expr "$gptstartpart" + "$gptstartguid" + 16) -n16 -e '/4 "%08x-" /2 "%04x-" /2 "%04x-" 2/1 "%02x" "-" 6/1 "%02x" "\n" ' "$efidev")" |
213 | + if [ "x$HINT2" != "xc12a7328-f81f-11d2-ba4b-00a0c93ec93b" ]; then |
214 | + HINT2='# _EFI= no ESP-GUID: c12a7328-f81f-11d2-ba4b-00a0c93ec93b' |
215 | + echo "***** $HINT2" >&2 |
216 | + fi |
217 | + HINT2="# GUID : $HINT2 _EFI= " |
218 | + HINT3="# unique : $HINT3 _EFI=" |
219 | +else |
220 | + # get the IDs of the four MPT entries |
221 | + HINT2="# _EFI= no GPT found (searched for $maxlogicalKB bytes)" |
222 | + HINT3="# _EFI= MBR/MPT-ID's $(hexdump -s450 -n1 -e '1/1 "Part 1:%02x "' "$efidev" 2>/dev/null) \ |
223 | + $(hexdump -s466 -n1 -e '1/1 "Part 2:%02x "' "$efidev" 2>/dev/null) \ |
224 | + $(hexdump -s482 -n1 -e '1/1 "Part 3:%02x "' "$efidev" 2>/dev/null) \ |
225 | + $(hexdump -s498 -n1 -e '1/1 "Part 4:%02x"' "$efidev" 2>/dev/null)" |
226 | + echo "***** $HINT2" >&2 |
227 | +fi |
228 | + |
229 | +## Check GRUB_DISABLE_EFI_directory/loader.efi from /etc/default/grub ## |
230 | cat << EOF |
231 | $HINT1 |
232 | $HINT2 |
233 | $HINT3 |
234 | EOF |
235 | |
236 | -for efiboot in $(find "$GRUB_MOUNTPOINT_EFI" -type f -iname *.efi | tr ' ' '_') # search for entries |
237 | - do |
238 | - efishort=$(echo "$efiboot" | sed -e 's#^'"$GRUB_MOUNTPOINT_EFI"'/##g') # cut efimount-directory |
239 | - CLASS='--class efi' # Infos for menuentry |
240 | - CHAINER=$(echo "$efishort" | sed -e 's#\_#\\ #g') # chainloader without ($root)/EFI/ |
241 | - TITLE=$(echo $(dirname "$efishort")) # Menue title |
242 | - LOADER=$(basename "$CHAINER") # only the file |
243 | - check_short=$(echo $efishort | tr [a-z] [A-Z] | tr [/.:] '_') # with /et/default/grub - variables |
244 | - eval check_var=\$GRUB_DISABLE_EFI_$check_short # export GRUB_DISABLE_EFI_directory/loader.efi |
245 | - if [ "x$check_var" = "xtrue" ]; then |
246 | - printf ' (U)EFI %-40s %12s %s\n' "${TITLE} ${LOADER}" "** disabled **" "" >&2 |
247 | - continue # disabled loader found |
248 | - else |
249 | - check_short=$(echo $TITLE | tr [a-z] [A-Z]) # prepare |
250 | - check_new='' # for loop |
251 | - check_old=$check_short # and checking directories |
252 | - while [ "$check_old" != "$check_new" ]; do # and subdirectories |
253 | - check_var="\$GRUB_DISABLE_EFI_$(echo $check_old | tr [a-z] [A-Z] | tr [/\ .:] '_')" |
254 | - eval check_var=$check_var |
255 | - if [ "x$check_var" = "xtrue" ]; then |
256 | - printf ' (U)EFI %-40s %12s %s\n' "${TITLE} ${LOADER}" "** disabled **" "" >&2 |
257 | - continue 2 # disabled directory found |
258 | - fi |
259 | - check_new=$check_old # prepare |
260 | - check_old=$(dirname "$check_old") # new directory |
261 | - [ "$check_old" = "." ] && break # last directory not importand |
262 | - done |
263 | +# search for entries |
264 | +i= |
265 | +for efiboot in $(find "$GRUB_MOUNTPOINT_EFI" -type f -iname *.efi | tr ' ' '_'); do |
266 | + efishort="$(echo "$efiboot" | sed -e 's#^'"$GRUB_MOUNTPOINT_EFI"'/##g')" # cut efimount-directory |
267 | + CLASS='--class efi' # Infos for menuentry |
268 | + CHAINER="$(echo "$efishort" | sed -e 's#\_#\\ #g')" # chainloader without ($root)/EFI/ |
269 | + TITLE="$(dirname "$efishort")" # menue title |
270 | + LOADER="$(basename "$CHAINER")" # only the file |
271 | + check_short="$(echo "$efishort" | tr [a-z] [A-Z] | tr [/.:] '_')" # with /et/default/grub - variables |
272 | + eval check_var=\$GRUB_DISABLE_EFI_$check_short # export GRUB_DISABLE_EFI_directory/loader.efi |
273 | + if [ "x$check_var" = "xtrue" ]; then |
274 | + printf ' (U)EFI %-40s %12s %s\n' "${TITLE} ${LOADER}" "** disabled **" "" >&2 |
275 | + # disabled loader found |
276 | + continue |
277 | + else |
278 | + check_short="$(echo "$TITLE" | tr [a-z] [A-Z])" # prepare |
279 | + check_new='' # for loop |
280 | + check_old="$check_short" # and check directories |
281 | + while [ "$check_old" != "$check_new" ]; do # subdirectories |
282 | + check_var="\$GRUB_DISABLE_EFI_$(echo "$check_old" | tr [a-z] [A-Z] | tr [/\ .:] '_')" |
283 | + eval check_var=$check_var |
284 | + if [ "$check_var" = "true" ]; then |
285 | + printf ' (U)EFI %-40s %12s %s\n' "${TITLE} ${LOADER}" "** disabled **" "" >&2 |
286 | + # disabled directory found |
287 | + continue 2 |
288 | + fi |
289 | + check_new="$check_old" # prepare |
290 | + check_old="$(dirname "$check_old")" # new directory |
291 | + if [ "$check_old" = "." ]; then |
292 | + # last directory not importand |
293 | + #FIXME: important or imported? |
294 | + break |
295 | + fi |
296 | + done |
297 | fi |
298 | |
299 | -## Build the --class os and --class itself ## |
300 | -classes=$(echo "$classos" | tr [A-Z] [a-z] ) |
301 | -title=$(echo $TITLE | tr [A-Z] [a-z] | tr '/' ' ' | cut -d ' ' -f1 ) |
302 | -linuxnct=$(echo "$classes" | { grep -q "$title" ; echo $? ;}) |
303 | -[ $linuxnct = 0 ] && CLASS="$CLASS --class $title --class os" |
304 | - |
305 | -## Build the --class gnu and --class gnu-linux ## |
306 | -classes=$(echo "$classgnu" | tr [A-Z] [a-z] ) |
307 | -title=$(echo $TITLE | tr [A-Z] [a-z] | tr '/' ' ' | cut -d ' ' -f1 ) |
308 | -linuxnct=$(echo "$classes" | { grep -q "$title" ; echo $? ;}) |
309 | -[ $linuxnct = 0 ] && CLASS="$CLASS --class gnu --class gnu-linux" |
310 | - |
311 | -## Build the --class others ## |
312 | -[ "$CLASS" = '--class efi' ] && CLASS="$CLASS --class others" |
313 | - |
314 | -i=$(expr $i + 1) |
315 | - |
316 | -printf '%3s. (U)EFI %-40s %s %s\n' ${i} "${TITLE} ${LOADER}" "" "" >&2 |
317 | -cat << EOF |
318 | + ## Build the --class os and --class itself ## |
319 | + classes="$(echo "$classos" | tr [A-Z] [a-z] )" |
320 | + title="$(echo "$TITLE" | tr [A-Z] [a-z] | tr '/' ' ' | cut -d ' ' -f1 )" |
321 | + linuxnct="$(echo "$classes" | { grep -q "$title" ; echo $? ;})" |
322 | + if [ "$linuxnct" = "0" ]; then |
323 | + CLASS="$CLASS --class $title --class os" |
324 | + fi |
325 | + |
326 | + ## Build the --class gnu and --class gnu-linux ## |
327 | + classes="$(echo "$classgnu" | tr [A-Z] [a-z] )" |
328 | + title="$(echo $TITLE | tr [A-Z] [a-z] | tr '/' ' ' | cut -d ' ' -f1 )" |
329 | + linuxnct="$(echo "$classes" | { grep -q "$title" ; echo $? ;})" |
330 | + if [ "$linuxnct" = "0" ]; then |
331 | + CLASS="$CLASS --class gnu --class gnu-linux" |
332 | + fi |
333 | + |
334 | + ## Build the --class others ## |
335 | + if [ "$CLASS" = '--class efi' ]; then |
336 | + CLASS="$CLASS --class others" |
337 | + fi |
338 | + |
339 | + i=$(expr $i + 1) |
340 | + |
341 | + printf '%3s. (U)EFI %-40s %s %s\n' ${i} "${TITLE} ${LOADER}" "" "" >&2 |
342 | + cat << EOF |
343 | menuentry '(U)EFI ${TITLE} ${LOADER} (on $EFIDEVICE)' ${CLASS} { |
344 | insmod part_msdos |
345 | insmod fat |
346 | - set root='$EFIROOT' |
347 | - search --no-floppy --fs-uuid --set=root $EFIUUID |
348 | - chainloader (\${root})/EFI/$CHAINER |
349 | + set root='$EFIROOT' |
350 | + search --no-floppy --fs-uuid --set=root $EFIUUID |
351 | + chainloader (\${root})/EFI/$CHAINER |
352 | } |
353 | EOF |
354 | |
355 | |
356 | === modified file 'trunc/os-prober-efi' |
357 | --- trunc/os-prober-efi 2012-09-22 01:28:25 +0000 |
358 | +++ trunc/os-prober-efi 2012-09-22 14:44:21 +0000 |
359 | @@ -1,8 +1,8 @@ |
360 | #! /bin/sh |
361 | PGMNAME=`basename ${0}` |
362 | -VERSION='0.1'; |
363 | -RELEASE_DATE='Sep. 21, 2012'; |
364 | -############################################################################################ |
365 | +VERSION='0.1' |
366 | +RELEASE_DATE='Sep. 21, 2012' |
367 | +############################################################################### |
368 | # This is a EFI-System helper script and for EFI-Systems only! |
369 | # Needs GRUB and grub-probe (c) |
370 | #--------------------------------------------------------------------------------------- |
371 | @@ -22,7 +22,7 @@ |
372 | # You should have received a copy of the GNU General Public License |
373 | # along with 30_os_porber_efi. If not, see <http://www.gnu.org/licenses/>. |
374 | # |
375 | -########################################################################################### |
376 | +############################################################################### |
377 | # Analyze the system EFI-environment: |
378 | # Check: /sys/firmware/efi/ |
379 | # partition table (GPT) and list the UUID, GUID and unique GUID |
380 | @@ -35,143 +35,154 @@ |
381 | # device information with lsdisk - if installed (lsdisk: https://launchpad.net/lsdisk) |
382 | # the startup.nsh |
383 | # the ESP entries with information (found, disabled, GRUB configuration variable) |
384 | -############################################################################################ |
385 | -############## initial values ############## |
386 | +############################################################################### |
387 | + |
388 | + |
389 | +############## initial values ############## |
390 | execpath="/usr/bin /usr/sbin usrs/local/sbin /usr/local/bin /bin /sbin" |
391 | programs='basename cat chown dirname dmidecode echo efibootmgr expr find grep grub-probe hexdump lsdisk printf sed whoami which' |
392 | -classos='debian ubuntu fedora suse opensuse redhat arch grub boot microsoft apple' # --class os vendor-specific subdirectory names in the EFI system partition described in the UEFI Specification |
393 | -classgnu='debian ubuntu fedora opensuse arch grub' # --class gnu --class gnu-linux |
394 | -grubconfig="/etc/default/grub" # Grub configuration-file, e.G. /etc/default/grub |
395 | -etcfstab="/etc/fstab" # fstab, e.G. /etc/fstab |
396 | -efimount="/boot/efi" # EFI-System mountpoint, e.G. /boot/efi |
397 | -efiroot="/EFI" # suffix for efimount |
398 | -maxlogicalKB=8 # max. logical sector size for search GPT (8KiB) |
399 | -footer='------- END ----------' # for list-end |
400 | + # --class os vendor-specific subdirectory names |
401 | + # in the EFI system partition described in the |
402 | + # UEFI Specification |
403 | +classos='debian ubuntu fedora suse opensuse redhat arch grub boot microsoft apple' |
404 | +classgnu='debian ubuntu fedora opensuse arch grub' # --class gnu --class gnu-linux |
405 | +grubconfig="/etc/default/grub" # Grub configuration-file, e.G. /etc/default/grub |
406 | +etcfstab="/etc/fstab" # fstab, e.G. /etc/fstab |
407 | +efimount="/boot/efi" # EFI-System mountpoint, e.G. /boot/efi |
408 | +efiroot="/EFI" # suffix for efimount |
409 | +maxlogicalKB=8 # max. logical sector size for search GPT (8KiB) |
410 | +footer='------- END ----------' # for list-end |
411 | lsdiskinfo='(lsdisk: https://launchpad.net/lsdisk * https://sourceforge.net/projects/lsdisk)' |
412 | -rc=0 # return-code |
413 | -forceit=no # exit by rc != 0 |
414 | -all=no # Options - do not change !! |
415 | -efiloader=0 # ^ |
416 | -efinvram=0 # " |
417 | -fstab=0 # " |
418 | -grubconf=0 # " |
419 | -grubuids=0 # " |
420 | -mountstat=0 # " |
421 | -startup=0 # v |
422 | -listdisk=0 # Options - do not change ! |
423 | +rc=0 # return-code |
424 | +forceit=no # exit by rc != 0 |
425 | +all=no # Options - do not change ! |
426 | +efiloader=0 # ^ |
427 | +efinvram=0 # " |
428 | +fstab=0 # " |
429 | +grubconf=0 # " |
430 | +grubuids=0 # " |
431 | +mountstat=0 # " |
432 | +startup=0 # v |
433 | +listdisk=0 # Options - do not change ! |
434 | |
435 | _usage() { |
436 | -################################################################################## |
437 | -## U S A G E ## |
438 | - cat <<EOF |
439 | +############################################################################### |
440 | +## U S A G E ## |
441 | + cat <<EOF |
442 | $PGMNAME $Options |
443 | $* |
444 | |
445 | Usage: lsdisk <[options]> |
446 | - Some options need 'root privileges'. Without options show only loader |
447 | + Some options need 'root privileges'. Without options show only loader |
448 | |
449 | Options: |
450 | - -a --all 'root' List all informations (-f -g -l -m -n -s -u) and "lsdisk" if installed |
451 | - -d --device List device information with "lsdisk" - if installed |
452 | + -a --all 'root' List all informations (-f -g -l -m -n -s -u) and "lsdisk" if installed |
453 | + -d --device List device information with "lsdisk" - if installed |
454 | $lsdiskinfo |
455 | - -D --dev-list 'root' List device information with "lsdisk -A" - if installed |
456 | - -f --fstab List EFI entries of "/etc/fstab" |
457 | - "${prefixdir}/${etcfstab}" |
458 | - -g --grub List EFI variable-entries of e.G. "/etc/default/grub" |
459 | - ("${prefixdir}${grubconfig}") |
460 | - -h --help Show this help message |
461 | - -l --loader List EFI System Partition EFI-loader, e.G. /boot/efi/EFI/*.efi |
462 | - -m --mount List mounted devices |
463 | - -n --nvram 'root' List NVRAM with efibootmgr --verbose |
464 | - -s --script List the ESP-scripts "startup.nsh" |
465 | - -u --uids 'root' List EFI System Partition uid (uuid, GPT-GUID, unique GPT-GUID) |
466 | - -v --version Display version information |
467 | - |
468 | - -E --efi-directory= System-mountpoint of the ESP - e.G. --efi-directory="/boot/efi" |
469 | - ("${prefixdir}${efimount_check}") |
470 | - -G --grub-configfile= Grub-configfile, e.G. --grub-config="/etc/default/grub" |
471 | - ("${prefixdir}${grubconfig}") |
472 | - -M --fstab-file= Mounttab (fstab), e.G. --fstab-sile="/etc/fstab" |
473 | - ("${prefixdir}${etcfstab}") |
474 | - -P --prefix= Set prefix for all directories, e.G. --prefix="/mnt" ("${prefixdir}") |
475 | - |
476 | - --force Do what I say, even if it is stupid. |
477 | + -D --dev-list 'root' List device information with "lsdisk -A" - if installed |
478 | + -f --fstab List EFI entries of "/etc/fstab" |
479 | + "${prefixdir}/${etcfstab}" |
480 | + -g --grub List EFI variable-entries of e.G. "/etc/default/grub" |
481 | + ("${prefixdir}${grubconfig}") |
482 | + -h --help Show this help message |
483 | + -l --loader List EFI System Partition EFI-loader, e.G. /boot/efi/EFI/*.efi |
484 | + -m --mount List mounted devices |
485 | + -n --nvram 'root' List NVRAM with efibootmgr --verbose |
486 | + -s --script List the ESP-scripts "startup.nsh" |
487 | + -u --uids 'root' List EFI System Partition uid (uuid, GPT-GUID, unique GPT-GUID) |
488 | + -v --version Display version information |
489 | + |
490 | + -E --efi-directory= System-mountpoint of the ESP - e.G. --efi-directory="/boot/efi" |
491 | + ("${prefixdir}${efimount_check}") |
492 | + -G --grub-configfile= Grub-configfile, e.G. --grub-config="/etc/default/grub" |
493 | + ("${prefixdir}${grubconfig}") |
494 | + -M --fstab-file= Mounttab (fstab), e.G. --fstab-sile="/etc/fstab" |
495 | + ("${prefixdir}${etcfstab}") |
496 | + -P --prefix= Set prefix for all directories, e.G. --prefix="/mnt" ("${prefixdir}") |
497 | + |
498 | + --force Do what I say, even if it is stupid. |
499 | EOF |
500 | - exit 1 |
501 | + exit 1 |
502 | } |
503 | |
504 | -## Check: Programs and there systempath * error = rc1 ## |
505 | +## Check: Programs and there systempath * error = rc1 ## |
506 | for pgm in ${programs} ; do |
507 | - check1=$(dirname $(which $pgm 2>/dev/null) 2>/dev/null) |
508 | - check2=$(echo $check1 | grep -Eq "($(echo $execpath|tr ' ' '|'))" ; echo $?) |
509 | - if [ $check2 -ne 0 ]; then |
510 | - echo " ***** Couldn't find \"${pgm}\" in path: \"$execpath\" ($(which $pgm 2>/dev/null))" >&2 |
511 | + check1="$(dirname $(which "$pgm" 2>/dev/null) 2>/dev/null)" |
512 | + check2="$(echo "$check1" | grep -Eq "($(echo "$execpath"|tr ' ' '|'))" ; echo $?)" |
513 | + if [ "$check2" -ne 0 ]; then |
514 | + echo " ***** Couldn't find \"${pgm}\" in path: \"$execpath\" ($(which "$pgm" 2>/dev/null))" >&2 |
515 | rc=1 |
516 | fi |
517 | done |
518 | |
519 | -################################################################################## |
520 | -## O P T I O N S ## |
521 | +############################################################################### |
522 | +## O P T I O N S ## |
523 | OPTIND=1 |
524 | optind=0 |
525 | prefixdir= |
526 | -Options="$@" # save Options |
527 | -Optinum=$# # save Option count |
528 | +Options="$@" # save Options |
529 | +Optinum=$# # save Option count |
530 | |
531 | |
532 | while getopts ':adfghlmnsuv-DE:G:M:P:' OPTION ; do |
533 | case "$OPTION" in |
534 | - a ) all=yes ;; |
535 | - d ) listdisk=1 ;; |
536 | - f ) fstab=1 ;; |
537 | - g ) grubconf=1 ;; |
538 | - h ) _usage ;; |
539 | - l ) efiloader=1 ;; |
540 | - m ) mountstat=1 ;; |
541 | - n ) efinvram=1 ;; |
542 | - s ) startup=1 ;; |
543 | - u ) grubuids=1 ;; |
544 | - v ) echo "$PGMNAME - $VERSION - $RELEASE_DATE" |
545 | - exit 0 |
546 | - ;; |
547 | - D ) listdisk=1;listopt='a' ;; |
548 | - E ) efimount_check=$(dirname "${OPTARG}/x") ;; |
549 | - G ) grubconfig="$OPTARG" ;; |
550 | - M ) etcfstab="$OPTARG" ;; |
551 | - P ) prefixdir=$(dirname "${OPTARG}/x") ;; |
552 | - - ) [ $OPTIND -ge 1 ] && optind=$(expr $OPTIND - 1 ) || optind=$OPTIND # long options |
553 | - eval OPTION="\$$optind" |
554 | - OPTARG=$(echo $OPTION | cut -d'=' -f2) |
555 | - OPTION=$(echo $OPTION | cut -d'=' -f1) |
556 | - case $OPTION in |
557 | - --all ) all=yes ;; |
558 | - --device ) listdisk=1 ;; |
559 | - --dev-list ) listdisk=1,listopt='a' ;; |
560 | - --efi-directory ) efimount_check=$(dirname "${OPTARG}/x") ;; |
561 | - --fstab ) fstab=1; etcfstab=$OPTARG ;; |
562 | - --fstab-file ) etcfstab="$OPTARG" ;; |
563 | - --force ) forceit=yes ;; |
564 | - --grub ) grubconf=1 ;; |
565 | - --grub-configfile ) grubconfig="$OPTARG" ;; |
566 | - --help ) _usage ;; |
567 | - --loader ) efiloader=1 ;; |
568 | - --mount ) mountstat=1 ;; |
569 | - --prefix ) prefixdir=$(dirname "${OPTARG}/x") ;; |
570 | - --script ) startup=1 ;; |
571 | - --uids ) grubuids=1 ;; |
572 | - --version ) echo "$PGMNAME - $VERSION - $RELEASE_DATE" |
573 | - exit 0 |
574 | + a ) all=yes ;; |
575 | + d ) listdisk=1 ;; |
576 | + f ) fstab=1 ;; |
577 | + g ) grubconf=1 ;; |
578 | + h ) _usage ;; |
579 | + l ) efiloader=1 ;; |
580 | + m ) mountstat=1 ;; |
581 | + n ) efinvram=1 ;; |
582 | + s ) startup=1 ;; |
583 | + u ) grubuids=1 ;; |
584 | + v ) echo "$PGMNAME - $VERSION - $RELEASE_DATE" |
585 | + exit 0 |
586 | + ;; |
587 | + D ) listdisk=1;listopt='a' ;; |
588 | + E ) efimount_check=$(dirname "${OPTARG}/x") ;; |
589 | + G ) grubconfig="$OPTARG" ;; |
590 | + M ) etcfstab="$OPTARG" ;; |
591 | + P ) prefixdir=$(dirname "${OPTARG}/x") ;; |
592 | + |
593 | + # long options |
594 | + - ) [ "$OPTIND" -ge 1 ] && optind=$(expr "$OPTIND" - 1 ) || optind="$OPTIND" |
595 | + eval OPTION="\$$optind" |
596 | + OPTARG="$(echo "$OPTION" | cut -d'=' -f2)" |
597 | + OPTION="$(echo "$OPTION" | cut -d'=' -f1)" |
598 | + case "$OPTION" in |
599 | + --all ) all=yes ;; |
600 | + --device ) listdisk=1 ;; |
601 | + --dev-list ) listdisk=1,listopt='a' ;; |
602 | + --efi-directory ) efimount_check="$(dirname "${OPTARG}/x")" ;; |
603 | + --fstab ) fstab=1; etcfstab="$OPTARG" ;; |
604 | + --fstab-file ) etcfstab="$OPTARG" ;; |
605 | + --force ) forceit=yes ;; |
606 | + --grub ) grubconf=1 ;; |
607 | + --grub-configfile ) grubconfig="$OPTARG" ;; |
608 | + --help ) _usage ;; |
609 | + --loader ) efiloader=1 ;; |
610 | + --mount ) mountstat=1 ;; |
611 | + --prefix ) prefixdir="$(dirname "${OPTARG}/x")" ;; |
612 | + --script ) startup=1 ;; |
613 | + --uids ) grubuids=1 ;; |
614 | + --version ) echo "$PGMNAME - $VERSION - $RELEASE_DATE" |
615 | + exit 0 |
616 | ;; |
617 | - * ) _usage " >>> invalid long options" ;; |
618 | - esac |
619 | - shift |
620 | - OPTIND=1 |
621 | - ;; |
622 | - ? ) _usage "Short: >>>>>>>> invalid short options" ;; |
623 | + * ) _usage " >>> invalid long options" ;; |
624 | + esac |
625 | + shift |
626 | + OPTIND=1 |
627 | + ;; |
628 | + |
629 | + ? ) _usage "Short: >>>>>>>> invalid short options" ;; |
630 | esac |
631 | done |
632 | |
633 | -[ $(expr $efiloader + $efinvram + $fstab + $grubconf + $grubuids + $mountstat + $startup + $listdisk) = 0 ] && efiloader=1 |
634 | +if [ $(expr "$efiloader" + "$efinvram" + "$fstab" + "$grubconf" + "$grubuids" \ |
635 | + + "$mountstat" + "$startup" + "$listdisk") = 0 ]; then |
636 | + efiloader=1 |
637 | +fi |
638 | if [ "x$all" = "xyes" ]; then |
639 | Options='--all' |
640 | efiloader=1 |
641 | @@ -184,208 +195,250 @@ |
642 | listdisk=1 |
643 | fi |
644 | |
645 | -################################################################################## |
646 | -## S T A R T ## |
647 | -echo '';echo " $PGMNAME $Options" >&2 |
648 | - |
649 | -## Check: sysfs ## |
650 | -if [ ! -d /sys ]; then |
651 | - echo " ***** Couldn't open \"sysfs\" (/sys directory) - you need kernel 2.6.32 or later" >&2 |
652 | - rc=1 |
653 | -fi |
654 | - |
655 | -## Check: /sys/firmware/efi = EFI loaded ## |
656 | -if [ ! -d /sys/firmware/efi ]; then |
657 | - echo " ***** Couldn't find \"/sys/firmware/efi/\" for accessing EFI variables" >&2 |
658 | - rc=1 |
659 | -fi |
660 | - |
661 | -## Set: /etc/fstab ## |
662 | +############################################################################### |
663 | +## S T A R T ## |
664 | +echo |
665 | +echo " $PGMNAME $Options" >&2 |
666 | + |
667 | +## Check: sysfs ## |
668 | +if [ ! -d "/sys" ]; then |
669 | + echo " ***** Couldn't open \"sysfs\" (/sys directory) - you need kernel 2.6.32 or later" >&2 |
670 | + rc=1 |
671 | +fi |
672 | + |
673 | +## Check: /sys/firmware/efi = EFI loaded ## |
674 | +if [ ! -d "/sys/firmware/efi" ]; then |
675 | + echo " ***** Couldn't find \"/sys/firmware/efi/\" for accessing EFI variables" >&2 |
676 | + rc=1 |
677 | +fi |
678 | + |
679 | +## Set: /etc/fstab ## |
680 | etcfstab="${prefixdir}${etcfstab}" |
681 | if [ "$fstab" != "0" ]; then |
682 | - if [ ! -f "$etcfstab" ];then |
683 | - echo " ***** Couldn't find fstab: \"$etcfstab\"" >&2 |
684 | - rc=1 |
685 | - fi |
686 | + if [ ! -f "$etcfstab" ];then |
687 | + echo " ***** Couldn't find fstab: \"$etcfstab\"" >&2 |
688 | + rc=1 |
689 | + fi |
690 | fi |
691 | |
692 | -## Check: Grub config-file, e.G. /etc/default/grub ## |
693 | +## Check: Grub config-file, e.g. /etc/default/grub ## |
694 | grubconfig="${prefixdir}${grubconfig}" |
695 | if [ -f "$grubconfig" ];then |
696 | - . "$grubconfig" |
697 | - efimount="$GRUB_MOUNTPOINT_EFI" |
698 | - grubcheck=yes |
699 | - else |
700 | - echo " ***** Couldn't find Grub config-file: \"$grubconfig\"" >&2 |
701 | - rc=1 |
702 | -fi |
703 | - |
704 | -## After all posible modifications set final efimount ## |
705 | - [ "x$efimount_check" != "x" ] && efimount="${prefixdir}${efimount_check}" || efimount=${prefixdir}${efimount} |
706 | - |
707 | -## Check: EFI-System mountpoint, e.G. /boot/efi subdir /EFI ## |
708 | + . "$grubconfig" |
709 | + efimount="$GRUB_MOUNTPOINT_EFI" |
710 | + grubcheck=yes |
711 | +else |
712 | + echo " ***** Couldn't find Grub config-file: \"$grubconfig\"" >&2 |
713 | + rc=1 |
714 | +fi |
715 | + |
716 | +## After all posible modifications set final efimount ## |
717 | +if [ "x$efimount_check" != "x" ]; then |
718 | + efimount="${prefixdir}${efimount_check}" |
719 | +else |
720 | + efimount="${prefixdir}${efimount}" |
721 | +fi |
722 | + |
723 | +## Check: EFI-System mountpoint, e.g. /boot/efi subdir /EFI ## |
724 | if [ ! -d "${efimount}${efiroot}" ]; then |
725 | - echo " ***** Couldn't find \"${efimount}${efiroot}\" (EFI System Partition - ESP)" >&2 |
726 | - rc=1 |
727 | + echo " ***** Couldn't find \"${efimount}${efiroot}\" (EFI System Partition - ESP)" >&2 |
728 | + rc=1 |
729 | fi |
730 | |
731 | -## If errors and NO --force = exit ## |
732 | +## If errors and NO --force = exit ## |
733 | if [ $rc -ne 0 ]; then |
734 | - if [ "x$forceit" != "xyes" ] ; then |
735 | - echo " ***** Try running with --force" >&2 |
736 | - [ "x$(which lsdisk 2>/dev/null)" != "x" ] && lsdisk >&2 |
737 | - exit 1 |
738 | - fi |
739 | + if [ "x$forceit" != "xyes" ] ; then |
740 | + echo " ***** Try running with --force" >&2 |
741 | + if [ "x$(which lsdisk 2>/dev/null)" != "x" ]; then |
742 | + lsdisk >&2 |
743 | + fi |
744 | + exit 1 |
745 | + fi |
746 | fi |
747 | |
748 | -################################################################################## |
749 | -## L I S T I N G ## |
750 | -if [ $(whoami) = root ] ; then # Mainboard-Infos with dmidecode |
751 | - echo '';echo " --------------- Mainboard - Info ---------------" |
752 | - dmidecode -t0 | grep -Ei "(Vendor:|Version:|Release Date:|BIOS boot|EFI)" |
753 | - dmimsg=$(dmidecode -t0 | { grep "EFI" || echo "NOT" ;}) |
754 | - [ "x$dmimsg" = "xNOT" ] && echo ' ***** UEFI supported NOT found' >&2 |
755 | - echo " ------------------------------------------------" |
756 | +############################################################################### |
757 | +## L I S T I N G ## |
758 | +# Mainboard-Infos with dmidecode |
759 | +if [ "$(whoami)" = root ]; then |
760 | + echo |
761 | + echo " --------------- Mainboard - Info ---------------" |
762 | + dmidecode -t0 | grep -Ei "(Vendor:|Version:|Release Date:|BIOS boot|EFI)" |
763 | + dmimsg=$(dmidecode -t0 | { grep "EFI" || echo "NOT" ;}) |
764 | + if [ "x$dmimsg" = "xNOT" ]; then |
765 | + echo ' ***** UEFI supported NOT found' >&2 |
766 | + fi |
767 | + echo " ------------------------------------------------" |
768 | fi |
769 | |
770 | echo "---------------------- System - Info -----------------------------------------------------------------------------------" |
771 | -if [ "x$(which lsb_release 2>/dev/null)" = "x/usr/bin/lsb_release" ] ;then |
772 | - lsbrel=$(lsb_release -d) |
773 | - if [ "x$(which uname 2>/dev/null)" = "x/bin/uname" ] ; then |
774 | - lsarch=$(uname -m) |
775 | - lsvers=$(uname -v) |
776 | - echo "Architecture: $lsarch Kernel version: $lsvers" |
777 | - fi |
778 | - echo "$(cat /proc/cmdline)" |
779 | - echo "$footer" |
780 | -fi |
781 | - |
782 | -if [ $listdisk -ge 1 ]; then # Option list device information |
783 | - echo "---------------------- List device info of all connected volumes ----------------------" |
784 | - if [ "x$(which lsdisk 2>/dev/null)" != "x" ]; then |
785 | - [ $(whoami) != root -a "x$listopt" = "xa" ] && { listopt=''; echo " ***** \"lsdisk\" you need root privileges for listing partition table">&2 ;} |
786 | - lsdisk -l$listopt |
787 | - else echo " ***** "lsdisk" not installed $lsdiskinfo">&2 |
788 | - fi |
789 | - echo "$footer" |
790 | - fi |
791 | - |
792 | -if [ $mountstat -ge 1 ] ; then # Option mounted devices |
793 | - echo "---------------------- Mounted devices ... -------------------------------------------------------" |
794 | - grep '^device /dev/' /proc/self/mountstats |
795 | -echo "$footer" |
796 | -fi |
797 | - |
798 | -if [ $fstab -ge 1 ] ; then # Option /etc/fstab entries |
799 | - echo "---------------------- Entries in \"$etcfstab\" -------------------------------------------------------" |
800 | - grep -v '^#' "$etcfstab" |
801 | -echo "$footer" |
802 | -fi |
803 | - |
804 | -if [ $efinvram -ge 1 ] ; then # Option NVRAM - efibootmgr |
805 | - echo "---------------------- NVRAM with efibootmgr -----------------------------------------------------" |
806 | - if [ $(whoami) = root ] ; then |
807 | - efibootmgr --verbose |
808 | - [ $? -ne 0 ] && echo 'Or "efibootmgr" ist not installed!' |
809 | - else echo " ***** permission denied - you'll need root privileges " >&2 |
810 | - fi |
811 | -echo "$footer" |
812 | -fi |
813 | - |
814 | -if [ $startup -ge 1 ] ; then # Option startup.nsh |
815 | - echo "---------------------- (ESP) startup.nsh ------------------------------" |
816 | - for efiboot in $(find "${efimount}" -type f -iname startup.nsh | tr ' ' '_'); do |
817 | - efiboot=$(echo "$efiboot" | tr '_' ' ') |
818 | - echo "---------------------- \"$efiboot\"" |
819 | - cat "${efiboot}"; echo '' |
820 | - done |
821 | - echo "$footer" |
822 | -fi |
823 | - |
824 | - |
825 | -if [ $grubuids -ge 1 ] ; then # Option UUID/GUIDs |
826 | - echo "---------------------- (ESP) fs_UUID - GUID - unique GUID ----------------------------------------" |
827 | - echo "---------------------- \"${efimount}${efiroot}\"" |
828 | - if [ $(whoami) = root ] ; then |
829 | - EFIDEVICE=$(grub-probe -t device "${efimount}${efiroot}") # device: /dev/sdXY |
830 | - efidev=$(echo $EFIDEVICE | sed -ne 's#\(/dev/[a-zA-Z]\+\)\([0-9]\+$\)#\1#p') # only /dev/alpha e.g. /dev/sda |
831 | - efipart=$(echo $EFIDEVICE | sed -ne 's#\(/dev/[a-zA-Z]\+\)\([0-9]\+$\)#\2#p') # only numeric e.g. 1 |
832 | - EFIROOT=$(grub-probe -t drive "${efimount}${efiroot}") # drive: (hdX,parttabY) |
833 | - EFIUUID=$(grub-probe -t fs_uuid "${efimount}${efiroot}") # UUID of the partition |
834 | - maxlogicalKB=$(expr $maxlogicalKB \* 1024) # max. bytes for scan |
835 | - gptstart=0 |
836 | - if [ "x$efidev" != "x" ] ; then # start position of GPT - start position of partition entires in decimal |
837 | - gptstart=$(printf '%d' 0x0$( hexdump -n$maxlogicalKB -C $efidev | grep "EFI PART"|cut -d ' ' -f1)) |
838 | - fi |
839 | - if [ $gptstart -ne 0 ] ; then # search for size of a single partition entry (usually 128) |
840 | - gptpartsize=$( hexdump -s$(expr $gptstart + 84) -n4 -e '1/4 "%d"' $efidev) # offset +84 |
841 | - gptstartpart=$(expr $gptstart + 512 - $gptpartsize) # first partition entry - size |
842 | - gptefipart=$(expr $efipart + 0) # at least 0 |
843 | - gptstartguid=$(expr $gptefipart \* $gptpartsize) # offset of partition entry (usually 1024) |
844 | - EFIGUID=$(hexdump -s$(expr $gptstartpart + $gptstartguid) -n16 -e '/4 "%08x-" /2 "%04x-" /2 "%04x-" 2/1 "%02x" "-" 6/1 "%02x" "\n" ' $efidev) |
845 | - EFIGUID2=$(hexdump -s$(expr $gptstartpart + $gptstartguid + 16) -n16 -e '/4 "%08x-" /2 "%04x-" /2 "%04x-" 2/1 "%02x" "-" 6/1 "%02x" "\n" ' $efidev) |
846 | - else echo " ***** no GPT found (searched for $maxlogicalKB bytes)" >&2 |
847 | - if [ "x$efidev" != "x" ]; then # List MBR/MPT |
848 | - echo " MBR: Boot Start-CHS ID End-CHS LBA1 LBA2" >&2 |
849 | - hexdump -s 446 -n 64 -v -e '1/1 " %02x " 3/1 "|%3u" 1/1 "| %02x " 3/1 "|%3u" 2/4 "|%9u" "|\n"' $efidev >&2 |
850 | - echo '' |
851 | - fi |
852 | - fi |
853 | - printf 'Device %-11s : UUID = %s Drive = %s \n' "$EFIDEVICE" "$EFIUUID" "$EFIROOT" |
854 | - printf 'GUID : %s \n' "$EFIGUID" |
855 | - if [ "x$EFIGUID" != "xc12a7328-f81f-11d2-ba4b-00a0c93ec93b" ]; then |
856 | - echo " ****** no ESP-GUID: c12a7328-f81f-11d2-ba4b-00a0c93ec93b" >&2 |
857 | - fi |
858 | - printf 'GUID unique : %s \n' "$EFIGUID2" |
859 | - else echo " ***** permission denied - you'll need root privileges " >&2 |
860 | - fi |
861 | -echo "$footer" |
862 | -fi |
863 | - |
864 | -if [ $grubconf -ge 1 ] ;then # Option EFI-configuration variables from grubconfig |
865 | - echo "---------------------- EFI variable in \"$grubconfig\" -----------------------------------------" |
866 | - grep -Ei '(_EFI_|_EFI=)' "$grubconfig" |
867 | -echo "$footer" |
868 | -fi |
869 | - |
870 | -if [ $efiloader -ge 1 ] ;then # Option ESP-Loader-Entries (*.efi) |
871 | - echo "---------------------- EFI entries in \"${efimount}${efiroot}\" -------------------------------" |
872 | -check_disable='not checked' |
873 | - |
874 | - for efiboot in $(find "${efimount}${efiroot}" -type f -iname *.efi | tr ' ' '_'); do # search for entries |
875 | - i=$(expr $i + 1) |
876 | - efishort=$(echo "$efimount" | tr ' ' '_') |
877 | - efishort=$(echo "$efiboot" | sed -e 's#^'"${efishort}${efiroot}"'/##g') # cut efimount/efiroot directory |
878 | - CLASS='--class efi' # Infos for menuentry |
879 | - CHAINER=$(echo "$efishort" | sed -e 's#\_#\\ #g') # chainloader without ($root)/EFI/ |
880 | - TITLE=$(echo $(dirname "$efishort")) # Menue title |
881 | - LOADER=$(basename "$CHAINER") # only the file |
882 | - [ "x$grubcheck" = "xyes" ] && check_disable='' # check complete file |
883 | - check_short=$(echo $efishort | tr [a-z] [A-Z] | tr [/.:] '_') # with /et/default/grub - variables |
884 | - eval check_var=\$GRUB_DISABLE_EFI_$check_short # export GRUB_DISABLE_EFI_directory/loader.efi |
885 | - CHECKER="GRUB_DISABLE_EFI_$check_short" |
886 | - |
887 | - if [ "x$check_var" = "xtrue" ]; then |
888 | - [ "x$grubcheck" = "xyes" ] && check_disable='disabled' |
889 | - else |
890 | - check_short=$(echo $TITLE | tr [a-z] [A-Z]| tr [/.:] '_') # prepare |
891 | - check_new='' # for loop |
892 | - check_old=$(echo $TITLE | tr [a-z] [A-Z]| tr [/.:] '_') # and checking directorie |
893 | - while [ "$check_old" != "$check_new" ]; do |
894 | - check_var="\$GRUB_DISABLE_EFI_$(echo $check_old | tr [a-z] [A-Z] | tr [/\ .:] '_')" |
895 | - eval check_var=$check_var |
896 | - if [ "x$check_var" = "xtrue" ]; then |
897 | - [ "x$grubcheck" = "xyes" ] && check_disable='disabled' # found disabled |
898 | - break # terminat loop |
899 | - fi |
900 | - check_new=$check_old # prepare |
901 | - check_old=$(dirname "$check_old") # new directory |
902 | - [ "$check_old" = "." ] && break # terminate loop |
903 | - done |
904 | - fi |
905 | - printf '%3s. %-8s: %8s %-40s %s %s\n' ${i} "$check_disable" "(U)EFI" "${TITLE} ${LOADER}" ": $(echo $efiboot | tr '_' ' ')" "" |
906 | - printf '%3s %-8s %8s %-40s %s %s\n' ' ' ' ' ' ' ' ' ' ' " $CHECKER" |
907 | - |
908 | - done |
909 | - echo "$footer" |
910 | +if [ "x$(which lsb_release 2>/dev/null)" = "x/usr/bin/lsb_release" ]; then |
911 | + lsbrel=$(lsb_release -d) |
912 | + if [ "x$(which uname 2>/dev/null)" = "x/bin/uname" ]; then |
913 | + lsarch="$(uname -m)" |
914 | + lsvers="$(uname -v)" |
915 | + echo "Architecture: $lsarch Kernel version: $lsvers" |
916 | + fi |
917 | + echo "$(cat /proc/cmdline)" |
918 | + echo "$footer" |
919 | +fi |
920 | + |
921 | +# Option list device information |
922 | +if [ "$listdisk" -ge 1 ]; then |
923 | + echo "---------------------- List device info of all connected volumes ----------------------" |
924 | + if [ "x$(which lsdisk 2>/dev/null)" != "x" ]; then |
925 | + if [ "$(whoami)" != root -a "x$listopt" = "xa" ]; then |
926 | + { listopt=''; |
927 | + echo " ***** \"lsdisk\" you need root privileges for listing partition table">&2 ;} |
928 | + fi |
929 | + lsdisk -l"$listopt" |
930 | + else echo " ***** lsdisk not installed $lsdiskinfo">&2 |
931 | + fi |
932 | + echo "$footer" |
933 | +fi |
934 | + |
935 | +# Option mounted devices |
936 | +if [ "$mountstat" -ge 1 ]; then |
937 | + echo "---------------------- Mounted devices ... -------------------------------------------------------" |
938 | + grep '^device /dev/' /proc/self/mountstats |
939 | + echo "$footer" |
940 | +fi |
941 | + |
942 | +# Option /etc/fstab entries |
943 | +if [ "$fstab" -ge 1 ]; then |
944 | + echo "---------------------- Entries in \"$etcfstab\" -------------------------------------------------------" |
945 | + grep -v '^#' "$etcfstab" |
946 | + echo "$footer" |
947 | +fi |
948 | + |
949 | +# Option NVRAM - efibootmgr |
950 | +if [ "$efinvram" -ge 1 ]; then |
951 | + echo "---------------------- NVRAM with efibootmgr -----------------------------------------------------" |
952 | + if [ "$(whoami)" = root ]; then |
953 | + if ! efibootmgr --verbose ; then |
954 | + echo 'Or "efibootmgr" ist not installed!' |
955 | + fi |
956 | + else |
957 | + echo " ***** permission denied - you'll need root privileges " >&2 |
958 | + fi |
959 | + echo "$footer" |
960 | +fi |
961 | + |
962 | +# Option startup.nsh |
963 | +if [ "$startup" -ge 1 ]; then |
964 | + echo "---------------------- (ESP) startup.nsh ------------------------------" |
965 | + for efiboot in $(find "${efimount}" -type f -iname startup.nsh | tr ' ' '_'); do |
966 | + efiboot="$(echo "$efiboot" | tr '_' ' ')" |
967 | + echo "---------------------- \"$efiboot\"" |
968 | + cat "${efiboot}" |
969 | + echo |
970 | + done |
971 | + echo "$footer" |
972 | +fi |
973 | + |
974 | + |
975 | +# Option UUID/GUIDs |
976 | +if [ "$grubuids" -ge 1 ]; then |
977 | + echo "---------------------- (ESP) fs_UUID - GUID - unique GUID ----------------------------------------" |
978 | + echo "---------------------- \"${efimount}${efiroot}\"" |
979 | + if [ "$(whoami)" = root ]; then |
980 | + EFIDEVICE="$(grub-probe -t device "${efimount}${efiroot}")" # device: /dev/sdXY |
981 | + efidev="$(echo $EFIDEVICE | sed -ne 's#\(/dev/[a-zA-Z]\+\)\([0-9]\+$\)#\1#p')" # only /dev/alpha e.g. /dev/sda |
982 | + efipart="$(echo $EFIDEVICE | sed -ne 's#\(/dev/[a-zA-Z]\+\)\([0-9]\+$\)#\2#p')" # only numeric e.g. 1 |
983 | + EFIROOT="$(grub-probe -t drive "${efimount}${efiroot}")" # drive: (hdX,parttabY) |
984 | + EFIUUID="$(grub-probe -t fs_uuid "${efimount}${efiroot}")" # UUID of the partition |
985 | + maxlogicalKB="$(expr "$maxlogicalKB" \* 1024)" # max. bytes for scan |
986 | + gptstart=0 |
987 | + if [ "x$efidev" != "x" ]; then |
988 | + # start position of GPT - start position of partition entires in decimal |
989 | + gptstart="$(printf '%d' 0x0$( hexdump -n"$maxlogicalKB" -C "$efidev" | grep "EFI PART"|cut -d ' ' -f1))" |
990 | + fi |
991 | + if [ "$gptstart" -ne 0 ]; then |
992 | + # search for size of a single partition entry (usually 128) |
993 | + gptpartsize="$( hexdump -s"$(expr "$gptstart" + 84)" -n4 -e '1/4 "%d"' "$efidev")" # offset +84 |
994 | + gptstartpart="$(expr "$gptstart" + 512 - "$gptpartsize")" # first partition entry - size |
995 | + gptefipart="$(expr "$efipart" + 0)" # at least 0 |
996 | + gptstartguid="$(expr "$gptefipart" \* "$gptpartsize")" # offset of partition entry (usually 1024) |
997 | + EFIGUID="$(hexdump -s"$(expr "$gptstartpart" + "$gptstartguid")" -n16 -e '/4 "%08x-" /2 "%04x-" /2 "%04x-" 2/1 "%02x" "-" 6/1 "%02x" "\n" ' "$efidev")" |
998 | + EFIGUID2="$(hexdump -s"$(expr "$gptstartpart" + "$gptstartguid" + 16)" -n16 -e '/4 "%08x-" /2 "%04x-" /2 "%04x-" 2/1 "%02x" "-" 6/1 "%02x" "\n" ' "$efidev")" |
999 | + else |
1000 | + echo " ***** no GPT found (searched for $maxlogicalKB bytes)" >&2 |
1001 | + if [ "x$efidev" != "x" ]; then |
1002 | + # List MBR/MPT |
1003 | + echo " MBR: Boot Start-CHS ID End-CHS LBA1 LBA2" >&2 |
1004 | + hexdump -s 446 -n 64 -v -e '1/1 " %02x " 3/1 "|%3u" 1/1 "| %02x " 3/1 "|%3u" 2/4 "|%9u" "|\n"' "$efidev" >&2 |
1005 | + echo |
1006 | + fi |
1007 | + fi |
1008 | + printf 'Device %-11s : UUID = %s Drive = %s \n' "$EFIDEVICE" "$EFIUUID" "$EFIROOT" |
1009 | + printf 'GUID : %s \n' "$EFIGUID" |
1010 | + if [ "x$EFIGUID" != "xc12a7328-f81f-11d2-ba4b-00a0c93ec93b" ]; then |
1011 | + echo " ****** no ESP-GUID: c12a7328-f81f-11d2-ba4b-00a0c93ec93b" >&2 |
1012 | + fi |
1013 | + printf 'GUID unique : %s \n' "$EFIGUID2" |
1014 | + else |
1015 | + echo " ***** permission denied - you'll need root privileges " >&2 |
1016 | + fi |
1017 | + echo "$footer" |
1018 | +fi |
1019 | + |
1020 | +# Option EFI-configuration variables from grubconfig |
1021 | +if [ "$grubconf" -ge 1 ]; then |
1022 | + echo "---------------------- EFI variable in \"$grubconfig\" -----------------------------------------" |
1023 | + grep -Ei '(_EFI_|_EFI=)' "$grubconfig" |
1024 | + echo "$footer" |
1025 | +fi |
1026 | + |
1027 | +# Option ESP-Loader-Entries (*.efi) |
1028 | +if [ "$efiloader" -ge 1 ]; then |
1029 | + echo "---------------------- EFI entries in \"${efimount}${efiroot}\" -------------------------------" |
1030 | + check_disable='not checked' |
1031 | + |
1032 | + # search for entries |
1033 | + i= |
1034 | + for efiboot in $(find "${efimount}${efiroot}" -type f -iname *.efi | tr ' ' '_'); do |
1035 | + i=$(expr $i + 1) |
1036 | + efishort="$(echo "$efimount" | tr ' ' '_')" |
1037 | + efishort="$(echo "$efiboot" | sed -e 's#^'"${efishort}${efiroot}"'/##g')" # cut efimount/efiroot directory |
1038 | + CLASS='--class efi' # Infos for menuentry |
1039 | + CHAINER="$(echo "$efishort" | sed -e 's#\_#\\ #g')" # chainloader without ($root)/EFI/ |
1040 | + TITLE="$(echo $(dirname "$efishort"))" # Menue title |
1041 | + LOADER="$(basename "$CHAINER")" # only the file |
1042 | + if [ "x$grubcheck" = "xyes" ]; then |
1043 | + # check complete file |
1044 | + check_disable='' |
1045 | + fi |
1046 | + check_short="$(echo "$efishort" | tr [a-z] [A-Z] | tr [/.:] '_')" # with /et/default/grub - variables |
1047 | + eval check_var=\$GRUB_DISABLE_EFI_$check_short # export GRUB_DISABLE_EFI_directory/loader.efi |
1048 | + CHECKER="GRUB_DISABLE_EFI_$check_short" |
1049 | + |
1050 | + if [ "x$check_var" = "xtrue" -a "x$grubcheck" = "xyes" ]; then |
1051 | + check_disable='disabled' |
1052 | + else |
1053 | + check_short="$(echo "$TITLE" | tr [a-z] [A-Z]| tr [/.:] '_')" # prepare |
1054 | + check_new='' # for loop |
1055 | + check_old="$(echo "$TITLE" | tr [a-z] [A-Z]| tr [/.:] '_')" # and check directories |
1056 | + while [ "$check_old" != "$check_new" ]; do |
1057 | + check_var="\$GRUB_DISABLE_EFI_$(echo "$check_old" | tr [a-z] [A-Z] | tr [/\ .:] '_')" |
1058 | + eval check_var=$check_var |
1059 | + if [ "x$check_var" = "xtrue" ]; then |
1060 | + if [ "x$grubcheck" = "xyes" ]; then |
1061 | + # found disabled |
1062 | + check_disable='disabled' |
1063 | + fi |
1064 | + # terminat loop |
1065 | + break |
1066 | + fi |
1067 | + check_new="$check_old" # prepare |
1068 | + check_old="$(dirname "$check_old")" # new directory |
1069 | + if [ "$check_old" = "." ]; then |
1070 | + # terminate loop |
1071 | + break |
1072 | + fi |
1073 | + done |
1074 | + fi |
1075 | + printf '%3s. %-8s: %8s %-40s %s %s\n' ${i} "$check_disable" "(U)EFI" "${TITLE} ${LOADER}" ": $(echo $efiboot | tr '_' ' ')" "" |
1076 | + printf '%3s %-8s %8s %-40s %s %s\n' ' ' ' ' ' ' ' ' ' ' " $CHECKER" |
1077 | + |
1078 | + done |
1079 | + echo "$footer" |
1080 | fi |