You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: initrd/bin/flash-gui.sh
+51-53Lines changed: 51 additions & 53 deletions
Original file line number
Diff line number
Diff line change
@@ -25,67 +25,65 @@ while true; do
25
25
menu_choice=$(cat /tmp/whiptail)
26
26
27
27
case"$menu_choice"in
28
-
"x")
29
-
exit 0
28
+
"x")
29
+
exit 0
30
30
;;
31
-
f|c )
32
-
if (whiptail $BG_COLOR_WARNING --title 'Flash the BIOS with a new ROM' \
33
-
--yesno "You will need to insert a USB drive containing your BIOS image (*.romor *.tgz).\n\nAfter you select this file, this program will reflash your BIOS.\n\nDo you want to proceed?" 0 80) then
34
-
mount_usb
35
-
if grep -q /media /proc/mounts;then
36
-
find /media ! -path '*/\.*' -type f \( -name '*.rom' -o -name '*.tgz' -o -type f -name '*.npf'\)| sort >/tmp/filelist.txt
37
-
file_selector "/tmp/filelist.txt""Choose the ROM to flash"
38
-
if [ "$FILE"=="" ];then
39
-
exit 1
40
-
else
41
-
ROM=$FILE
42
-
fi
31
+
f | c)
32
+
if (whiptail $BG_COLOR_WARNING --title 'Flash the BIOS with a new ROM' \
33
+
--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
34
+
mount_usb
35
+
if grep -q /media /proc/mounts;then
36
+
find /media ! -path '*/\.*' -type f \( -name '*.rom' -o -name '*.tgz' -o -type f -name '*.npf'\)| sort >/tmp/filelist.txt
37
+
file_selector "/tmp/filelist.txt""Choose the ROM to flash"
38
+
if [ "$FILE"=="" ];then
39
+
exit 1
40
+
else
41
+
ROM=$FILE
42
+
fi
43
43
44
-
# is a .npf provided?
45
-
if [ -z"${ROM##*.npf}" ];then
46
-
# unzip to /tmp/verified_rom
47
-
mkdir /tmp/verified_rom
48
-
unzip $ROM -d /tmp/verified_rom
49
-
# check file integrity
50
-
if (cd /tmp/verified_rom/ && sha256sum -cs /tmp/verified_rom/sha256sum.txt) ;then
if! (whiptail $CONFIG_ERROR_BG_COLOR --title 'Flash ROM without integrity check?' \
60
-
--yesno "You have provided a *.rom file. The integrity of the file can not be\nchecked 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
61
-
exit
62
-
fi
55
+
whiptail --title 'ROM Integrity Check Failed! ' \
56
+
--msgbox "$ROM integrity check failed. Did not flash.\n\nPlease check your file (e.g. re-download).\n" 16 60
57
+
exit
63
58
fi
64
-
65
-
if (whiptail $BG_COLOR_WARNING --title 'Flash ROM?' \
66
-
--yesno "This will replace your current ROM with:\n\n${ROM#"/media/"}\n\nDo you want to proceed?" 0 80) then
67
-
if [ "$menu_choice"=="c" ];then
68
-
/bin/flash.sh -c "$ROM"
69
-
# after flash, /boot signatures are now invalid so go ahead and clear them
70
-
if ls /boot/kexec*>/dev/null 2>&1;then
71
-
(
72
-
mount -o remount,rw /boot 2>/dev/null
73
-
rm /boot/kexec*2>/dev/null
74
-
mount -o remount,ro /boot 2>/dev/null
75
-
)
76
-
fi
77
-
else
78
-
/bin/flash.sh "$ROM"
79
-
fi
80
-
whiptail --title 'ROM Flashed Successfully' \
81
-
--msgbox "${ROM#"/media/"}\n\nhas been flashed successfully.\n\nPress Enter to reboot\n" 0 80
82
-
umount /media
83
-
/bin/reboot
84
-
else
59
+
else
60
+
# a rom file was provided. exit if we shall not proceed
61
+
ROM_HASH=$(sha256sum "$ROM"| awk '{print $1}')|| die "Failed to hash ROM file"
62
+
if! (whiptail $CONFIG_ERROR_BG_COLOR --title 'Flash ROM without integrity check?' \
63
+
--yesno "You have provided a *.rom file. The integrity of the file can not be\nchecked automatically for this file type.\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
85
64
exit
86
65
fi
87
66
fi
67
+
68
+
if [ "$menu_choice"=="c" ];then
69
+
/bin/flash.sh -c "$ROM"
70
+
# after flash, /boot signatures are now invalid so go ahead and clear them
71
+
if ls /boot/kexec*>/dev/null 2>&1;then
72
+
(
73
+
mount -o remount,rw /boot 2>/dev/null
74
+
rm /boot/kexec*2>/dev/null
75
+
mount -o remount,ro /boot 2>/dev/null
76
+
)
77
+
fi
78
+
else
79
+
/bin/flash.sh "$ROM"
80
+
fi
81
+
whiptail --title 'ROM Flashed Successfully' \
82
+
--msgbox "${ROM#"/media/"}\n\nhas been flashed successfully.\n\nPress Enter to reboot\n" 0 80
0 commit comments