fix: check package manager existence

This commit is contained in:
SunBK201 2025-12-02 13:29:23 +08:00
parent a84cfc87bf
commit e1e02929f8

View File

@ -11,15 +11,19 @@ local ListValue = cbi.ListValue
local DummyValue = cbi.DummyValue
local TextValue = cbi.TextValue
function cmd_exists(cmd)
return sys.call("command -v " .. cmd .. " >/dev/null 2>&1") == 0
end
function nfqueue_exists()
local opkg = sys.call("opkg list-installed kmod-nft-queue | grep -q kmod-nft-queue") == 0
local apk = sys.call("apk info | grep -q kmod-nft-queue") == 0
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
end
function tproxy_exists()
local opkg = sys.call("opkg list-installed kmod-nft-tproxy | grep -q kmod-nft-tproxy") == 0
local apk = sys.call("apk info | grep -q kmod-nft-tproxy") == 0
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
end