Provide better error feedback when upgrades fail

This commit is contained in:
Tim Wilkinson 2023-01-05 16:37:39 -08:00 committed by Joe AE6XE
parent d2364b83ad
commit 5214d35fcd
2 changed files with 18 additions and 8 deletions

View File

@ -5,11 +5,20 @@
include /lib/upgrade/
if (eval platform_check_image "$*")
if $(platform_check_image "$*" > /dev/null 2>&1)
then
return 0;
else
return 1;
json=$(/usr/libexec/validate_firmware_image "$*" 2> /dev/null)
if [ "$(echo "$json" | jsonfilter -e '@.value')" = "true" ]; then
return 0;
fi
if [ "$(echo "$json" | jsonfilter -e '@.tests.fwtool_signature')" = "false" ]; then
echo "firmware signature failed"
return 1;
fi
if [ "$(echo "$json" | jsonfilter -e '@.tests.fwtool_device_match')" = "false" ]; then
echo "firmware device match failed";
return 1
fi
fi
echo "platform check image failed";
return 1

View File

@ -348,9 +348,10 @@ if parms.button_ul_fw and nixio.fs.stat("/tmp/web/upload/file") then
-- drop the page cache to take pressure off tmps when checking the firmware
write_all("/proc/sys/vm/drop_caches", "3")
-- check firmware header
if os.execute("/usr/local/bin/firmwarecheck.sh " .. tmpdir .. "/firmware > /dev/null 2>&1") ~= 0 then
local fcheck = capture("/usr/local/bin/firmwarecheck.sh " .. tmpdir .. "/firmware")
if fcheck ~= "" then
fwout("Firmware CANNOT be updated")
fwout("firmware file is not valid")
fwout("firmware file is not valid: " .. fcheck)
fw_install = false
nixio.fs.remove(tmpdir .. "/firmware")
if os.execute("/usr/local/bin/uploadctlservices restore > /dev/null 2>&1") ~= 0 then