refactor: Replace opkg version checks with direct command execution

This commit is contained in:
Andrey Petelin
2025-09-30 19:55:25 +05:00
parent dd44e0156e
commit 759b6748c6
2 changed files with 4 additions and 23 deletions

View File

@@ -32,12 +32,10 @@ config_load "$PODKOP_CONFIG"
check_requirements() {
log "Check Requirements"
local sing_box_version curl_version jq_version kmod_nft_tproxy_version coreutils_base64_version
sing_box_version="$(get_package_version "sing-box")"
curl_version="$(get_package_version "curl")"
jq_version="$(get_package_version "jq")"
kmod_nft_tproxy_version="$(get_package_version "kmod-nft-tproxy")"
coreutils_base64_version="$(get_package_version "coreutils-base64")"
local sing_box_version jq_version coreutils_base64_version
sing_box_version="$(sing-box version | head -n1 | awk '{print $3}')"
jq_version="$(jq --version | awk -F- '{print $2}')"
coreutils_base64_version="$(base64 --version | head -n1 | awk '{print $4}')"
if [ -z "$sing_box_version" ]; then
log "Package 'sing-box' is not installed." "error"
@@ -54,11 +52,6 @@ check_requirements() {
fi
fi
if [ -z "$curl_version" ]; then
log "Package 'curl' is not installed." "error"
exit 1
fi
if [ -z "$jq_version" ]; then
log "Package 'jq' is not installed." "error"
exit 1
@@ -67,11 +60,6 @@ check_requirements() {
exit 1
fi
if [ -z "$kmod_nft_tproxy_version" ]; then
log "Package 'kmod-nft-tproxy' is not installed." "error"
exit 1
fi
if [ -z "$coreutils_base64_version" ]; then
log "Package 'coreutils-base64' is not installed." "error"
exit 1

View File

@@ -128,13 +128,6 @@ get_ruleset_format_by_file_extension() {
echo "$format"
}
# Retrieves the installed package version from opkg
get_package_version() {
local package="$1"
opkg status "$package" 2> /dev/null | awk '/^Version:/ {print $2}' | cut -d'-' -f1
}
# Converts a comma-separated string into a JSON array string
comma_string_to_json_array() {
local input="$1"