summaryrefslogtreecommitdiffhomepage
path: root/libs/luci-lib-nixio/root
diff options
context:
space:
mode:
authorXiang W <wxjstz@126.com>2023-12-05 04:48:19 +0800
committerGitHub <noreply@github.com>2023-12-04 21:48:19 +0100
commitc2f679962ddf7f6545adacfcf3068370825c43a9 (patch)
tree13dc2bc88c97adb2a4e3c88770fc5614e23cdfc2 /libs/luci-lib-nixio/root
parent830c0ee6bdec7ef727b4caf913dcf30c084eb305 (diff)
luci-lib-nixio: Fix add_luci_conffiles adding duplicate files (#6568)
* luci-lib-nixio: Fix add_luci_conffiles adding duplicate files add_luci_conffiles does not check whether the file already exists when adding the file, which may result in redundant backups in the sysupgrade backup. Signed-off-by: Xiang W <wxjstz@126.com>
Diffstat (limited to 'libs/luci-lib-nixio/root')
-rw-r--r--libs/luci-lib-nixio/root/lib/upgrade/luci-add-conffiles.sh17
1 files changed, 14 insertions, 3 deletions
diff --git a/libs/luci-lib-nixio/root/lib/upgrade/luci-add-conffiles.sh b/libs/luci-lib-nixio/root/lib/upgrade/luci-add-conffiles.sh
index 77399b9872..d5117f9d89 100644
--- a/libs/luci-lib-nixio/root/lib/upgrade/luci-add-conffiles.sh
+++ b/libs/luci-lib-nixio/root/lib/upgrade/luci-add-conffiles.sh
@@ -1,15 +1,26 @@
add_luci_conffiles()
{
+ add_luci_conffiles_helper()
+ {
+ [ ! -f "$1" ] && return
+ grep -q "$1" "$2" && return
+ echo "$1" >> "$2"
+ }
+
local filelist="$1"
# save ssl certs
if [ -d /etc/nixio ]; then
- find /etc/nixio -type f >> $filelist
+ find /etc/nixio -type f | while read ff; do
+ add_luci_conffiles_helper "$ff" "$filelist"
+ done
fi
# save uhttpd certs
- [ -f "/etc/uhttpd.key" ] && echo /etc/uhttpd.key >> $filelist
- [ -f "/etc/uhttpd.crt" ] && echo /etc/uhttpd.crt >> $filelist
+ add_luci_conffiles_helper /etc/uhttpd.key "$filelist"
+ add_luci_conffiles_helper /etc/uhttpd.crt "$filelist"
+
+ unset -f add_luci_conffiles_helper
}
sysupgrade_init_conffiles="$sysupgrade_init_conffiles add_luci_conffiles"