mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-31 02:55:13 +08:00
🔥 Sync 2026-08-14 20:56:42
This commit is contained in:
1 parent
badefb504c
commit
2ef703a2e1
20 files changed
+639
-321
No files matched your search
@@ -1,12 +1,11 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
local api = require "luci.passwall2.api"
|
||||
local name = api.appname
|
||||
local c_config = api.c_config
|
||||
local appname = api.appname
|
||||
local fs = api.fs
|
||||
local log = api.log
|
||||
local sys = api.sys
|
||||
local uci = api.uci
|
||||
local uci, uci_get, uci_set, uci_del, uci_foreach, uci_save = api.uci, api.uci_get_c, api.uci_set_c, api.uci_del_c, api.uci_foreach_c, api.uci_save_c
|
||||
|
||||
local arg1 = arg[1]
|
||||
local arg2 = arg[2]
|
||||
@@ -16,9 +15,9 @@ local reboot = 0
|
||||
local geoip_update = "0"
|
||||
local geosite_update = "0"
|
||||
|
||||
local geoip_url = uci:get(c_config, "@global_rules[0]", "geoip_url") or "https://github.com/Loyalsoldier/geoip/releases/latest/download/geoip.dat"
|
||||
local geosite_url = uci:get(c_config, "@global_rules[0]", "geosite_url") or "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat"
|
||||
local asset_location = uci:get(c_config, "@global_rules[0]", "v2ray_location_asset") or "/usr/share/v2ray/"
|
||||
local geoip_url = uci_get("@global_rules[0]", "geoip_url") or "https://github.com/Loyalsoldier/geoip/releases/latest/download/geoip.dat"
|
||||
local geosite_url = uci_get("@global_rules[0]", "geosite_url") or "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat"
|
||||
local asset_location = uci_get("@global_rules[0]", "v2ray_location_asset") or "/usr/share/v2ray/"
|
||||
asset_location = asset_location:match("/$") and asset_location or (asset_location .. "/")
|
||||
local backup_path = "/tmp/bak_v2ray/"
|
||||
|
||||
@@ -177,16 +176,16 @@ if arg2 then
|
||||
end
|
||||
end)
|
||||
else
|
||||
geoip_update = uci:get(c_config, "@global_rules[0]", "geoip_update") or "1"
|
||||
geosite_update = uci:get(c_config, "@global_rules[0]", "geosite_update") or "1"
|
||||
geoip_update = uci_get("@global_rules[0]", "geoip_update") or "1"
|
||||
geosite_update = uci_get("@global_rules[0]", "geosite_update") or "1"
|
||||
end
|
||||
if geoip_update == "0" and geosite_update == "0" then
|
||||
os.exit(0)
|
||||
end
|
||||
|
||||
local function check_instance(action)
|
||||
local rule_lock = "/var/lock/" .. name .. "_rule_update.lock"
|
||||
local sub_lock = "/var/lock/" .. name .. "_subscribe.lock"
|
||||
local rule_lock = "/var/lock/" .. appname .. "_rule_update.lock"
|
||||
local sub_lock = "/var/lock/" .. appname .. "_subscribe.lock"
|
||||
|
||||
if action == "start" then
|
||||
math.randomseed(os.time() + math.floor(os.clock() * 1000))
|
||||
@@ -233,20 +232,20 @@ if geosite_update == "1" then
|
||||
remove_tmp_geofile("geosite")
|
||||
end
|
||||
|
||||
uci:set(c_config, "@global_rules[0]", "geoip_update", geoip_update)
|
||||
uci:set(c_config, "@global_rules[0]", "geosite_update", geosite_update)
|
||||
api.uci_save(uci, c_config, true)
|
||||
uci_set("@global_rules[0]", "geoip_update", geoip_update)
|
||||
uci_set("@global_rules[0]", "geosite_update", geosite_update)
|
||||
uci_save(true)
|
||||
|
||||
if reboot == 1 then
|
||||
if arg3 == "cron" then
|
||||
if not fs.access("/var/lock/" .. name .. ".lock") then
|
||||
sys.call("touch /tmp/lock/" .. name .. "_cron.lock")
|
||||
if not fs.access("/var/lock/" .. appname .. ".lock") then
|
||||
sys.call("touch /tmp/lock/" .. appname .. "_cron.lock")
|
||||
end
|
||||
end
|
||||
|
||||
log(1, api.i18n.translate("Restart the service and apply the new rules."))
|
||||
uci:set(c_config, "@global[0]", "flush_set", "1")
|
||||
api.uci_save(uci, c_config, true, true)
|
||||
uci_set("@global[0]", "flush_set", "1")
|
||||
uci_save(true, true)
|
||||
end
|
||||
log(0, api.i18n.translate("The rules have been updated..."))
|
||||
|
||||
|
||||
Reference in new issue
Block a user