fff-web: Remove old firmware binaries on POST

Submitted by Fabian Blaese on Nov. 17, 2019, 9:57 p.m.

Details

Message ID 20191117215734.1536845-1-fabian@blaese.de
State Rejected
Headers show

Commit Message

Fabian Blaese Nov. 17, 2019, 9:57 p.m.
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@blaese.de>
---
 src/packages/fff/fff-web/files/www/ssl/cgi-bin/upgrade.html | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

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&uuml;ckgesetzt und anschlie&szlig;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
 %>

Comments

Fabian Blaese Nov. 17, 2019, 10:24 p.m.
Eigentlich könnten wir uns das löschen auch sparen. Spätestens zum Updatezeitpunkt kann ja eh maximal eine Datei existieren..

Gruß
Fabian