diff options
author | Luiz Angelo Daros de Luca <luizluca@gmail.com> | 2022-10-19 23:27:52 -0300 |
---|---|---|
committer | Rafał Miłecki <rafal@milecki.pl> | 2024-02-19 12:41:40 +0100 |
commit | 700907bc6371939256129b00c1324f3a5942f007 (patch) | |
tree | 66825bdadd0e044cb47f264edeb1e5e9c0750fce /package | |
parent | 14ac91c68c0e17b8ec705256f0d9092bfb899466 (diff) | |
download | openwrt-700907bc6371939256129b00c1324f3a5942f007.tar.gz openwrt-700907bc6371939256129b00c1324f3a5942f007.tar.bz2 openwrt-700907bc6371939256129b00c1324f3a5942f007.zip |
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 <luizluca@gmail.com>
Diffstat (limited to 'package')
-rwxr-xr-x | package/base-files/files/sbin/sysupgrade | 10 |
1 files changed, 6 insertions, 4 deletions
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" |