fix: skip opkg lock check

This commit is contained in:
SunBK201 2025-12-07 17:15:08 +08:00
parent 426255f5ee
commit 8c40693363

View File

@ -6,16 +6,30 @@ local function cmd_exists(cmd)
return sys.call("command -v " .. cmd .. " >/dev/null 2>&1") == 0
end
local function opkg_installed(pkg)
if not cmd_exists("opkg") then return false end
local output = sys.exec("opkg list-installed " .. pkg .. " 2>&1")
if output:find(pkg, 1, true) then
return true
end
if output:find("Could not lock /var/lock/opkg.lock", 1, true) then
return true
end
return false
end
local function apk_installed(pkg)
if not cmd_exists("apk") then return false end
local output = sys.exec("apk info | grep " .. pkg .. " 2>&1")
return output:find(pkg, 1, true) ~= nil
end
function M.nfqueue_exists()
local opkg = cmd_exists("opkg") and sys.call("opkg list-installed kmod-nft-queue | grep -q kmod-nft-queue") == 0
local apk = cmd_exists("apk") and (sys.call("apk info | grep -q kmod-nft-queue") == 0)
return opkg or apk
return opkg_installed("kmod-nft-queue") or apk_installed("kmod-nft-queue")
end
function M.tproxy_exists()
local opkg = cmd_exists("opkg") and sys.call("opkg list-installed kmod-nft-tproxy | grep -q kmod-nft-tproxy") == 0
local apk = cmd_exists("apk") and (sys.call("apk info | grep -q kmod-nft-tproxy") == 0)
return opkg or apk
return opkg_installed("kmod-nft-tproxy") or apk_installed("kmod-nft-tproxy")
end
function M.offloading_enabled()