From e1e02929f8d9cc6ab544eb7733ad5cbc9778704e Mon Sep 17 00:00:00 2001 From: SunBK201 Date: Tue, 2 Dec 2025 13:29:23 +0800 Subject: [PATCH] fix: check package manager existence --- openwrt/files/luci/model/cbi/ua3f/fields.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/openwrt/files/luci/model/cbi/ua3f/fields.lua b/openwrt/files/luci/model/cbi/ua3f/fields.lua index 25f38d6..7f03cff 100644 --- a/openwrt/files/luci/model/cbi/ua3f/fields.lua +++ b/openwrt/files/luci/model/cbi/ua3f/fields.lua @@ -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