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