[PATCH] fff-web: Remove old firmware binaries on POST

Fabian Bläse fabian at blaese.de
So Nov 17 22:57:34 CET 2019


For some reason sysupgrade seems to return exit status != 0
even on successful calls. As the binary is removed if
sysupgrade exists with a failure status, it is possible that
it got deleted while a sysupgrade has been in progress.

Therefore, instead of deleting the firmware on specific exit
status of sysupgrade, the binary is removed on subsequent
binary uploads.

Signed-off-by: Fabian Bläse <fabian at blaese.de>
---
 src/packages/fff/fff-web/files/www/ssl/cgi-bin/upgrade.html | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/packages/fff/fff-web/files/www/ssl/cgi-bin/upgrade.html b/src/packages/fff/fff-web/files/www/ssl/cgi-bin/upgrade.html
index e2b0a57..0608d9b 100755
--- a/src/packages/fff/fff-web/files/www/ssl/cgi-bin/upgrade.html
+++ b/src/packages/fff/fff-web/files/www/ssl/cgi-bin/upgrade.html
@@ -10,6 +10,9 @@ if [ "$REQUEST_METHOD" = "POST" ] ; then
 			MSG='<span class="green">Router wird zurückgesetzt und anschließend neugestartet...</span>'
 		fi
 	elif [ "$POST_upgrade" != "" ] ; then
+		# remove firmware files from previous tries
+		rm -f /tmp/uploadedfw.bin
+
 		# upgrade
 		if [ ! -f "$HASERL_firmware_path" ] ; then
 			MSG='<span class="red">Firmware Datei nicht gefunden!</span>'
@@ -74,7 +77,7 @@ elif [ "$do_sysupgrade" = "1" ] ; then
 	echo 3 > /proc/sys/vm/drop_caches
 	echo "# sysupgrade $args /tmp/uploadedfw.bin"
 	mv -f "$HASERL_firmware_path" /tmp/uploadedfw.bin
-	sysupgrade $args /tmp/uploadedfw.bin || rm /tmp/uploadedfw.bin
+	sysupgrade $args /tmp/uploadedfw.bin
 	echo "</pre>"
 fi
 %>
-- 
2.24.0



Mehr Informationen über die Mailingliste franken-dev