mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-08 04:26:55 +03:00
refactor: Replace opkg version checks with direct command execution
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user