Skip to content

Commit 2a8deef

Browse files
committed
Added Error Handling to GetSB() for any future update errors to mokutil.
1 parent eed1257 commit 2a8deef

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

system-info

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#### Variables
3434
########################################################################
3535
# Versioning
36-
version="Version: 01.00-09, Script Date: 2022.06.01"
36+
version="Version: 01.00-10, Script Date: 2022.06.03"
3737
#md5_sum=$(md5sum $sname | sed 's/system.*//g' )
3838
arg1=$1
3939
arg2=$2
@@ -446,44 +446,55 @@ function GetSb()
446446
{
447447
# Gets SafeBoot Info from UEFI BIOS or if not UEFI capable. Called once by GetDMI().
448448
# Warns user if mokutil was not present.
449-
#echo -e " --- SecureBoot Status from 'mokutil --sb-state':"
449+
echo -e " --- SecureBoot Status from 'mokutil':"
450450

451451
## Bug found on some machines concerning the '--sb-state' option switch on 2022.06.01.
452452
# Shortened to '--sb' (undocumented option switch)
453+
# 'mokuitl' Bug was resolved within days...
454+
# 2022.06.02, Added fallack error handling for fallback to alternate option flag...
455+
# using the documented option flag as the primary method.
453456
if [ $check_mokutil -eq 0 ]
454457
then
455458
echo -e "\tThis would check / have checked if SecureBoot was enabled or not, "
456459
echo -e "\tand checks if the system BIOS was UEFI or Lagacy only BIOS, "
457460
echo -e "\tbut package mokutil was not installed. If you would like to check"
458461
echo -e "\tthis information, please install 'mokutil' and rerun script."
459462
else
463+
# Added this error handling because of a bug on a 'mokutil', that was resolved
464+
# but showed that an error was possible from a faulty update of this utility.
465+
error_mokutil=$(mokutil --sb-state 2>&1 )
466+
if [[ "$error_mokutil" == *"mokutil: unrecognized option '--sb-state​'"* ]]
467+
then
468+
mokutil_cmd=$(mokutil --sb 2>&1 )
469+
error_mokutil=$mokutil_cmd
470+
else
471+
mokutil_cmd=$(mokutil --sb-state 2>&1 )
472+
fi
460473
# For Legacy only BIOS, returns error: "EFI variables are not supported on this system"
461-
#error_mokutil=$(mokutil --sb-state 2>&1 )
462-
error_mokutil=$(mokutil --sb 2>&1 )
463474
if [[ "$error_mokutil" == *"EFI variables"* ]]
464475
then
465476
echo -e "$error_mokutil"
466477
elif [[ "$error_mokutil" == *"Command 'mokutil' not found"* ]] #
467-
then
468-
echo -e "\tThis would check / have checked if SecureBoot was enabled or not, "
469-
echo -e "\t and checks if the system BIOS was UEFI or Lagacy only BIOS, "
470-
echo -e "\tbut package mokutil was not installed. If you would like to check"
471-
echo -e "\tthis information, please install 'mokutil' and rerun script."
478+
then
479+
echo -e "\tThis would check / have checked if SecureBoot was enabled or not, "
480+
echo -e "\t and checks if the system BIOS was UEFI or Lagacy only BIOS, "
481+
echo -e "\tbut package mokutil was not installed. If you would like to check"
482+
echo -e "\tthis information, please install 'mokutil' and rerun script."
472483
else
473-
#sb_state=$(mokutil --sb-state 2>&1 )
474-
sb_state=$(mokutil --sb 2>&1 )
484+
sb_state=$mokutil_cmd
475485
debug "sb_state: $sb_state" 1
476486
if [[ $sb_state == "Failed to read SecureBoot" ]]
477487
then
478488
sb_disabled="SecureBoot: Disabled"
479489
#printf "%-20s %s\n" ${sb_disabled/ /: }
480490
echo -e "$sb_disabled"
481491
else
482-
# These are the four known messages returned from UEFI
492+
# These are the known messages returned from mokutil
483493
# This system doesn't support Secure Boot
484494
# Secure Boot is enabled
485495
# Failed to read SecureBoot
486496
# Platform is in Setup Mode
497+
# mokutil: unrecognized option '--sb-state​'
487498
#
488499
#printf "%-20s %s\n" ${sb_state/ /: }
489500
echo -e "$sb_state"

0 commit comments

Comments
 (0)