mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-10-30 11:25:13 +08:00
update 2026-08-30 00:04:48
This commit is contained in:
1 parent
8e9cbe68d9
commit
a93b4d6f7f
1952 files changed
+106
-1523040
No files matched your search
@@ -140,18 +140,6 @@ local function http_write_json_error(data)
|
||||
http.write(jsonStringify({code = 0, data = data}))
|
||||
end
|
||||
|
||||
function reset_config()
|
||||
uci:revert(c_config)
|
||||
luci.sys.call("echo '' > /tmp/log/passwall.log")
|
||||
luci.sys.call('/etc/init.d/passwall stop')
|
||||
if luci.sys.call('[ -s "/usr/share/passwall/0_default_config" ]') == 0 then
|
||||
luci.sys.call('cp -f /usr/share/passwall/0_default_config /etc/config/passwall')
|
||||
api.log(" * 恢复默认配置成功。")
|
||||
else
|
||||
api.log(" * 找不到默认配置文件,重置失败!")
|
||||
end
|
||||
end
|
||||
|
||||
function show_menu()
|
||||
api.sh_uci_del(c_config, "@global[0]", "hide_from_luci", true)
|
||||
luci.sys.call("rm -rf /tmp/luci-*")
|
||||
@@ -875,6 +863,7 @@ function create_backup()
|
||||
end
|
||||
|
||||
function restore_backup()
|
||||
local type = http.formvalue("type")
|
||||
local result = { status = "error", message = "unknown error" }
|
||||
local ok, err = pcall(function()
|
||||
local filename = http.formvalue("filename")
|
||||
@@ -904,21 +893,29 @@ function restore_backup()
|
||||
fp:close()
|
||||
if chunk_index + 1 == total_chunks then
|
||||
uci:revert(c_config)
|
||||
uci:revert(api.s_config)
|
||||
luci.sys.call("echo '' > /tmp/log/passwall.log")
|
||||
api.log(" * PassWall 配置文件上传成功…")
|
||||
local temp_dir = '/tmp/passwall_bak'
|
||||
luci.sys.call("mkdir -p " .. temp_dir)
|
||||
if luci.sys.call("tar -xzf " .. file_path .. " -C " .. temp_dir) == 0 then
|
||||
for _, backup_file in ipairs(backup_files) do
|
||||
local temp_file = temp_dir .. backup_file
|
||||
if fs.access(temp_file) then
|
||||
luci.sys.call("cp -f " .. temp_file .. " " .. backup_file)
|
||||
local is_server_config = backup_file == "/etc/config/passwall_server"
|
||||
if type == "all" or (type == "client" and not is_server_config) or (type == "server" and is_server_config) then
|
||||
local temp_file = temp_dir .. backup_file
|
||||
if fs.access(temp_file) then
|
||||
luci.sys.call("cp -f " .. temp_file .. " " .. backup_file)
|
||||
end
|
||||
end
|
||||
end
|
||||
api.log(" * PassWall 配置还原成功…")
|
||||
api.log(" * 重启 PassWall 服务中…\n")
|
||||
luci.sys.call('/etc/init.d/passwall restart > /dev/null 2>&1 &')
|
||||
luci.sys.call('/etc/init.d/passwall_server restart > /dev/null 2>&1 &')
|
||||
if type == "all" or type == "client" then
|
||||
api.log(" * PassWall 配置还原成功…")
|
||||
api.log(" * 重启 PassWall 服务中…\n")
|
||||
luci.sys.call('/etc/init.d/passwall restart > /dev/null 2>&1 &')
|
||||
end
|
||||
if type == "all" or type == "server" then
|
||||
luci.sys.call('/etc/init.d/passwall_server restart > /dev/null 2>&1 &')
|
||||
end
|
||||
result = { status = "success", message = "Upload completed", path = file_path }
|
||||
else
|
||||
api.log(" * PassWall 配置文件解压失败,请重试!")
|
||||
@@ -936,6 +933,26 @@ function restore_backup()
|
||||
http_write_json(result)
|
||||
end
|
||||
|
||||
function reset_config()
|
||||
local type = http.formvalue("type")
|
||||
if type == "client" then
|
||||
uci:revert(c_config)
|
||||
luci.sys.call("echo '' > /tmp/log/passwall.log")
|
||||
luci.sys.call('/etc/init.d/passwall stop')
|
||||
if luci.sys.call('[ -s "/usr/share/passwall/0_default_config" ]') == 0 then
|
||||
luci.sys.call('cp -f /usr/share/passwall/0_default_config /etc/config/passwall')
|
||||
api.log(" * 恢复默认配置成功。")
|
||||
else
|
||||
api.log(" * 找不到默认配置文件,重置失败!")
|
||||
end
|
||||
elseif type == "server" then
|
||||
uci:revert(api.s_config)
|
||||
luci.sys.call("echo '' > /tmp/log/passwall_server.log")
|
||||
luci.sys.call('/etc/init.d/passwall_server stop')
|
||||
luci.sys.call("echo \"config global 'global'\" > /etc/config/passwall_server")
|
||||
end
|
||||
end
|
||||
|
||||
function geo_view()
|
||||
local action = http.formvalue("action")
|
||||
local value = http.formvalue("value")
|
||||
|
||||
Reference in new issue
Block a user