diff --git a/podkop/files/usr/bin/podkop b/podkop/files/usr/bin/podkop index 8eeaca2..c5e904a 100755 --- a/podkop/files/usr/bin/podkop +++ b/podkop/files/usr/bin/podkop @@ -2026,38 +2026,6 @@ global_check() { fi } -# TODO: create helper functon -# Download URL content directly -download_to_stream() { - local url="$1" - - config_get_bool detour "main" "detour" "0" - if [ "$detour" -eq 1 ]; then - http_proxy="http://127.0.0.1:4534" https_proxy="http://127.0.0.1:4534" wget -qO- "$url" | sed 's/\r$//' - else - wget -qO- "$url" | sed 's/\r$//' - fi -} - -# TODO: create helper functon -# Download URL to temporary file -download_to_tempfile() { - local url="$1" - local filepath="$2" - - config_get_bool detour "main" "detour" "0" - if [ "$detour" -eq 1 ]; then - http_proxy="http://127.0.0.1:4534" https_proxy="http://127.0.0.1:4534" wget -O "$filepath" "$url" - else - wget -O "$filepath" "$url" - fi - - if grep -q $'\r' "$filepath"; then - log "$filename has Windows line endings (CRLF). Converting to Unix (LF)" - sed -i 's/\r$//' "$filepath" - fi -} - show_help() { cat << EOF Usage: $0 COMMAND diff --git a/podkop/files/usr/lib/helpers.sh b/podkop/files/usr/lib/helpers.sh index 3de5bfc..1d21ca4 100644 --- a/podkop/files/usr/lib/helpers.sh +++ b/podkop/files/usr/lib/helpers.sh @@ -176,3 +176,33 @@ migrate_config_key() { sed -i "s/$key_type $old_key_name/$key_type $new_key_name/g" "$config" fi } + +# Download URL content directly +download_to_stream() { + local url="$1" + local http_proxy_url="${2}" + + if [ -n "$http_proxy_url" ]; then + http_proxy="$http_proxy_url" https_proxy="$http_proxy_url" wget -qO- "$url" | sed 's/\r$//' + else + wget -qO- "$url" | sed 's/\r$//' + fi +} + +# Download URL to temporary file +download_to_tempfile() { + local url="$1" + local filepath="$2" + local http_proxy_url="${3}" + + if [ -n "$http_proxy_url" ]; then + http_proxy="$http_proxy_url" https_proxy="$http_proxy_url" wget -O "$filepath" "$url" + else + wget -O "$filepath" "$url" + fi + + if grep -q $'\r' "$filepath"; then + log "$filename has Windows line endings (CRLF). Converting to Unix (LF)" + sed -i 's/\r$//' "$filepath" + fi +} \ No newline at end of file