From: Luiz Angelo Daros de Luca Date: Thu, 20 Oct 2022 02:27:52 +0000 (-0300) Subject: base-files: sysupgrade: always cleanup after backups X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=700907bc6371939256129b00c1324f3a5942f007;p=openwrt%2Fstaging%2Fnbd.git base-files: sysupgrade: always cleanup after backups When tar was failing, it was exiting immediately. Some files and the tmpfs mount (-k) would remain breaking the next backup attempt. Also remove redundant $? from exit builtin call as exit already returns the last command exit code when called. Signed-off-by: Luiz Angelo Daros de Luca --- diff --git a/package/base-files/files/sbin/sysupgrade b/package/base-files/files/sbin/sysupgrade index eba11ce78e..43e129e1d7 100755 --- a/package/base-files/files/sbin/sysupgrade +++ b/package/base-files/files/sbin/sysupgrade @@ -259,10 +259,10 @@ do_save_conffiles() { [ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V="" sed -i -e 's,^/,,' "$CONFFILES" tar c${TAR_V}zf "$conf_tar" -C / -T "$CONFFILES" - if [ "$?" -ne 0 ]; then + local err=$? + if [ "$err" -ne 0 ]; then echo "Failed to create the configuration backup." rm -f "$conf_tar" - exit 1 fi [ "$UMOUNT_ETCBACKUP_DIR" -eq 1 ] && { @@ -270,6 +270,8 @@ do_save_conffiles() { rm -rf "$RAMFS" } rm -f "$CONFFILES" + + return "$err" } if [ $CONF_BACKUP_LIST -eq 1 ]; then @@ -282,7 +284,7 @@ fi if [ -n "$CONF_BACKUP" ]; then do_save_conffiles "$CONF_BACKUP" - exit $? + exit fi if [ -n "$CONF_RESTORE" ]; then @@ -351,7 +353,7 @@ if [ -n "$CONF_IMAGE" ]; then get_image "$CONF_IMAGE" "cat" > "$CONF_TAR" export SAVE_CONFIG=1 elif ask_bool $SAVE_CONFIG "Keep config files over reflash"; then - [ $TEST -eq 1 ] || do_save_conffiles "$CONF_TAR" + [ $TEST -eq 1 ] || do_save_conffiles "$CONF_TAR" || exit export SAVE_CONFIG=1 else [ $TEST -eq 1 ] || rm -f "$CONF_TAR"