🐶 Sync 2026-05-01 20:23:08

This commit is contained in:
github-actions[bot] committed 2026-05-01 20:23:08 +08:00
1 parent c29ff1458e
commit 55924a6165
44 files changed
+2280 -1514

No files matched your search

@@ -184,6 +184,34 @@ 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"
if action == "start" then
math.randomseed(os.time() + math.floor(os.clock() * 1000))
api.nixio.nanosleep(0, math.random(100, 1000) * 1000000)
if fs.access(rule_lock) then
log(0, api.i18n.translatef("[Rule update] instance is running; please try again later.") .. "\n")
os.exit(0)
else
luci.sys.call("touch " .. rule_lock)
end
elseif action == "end" then
luci.sys.call("rm -f " .. rule_lock)
return
end
if fs.access(sub_lock) then
log(0, api.i18n.translatef("[Subscription] instance is running; [Rule Update] queue and wait.") .. "\n")
end
while fs.access(sub_lock) do
api.nixio.nanosleep(2, 0)
end
end
check_instance("start")
log(0, api.i18n.translate("Start updating the rules..."))
local function safe_call(func, err_msg)
xpcall(func, function(e)
@@ -221,3 +249,5 @@ if reboot == 1 then
api.uci_save(uci, name, true, true)
end
log(0, api.i18n.translate("The rules have been updated..."))
check_instance("end")