Skip to content

Commit 722121b

Browse files
committed
flash-gui.sh: single prompt for non npf file showing hash of rom file, correcting whiptail window size to be automatic, not fixed
1 parent 95d3e4c commit 722121b

File tree

1 file changed

+24
-31
lines changed

1 file changed

+24
-31
lines changed

initrd/bin/flash-gui.sh

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ while true; do
3333
;;
3434
f | c)
3535
if (whiptail $BG_COLOR_WARNING --title 'Flash the BIOS with a new ROM' \
36-
--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
36+
--yesno "You will need to insert a USB drive containing your BIOS image (*.rom, *.npf or *.tgz).\n\nAfter you select this file, this program will reflash your BIOS.\n\nDo you want to proceed?" 0 80); then
3737
mount_usb
3838
if grep -q /media /proc/mounts; then
3939
find /media ! -path '*/\.*' -type f \( -name '*.rom' -o -name '*.tgz' -o -type f -name '*.npf' \) | sort >/tmp/filelist.txt
@@ -60,41 +60,34 @@ while true; do
6060
exit
6161
fi
6262
else
63-
# exit if we shall not proceed
63+
# a rom file is provided. exit if we shall not proceed
64+
ROM_HASH=$(sha256sum "$ROM" | awk '{print $1}') || die "Failed to hash ROM file"
6465
if ! (whiptail $CONFIG_ERROR_BG_COLOR --title 'Flash ROM without integrity check?' \
65-
--yesno "You have provided a *.rom file. The integrity of the file can not be\nchecked automatically for this file.\nIf you do not know how to check the file integrity yourself,\nyou should use a *.npf file instead.\n\nIf the file is damaged, you will not be able to boot anymore.\nDo you want to proceed flashing without file integrity check?" 16 60); then
66+
--yesno "You have provided a *.rom file. The integrity of the file can not be\nchecked automatically for this file.\n\nROM: $ROM\nSHA256SUM: $ROM_HASH\n\nIf you do not know how to check the file integrity yourself,\nyou should use a *.npf file instead.\n\nIf the file is damaged, you will not be able to boot anymore.\nDo you want to proceed flashing without file integrity check?" 0 80); then
6667
exit
67-
fi
68+
else
69+
# then user validated sha256sum manually from has on screen
70+
ROM_INTEGRITY_VERIFIED=1
71+
fi
72+
fi
73+
74+
if [ "$ROM_INTEGRITY_VERIFIED" == "1" ]; then
75+
/bin/flash.sh -c -i "$ROM"
76+
else
77+
/bin/flash.sh -c "$ROM"
6878
fi
6979

70-
if (whiptail $BG_COLOR_WARNING --title 'Flash ROM?' \
71-
--yesno "This will replace your current ROM with:\n\n${ROM#"/media/"}\n\nDo you want to proceed?" 0 80); then
72-
if [ "$menu_choice" == "c" ]; then
73-
# flag is passed to flash.sh to erase settings while stating if rom is verified or not
74-
if [ "$ROM_INTEGRITY_VERIFIED" == "1" ]; then
75-
/bin/flash.sh -c -i "$ROM"
76-
else
77-
/bin/flash.sh -c "$ROM"
78-
fi
80+
# after flash, /boot signatures are now invalid so go ahead and clear them
81+
if ls /boot/kexec* >/dev/null 2>&1; then
82+
(
83+
mount -o remount,rw /boot 2>/dev/null
84+
rm /boot/kexec* 2>/dev/null
85+
mount -o remount,ro /boot 2>/dev/null
86+
)
87+
fi
7988

80-
# after flash, /boot signatures are now invalid so go ahead and clear them
81-
if ls /boot/kexec* >/dev/null 2>&1; then
82-
(
83-
mount -o remount,rw /boot 2>/dev/null
84-
rm /boot/kexec* 2>/dev/null
85-
mount -o remount,ro /boot 2>/dev/null
86-
)
87-
fi
88-
else
89-
if [ "$ROM_INTEGRITY_VERIFIED" == "1" ]; then
90-
# flag is passed to flash.sh to retain settings while stating if rom is verified or not
91-
/bin/flash.sh "$ROM" -i
92-
else
93-
/bin/flash.sh "$ROM"
94-
fi
95-
fi
96-
whiptail --title 'ROM Flashed Successfully' \
97-
--msgbox "${ROM#"/media/"}\n\nhas been flashed successfully.\n\nPress Enter to reboot\n" 0 80
89+
if (whiptail --title 'ROM Flashed Successfully' \
90+
--msgbox "${ROM#"/media/"}\n\nhas been flashed successfully.\n\nPress Enter to reboot\n" 0 80); then
9891
umount /media
9992
/bin/reboot
10093
else

0 commit comments

Comments
 (0)