From patchwork Sun Nov 17 21:57:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: fff-web: Remove old firmware binaries on POST From: Fabian Blaese X-Patchwork-Id: 1214 Message-Id: <20191117215734.1536845-1-fabian@blaese.de> To: franken-dev@freifunk.net Date: Sun, 17 Nov 2019 22:57:34 +0100 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 --- 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='Router wird zurückgesetzt und anschließend neugestartet...' fi elif [ "$POST_upgrade" != "" ] ; then + # remove firmware files from previous tries + rm -f /tmp/uploadedfw.bin + # upgrade if [ ! -f "$HASERL_firmware_path" ] ; then MSG='Firmware Datei nicht gefunden!' @@ -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 "" fi %>