--menu 'Select the BIOS function to perform'209010\
'f'' Flash the BIOS with a new ROM'\
'a'' Add GPG key to BIOS image'\
'r'' Add GPG key to running BIOS'\
'x'' Exit'\
2>/tmp/whiptail || recovery "GUI menu failed"
menu_choice=$(cat /tmp/whiptail)
case"$menu_choice" in
"x")
exit0
;;
"f")
if(whiptail --title 'Flash the BIOS with a new ROM'\
--yesno "This requires you insert a USB drive containing:\n* Your BIOS image (*.rom)\n\nAfter you select this file, this program will reflash your BIOS\n\nDo you want to proceed?"16 90)then
mount_usb
if grep -q /media /proc/mounts ;then
find /media -name '*.rom' > /tmp/filelist.txt
file_selector "/tmp/filelist.txt""Choose the ROM to flash"
if["$FILE"==""];then
return
else
ROM=$FILE
fi
if(whiptail --title 'Flash ROM?'\
--yesno "This will replace your old ROM with $ROM\n\nDo you want to proceed?"16 90)then
/bin/flash.sh $ROM
whiptail --title 'ROM Flashed Successfully'\
--msgbox "$ROM flashed successfully. Press Enter to reboot"1660
if(whiptail --title 'ROM and GPG public key required'\
--yesno "This requires you insert a USB drive containing:\n* Your GPG public key (*.key or *.asc)\n* Your BIOS image (*.rom)\n\nAfter you select these files, this program will reflash your BIOS\n\nDo you want to proceed?"16 90)then
mount_usb
if grep -q /media /proc/mounts ;then
find /media -name '*.key' > /tmp/filelist.txt
find /media -name '*.asc' >> /tmp/filelist.txt
file_selector "/tmp/filelist.txt""Choose your GPG public key"
if["$FILE"==""];then
return
else
PUBKEY=$FILE
fi
find /media -name '*.rom' > /tmp/filelist.txt
file_selector "/tmp/filelist.txt""Choose the ROM to load your key onto"
cbfs -o /tmp/gpg-gui.rom -a "heads/initrd/.gnupg/trustdb.gpg" -f /.gnupg/trustdb.gpg
if(whiptail --title 'Flash ROM?'\
--yesno "This will replace your old ROM with $ROM\n\nDo you want to proceed?"16 90)then
/bin/flash.sh /tmp/gpg-gui.rom
whiptail --title 'ROM Flashed Successfully'\
--msgbox "$ROM flashed successfully.\n\nIf your keys have changed, be sure to re-sign all files in /boot after you reboot.\n\nPress Enter to reboot"1660
--yesno "Flashing the running BIOS requires you insert a USB drive containing:\n* Your GPG public key (*.key or *.asc)\n\nAfter you select this file, this program will copy and reflash your BIOS\n\nDo you want to proceed?"16 90)then
mount_usb
if grep -q /media /proc/mounts ;then
find /media -name '*.key' > /tmp/filelist.txt
find /media -name '*.asc' >> /tmp/filelist.txt
file_selector "/tmp/filelist.txt""Choose your GPG public key"
cbfs -o /tmp/gpg-gui.rom -a "heads/initrd/.gnupg/trustdb.gpg" -f /.gnupg/trustdb.gpg
if(whiptail --title 'Update ROM?'\
--yesno "This will reflash your BIOS with the updated version\n\nDo you want to proceed?"16 90)then
/bin/flash.sh /tmp/gpg-gui.rom
whiptail --title 'BIOS Updated Successfully'\
--msgbox "BIOS updated successfully.\n\nIf your keys have changed, be sure to re-sign all files in /boot after you reboot.\n\nPress Enter to reboot"1660