mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-09 13:06:52 +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() {
|
check_requirements() {
|
||||||
log "Check Requirements"
|
log "Check Requirements"
|
||||||
|
|
||||||
local sing_box_version curl_version jq_version kmod_nft_tproxy_version coreutils_base64_version
|
local sing_box_version jq_version coreutils_base64_version
|
||||||
sing_box_version="$(get_package_version "sing-box")"
|
sing_box_version="$(sing-box version | head -n1 | awk '{print $3}')"
|
||||||
curl_version="$(get_package_version "curl")"
|
jq_version="$(jq --version | awk -F- '{print $2}')"
|
||||||
jq_version="$(get_package_version "jq")"
|
coreutils_base64_version="$(base64 --version | head -n1 | awk '{print $4}')"
|
||||||
kmod_nft_tproxy_version="$(get_package_version "kmod-nft-tproxy")"
|
|
||||||
coreutils_base64_version="$(get_package_version "coreutils-base64")"
|
|
||||||
|
|
||||||
if [ -z "$sing_box_version" ]; then
|
if [ -z "$sing_box_version" ]; then
|
||||||
log "Package 'sing-box' is not installed." "error"
|
log "Package 'sing-box' is not installed." "error"
|
||||||
@@ -54,11 +52,6 @@ check_requirements() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$curl_version" ]; then
|
|
||||||
log "Package 'curl' is not installed." "error"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$jq_version" ]; then
|
if [ -z "$jq_version" ]; then
|
||||||
log "Package 'jq' is not installed." "error"
|
log "Package 'jq' is not installed." "error"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -67,11 +60,6 @@ check_requirements() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
if [ -z "$coreutils_base64_version" ]; then
|
||||||
log "Package 'coreutils-base64' is not installed." "error"
|
log "Package 'coreutils-base64' is not installed." "error"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
@@ -128,13 +128,6 @@ get_ruleset_format_by_file_extension() {
|
|||||||
echo "$format"
|
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
|
# Converts a comma-separated string into a JSON array string
|
||||||
comma_string_to_json_array() {
|
comma_string_to_json_array() {
|
||||||
local input="$1"
|
local input="$1"
|
||||||
|
|||||||
Reference in New Issue
Block a user