2023-02-08 21:01:48 +00:00
#!/bin/bash
2018-05-11 21:08:31 +00:00
#
set -e -o pipefail
. /etc/functions
2020-07-10 17:58:32 +00:00
. /etc/gui_functions
2018-12-06 23:24:28 +00:00
. /tmp/config
2018-05-11 21:08:31 +00:00
2023-02-20 16:01:17 +00:00
TRACE "Under /bin/flash-gui.sh"
2023-02-18 17:58:43 +00:00
2018-05-17 22:31:23 +00:00
while true; do
unset menu_choice
2022-11-15 20:11:58 +00:00
whiptail $BG_COLOR_MAIN_MENU --title "Firmware Management Menu" \
2022-11-09 16:51:27 +00:00
--menu "Select the firmware function to perform\n\nRetaining settings copies existing settings to the new firmware:\n* Keeps your GPG keyring\n* Keeps changes to the default /boot device\n\nErasing settings uses the new firmware as-is:\n* Erases any existing GPG keyring\n* Restores firmware to default factory settings\n* Clears out /boot signatures\n\nIf you are just updating your firmware, you probably want to retain\nyour settings." 0 80 10 \
2019-04-19 21:11:45 +00:00
'f' ' Flash the firmware with a new ROM, retain settings' \
'c' ' Flash the firmware with a new ROM, erase settings' \
2018-05-17 22:31:23 +00:00
'x' ' Exit' \
2>/tmp/whiptail || recovery "GUI menu failed"
menu_choice = $( cat /tmp/whiptail)
case " $menu_choice " in
"x" )
exit 0
; ;
2018-05-28 18:38:04 +00:00
f| c )
2021-09-23 17:56:17 +00:00
if ( whiptail $BG_COLOR_WARNING --title 'Flash the BIOS with a new ROM' \
2022-11-05 22:13:05 +00:00
--yesno "You will need to insert a USB drive containing your BIOS image (*.rom or *.tgz).\n\nAfter you select this file, this program will reflash your BIOS.\n\nDo you want to proceed?" 0 80) then
2018-05-17 22:31:23 +00:00
mount_usb
if grep -q /media /proc/mounts ; then
2022-11-05 22:13:05 +00:00
find /media ! -path '*/\.*' -type f \( -name '*.rom' -o -name '*.tgz' \) | sort > /tmp/filelist.txt
2018-05-17 22:31:23 +00:00
file_selector "/tmp/filelist.txt" "Choose the ROM to flash"
if [ " $FILE " = = "" ] ; then
return
else
ROM = $FILE
fi
2021-09-23 17:56:17 +00:00
if ( whiptail $BG_COLOR_WARNING --title 'Flash ROM?' \
2022-11-09 16:51:27 +00:00
--yesno " This will replace your current ROM with:\n\n ${ ROM # "/media/" } \n\nDo you want to proceed? " 0 80) then
2018-05-28 18:38:04 +00:00
if [ " $menu_choice " = = "c" ] ; then
2019-02-08 17:38:38 +00:00
/bin/flash.sh -c " $ROM "
2019-08-28 15:47:53 +00:00
# after flash, /boot signatures are now invalid so go ahead and clear them
if ls /boot/kexec* >/dev/null 2>& 1 ; then
(
mount -o remount,rw /boot 2>/dev/null
rm /boot/kexec* 2>/dev/null
mount -o remount,ro /boot 2>/dev/null
)
fi
2018-05-28 18:38:04 +00:00
else
2019-02-08 17:38:38 +00:00
/bin/flash.sh " $ROM "
2018-05-28 18:38:04 +00:00
fi
2018-05-17 22:31:23 +00:00
whiptail --title 'ROM Flashed Successfully' \
2022-11-09 16:51:27 +00:00
--msgbox " ${ ROM # "/media/" } \n\nhas been flashed successfully.\n\nPress Enter to reboot\n " 0 80
2018-05-17 22:31:23 +00:00
umount /media
/bin/reboot
else
exit
fi
fi
2018-05-11 21:08:31 +00:00
fi
2018-05-17 22:31:23 +00:00
; ;
esac
2018-05-11 21:08:31 +00:00
2018-05-17 22:31:23 +00:00
done
2018-05-11 21:08:31 +00:00
exit 0