diff --git a/luci-app-amlogic/Makefile b/luci-app-amlogic/Makefile index b5763d731..a53cfe3a7 100644 --- a/luci-app-amlogic/Makefile +++ b/luci-app-amlogic/Makefile @@ -16,7 +16,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-amlogic -PKG_VERSION:=3.1.204 +PKG_VERSION:=3.1.206 PKG_RELEASE:=1 PKG_LICENSE:=GPL-2.0 License diff --git a/luci-app-amlogic/luasrc/model/cbi/amlogic/amlogic_backup.lua b/luci-app-amlogic/luasrc/model/cbi/amlogic/amlogic_backup.lua index d523811e0..c6cd891a4 100644 --- a/luci-app-amlogic/luasrc/model/cbi/amlogic/amlogic_backup.lua +++ b/luci-app-amlogic/luasrc/model/cbi/amlogic/amlogic_backup.lua @@ -41,8 +41,7 @@ my.render = function(self, section, scope) end my.write = function(self, section, scope) - local handle = io.popen("[[ -s /etc/amlogic_backup_list.conf ]] || sed -n \"/BACKUP_LIST='/,/.*'$/p\" /usr/sbin/openwrt-backup | tr -d \"BACKUP_LIST=|'\" >/etc/amlogic_backup_list.conf 2>/dev/null") - local result = handle:read("*a") + local handle = io.popen("[[ -s /etc/amlogic_backup_list.conf ]] || sed -n \"/BACKUP_LIST='/,/.*'$/p\" /usr/sbin/openwrt-backup | sed -e \"s/BACKUP_LIST=\\(.*\\)/\\1/; s/'//g; s/\\\\\\\\//g; s/ //g\" > /etc/amlogic_backup_list.conf 2>/dev/null") handle:close() luci.http.redirect(luci.dispatcher.build_url("admin", "system", "amlogic", "backuplist")) end diff --git a/luci-app-amlogic/luasrc/model/cbi/amlogic/amlogic_backuplist.lua b/luci-app-amlogic/luasrc/model/cbi/amlogic/amlogic_backuplist.lua index 7ca9c752d..e74307636 100644 --- a/luci-app-amlogic/luasrc/model/cbi/amlogic/amlogic_backuplist.lua +++ b/luci-app-amlogic/luasrc/model/cbi/amlogic/amlogic_backuplist.lua @@ -15,28 +15,19 @@ function remove_spaces(value) return value end --- Add ' \' to the end of each line except the last line -function check_backslash(str) +-- Remove backslash at the end of each line +function remove_backslash_at_end(value) local lines = {} - for line in str:gmatch("[^\r\n]+") do + for line in value:gmatch("[^\r\n]+") do + line = line:gsub("%s*\\%s*$", "") table.insert(lines, line) end - - local lastLineIndex = #lines - for i, line in ipairs(lines) do - if i < lastLineIndex then - if not line:match("%s+\\%s*$") then - lines[i] = line .. " \\" - end - end - end - return table.concat(lines, "\n") end local f = SimpleForm("customize", translate("Backup Configuration - Custom List"), - translate("Please maintain the format of the backup list. Except for the last line, each line should end with ' \\' character.")) + translate("Write one configuration item per line, and directories should end with a /.")) local o = f:field(Value, "_custom") @@ -46,13 +37,13 @@ o.rows = 30 function o.cfgvalue(self, section) local readconf = fs.readfile(backup_list_conf) local value = remove_spaces(readconf) - local value = check_backslash(value) + local value = remove_backslash_at_end(value) return value end function o.write(self, section, value) local value = remove_spaces(value) - local value = check_backslash(value) + local value = remove_backslash_at_end(value) fs.writefile(backup_list_conf, value) luci.http.redirect(luci.dispatcher.build_url("admin", "system", "amlogic", "backup")) end diff --git a/luci-app-amlogic/po/zh-cn/amlogic.po b/luci-app-amlogic/po/zh-cn/amlogic.po index 36d851d2d..aeb9f7509 100644 --- a/luci-app-amlogic/po/zh-cn/amlogic.po +++ b/luci-app-amlogic/po/zh-cn/amlogic.po @@ -269,8 +269,8 @@ msgstr "打开列表" msgid "Backup Configuration - Custom List" msgstr "备份配置 - 自定义列表" -msgid "Please maintain the format of the backup list. Except for the last line, each line should end with ' \\' character." -msgstr "请保持备份列表的格式,除最后一行外,每行以 ' \\' 结尾。" +msgid "Write one configuration item per line, and directories should end with a /." +msgstr "每行写一个配置项,目录需要以/结尾。" msgid "Restore Backup:" msgstr "恢复备份:" diff --git a/luci-app-amlogic/root/usr/sbin/openwrt-backup b/luci-app-amlogic/root/usr/sbin/openwrt-backup index 3c5062cb0..0701ce929 100755 --- a/luci-app-amlogic/root/usr/sbin/openwrt-backup +++ b/luci-app-amlogic/root/usr/sbin/openwrt-backup @@ -14,7 +14,9 @@ BACKUP_FILE="${BACKUP_DIR}/${BACKUP_NAME}" # Customize backup list backup_list_conf="/etc/amlogic_backup_list.conf" if [[ -s "${backup_list_conf}" ]]; then - BACKUP_LIST="$(cat ${backup_list_conf} 2>/dev/null)" + while IFS= read -r line; do + BACKUP_LIST+="${line} " + done < "${backup_list_conf}" else BACKUP_LIST='./etc/AdGuardHome.yaml \ ./etc/amlogic_backup_list.conf \