--msgbox "Unable to mount $CONFIG_USB_BOOT_DEV"1660
fi
fi
fi
}
file_selector(){
FILE=""
FILE_LIST=$1
MENU_MSG=${2:-"Choose the file"}
# create file menu options
if[`cat "$FILE_LIST"| wc -l` -gt 0];then
option=""
while[ -z "$option"]
do
MENU_OPTIONS=""
n=0
whileread option
do
n=`expr $n + 1`
option=$(echo$option| tr " ""_")
MENU_OPTIONS="$MENU_OPTIONS$n${option}"
done < $FILE_LIST
MENU_OPTIONS="$MENU_OPTIONS a Abort"
whiptail --clear --title "Select your File"\
--menu "${MENU_MSG} [1-$n, a to abort]:"201208\
-- $MENU_OPTIONS\
2>/tmp/whiptail || die "Aborting"
option_index=$(cat /tmp/whiptail)
if["$option_index"="a"];then
option="a"
return
fi
option=`head -n $option_index$FILE_LIST| tail -1`
if["$option"=="a"];then
return
fi
done
if[ -n "$option"];then
FILE=$option
fi
else
whiptail $CONFIG_ERROR_BG_COLOR --title 'ERROR: No Files Found'\
--msgbox "No Files found matching the pattern. Aborting."1660
exit1
fi
}
while true;do
unset menu_choice
whiptail --clear --title "GPG Management Menu"\
--menu 'Select the GPG function to perform'209010\
'r'' Add GPG key to running BIOS + reflash'\
'a'' Add GPG key to standalone BIOS image + flash'\
'l'' List GPG keys in your keyring'\
'g'' Generate GPG keys on a USB security token'\
'x'' Exit'\
2>/tmp/whiptail || recovery "GUI menu failed"
menu_choice=$(cat /tmp/whiptail)
case"$menu_choice" in
"x")
exit0
;;
"a")
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"
if["$FILE"==""];then
return
else
ROM=$FILE
fi
cat "$PUBKEY"| gpg --import
#update /.gnupg/trustdb.gpg to ultimately trust all user provided public keys
--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\nafter you reboot.\n\nPress Enter to reboot"1660
umount /media
/bin/reboot
else
exit0
fi
fi
fi
;;
"r")
if(whiptail --title 'GPG public key required'\
--yesno "This 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"
--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\nafter you reboot.\n\nPress Enter to reboot"1660