Skip to content

Commit

Permalink
gui-init: add clean boot check
Browse files Browse the repository at this point in the history
Add a check to determine if first boot after flashing a cleaned
ROM, and prompt user to run the OEM Factory Reset if so

Signed-off-by: Matt DeVillier <[email protected]>
  • Loading branch information
MrChromebox committed Aug 21, 2019
1 parent ba23fb7 commit aab9004
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions initrd/bin/gui-init
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,43 @@ update_totp()
fi
}

clean_boot_check()
{
# assume /boot mounted
if ! grep -q /boot /proc/mounts ; then
return
fi

# check for any kexec files in /boot
kexec_files=`find /boot -name kexec*.txt`
[ ! -z "$kexec_files" ] && return

#check for GPG key in keyring
GPG_KEY_COUNT=`gpg -k 2>/dev/null | wc -l`
[ $GPG_KEY_COUNT -ne 0 ] && return

# check for USB security token
if ! gpg --card-status > /dev/null ; then
return
fi

# OS is installed, no kexec files present, no GPG keys in keyring, security token present
# prompt user to run OEM factory reset
oem-factory-reset \
"Clean Boot Detected - Perform OEM Factory Reset?" "$CONFIG_WARNING_BG_COLOR"
}

# enable USB to load modules for external kb
enable_usb

# ensure /boot is sane and mount it
mount_boot
if detect_boot_device ; then
# /boot device with installed OS found
clean_boot_check
else
# can't determine /boot device or no OS installed,
# so fall back to interactive selection
mount_boot
fi

last_half=X
while true; do
Expand Down

0 comments on commit aab9004

Please sign in to comment.