Last active
December 2, 2021 11:22
-
-
Save hardyscc/be69cad55615765d96e04b3d52df97ca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
local_http_proxy=${HTTP_PROXY:-$http_proxy} | |
if [ -n "$local_http_proxy" ] ; then | |
if [ $? -eq 0 ]; then # If variable has username and password, its parse method different | |
http_proxy_host=$(echo $local_http_proxy | sed 's/http:\/\/.*@\(.*\):.*/\1/') | |
http_proxy_port=$(echo $local_http_proxy | sed 's/http:\/\/.*@.*:\(.*\)/\1/' | tr -d "/") | |
http_proxy_user=$(echo $local_http_proxy | sed 's/http:\/\/\(.*\)@.*/\1/' | awk -F: '{print $1}') | |
http_proxy_password=$(echo $local_http_proxy | sed 's/http:\/\/\(.*\)@.*/\1/' | awk -F: '{print $2}') | |
else # If it doesn't have username and password, its parse method this | |
http_proxy_host=$(echo $local_http_proxy | sed 's/http:\/\/\(.*\):.*/\1/') | |
http_proxy_port=$(echo $local_http_proxy | sed 's/http:\/\/.*:\(.*\)/\1/' | tr -d "/") | |
fi | |
fi | |
local_https_proxy=${HTTPS_PROXY:-$https_proxy} | |
if [ -n "$local_https_proxy" ] ; then | |
if [ $? -eq 0 ]; then # If variable has username and password, its parse method different | |
https_proxy_host=$(echo $local_https_proxy | sed 's/http:\/\/.*@\(.*\):.*/\1/') | |
https_proxy_port=$(echo $local_https_proxy | sed 's/http:\/\/.*@.*:\(.*\)/\1/' | tr -d "/") | |
https_proxy_user=$(echo $local_https_proxy | sed 's/http:\/\/\(.*\)@.*/\1/' | awk -F: '{print $1}') | |
https_proxy_password=$(echo $local_http_proxy | sed 's/http:\/\/\(.*\)@.*/\1/' | awk -F: '{print $2}') | |
else # If it doesn't have username and password, its parse method this | |
https_proxy_host=$(echo $local_https_proxy | sed 's/http:\/\/\(.*\):.*/\1/') | |
https_proxy_port=$(echo $local_https_proxy | sed 's/http:\/\/.*:\(.*\)/\1/' | tr -d "/") | |
fi | |
fi | |
local_no_proxy=${NO_PROXY:-$no_proxy} | |
if [ -n "$local_no_proxy" ] ; then | |
http_non_proxy_hosts=$(echo $local_no_proxy | sed 's/,/|/g; s/|\./|\*\./g') | |
fi | |
if [ -n "$http_proxy_host" ] ; then | |
java_opts="$java_opts -Dhttp.proxyHost=$http_proxy_host" | |
fi | |
if [ -n "$http_proxy_port" ] ; then | |
java_opts="$java_opts -Dhttp.proxyPort=$http_proxy_port" | |
fi | |
if [ -n "$http_proxy_user" ] ; then | |
java_opts="$java_opts -Dhttp.proxyUser=$http_proxy_user" | |
fi | |
if [ -n "$http_proxy_password" ] ; then | |
java_opts="$java_opts -Dhttp.proxyPassword=$http_proxy_password" | |
fi | |
if [ -n "$https_proxy_host" ] ; then | |
java_opts="$java_opts -Dhttps.proxyHost=$https_proxy_host" | |
fi | |
if [ -n "$https_proxy_port" ] ; then | |
java_opts="$java_opts -Dhttps.proxyPort=$https_proxy_port" | |
fi | |
if [ -n "$https_proxy_user" ] ; then | |
java_opts="$java_opts -Dhttps.proxyUser=$https_proxy_user" | |
fi | |
if [ -n "$https_proxy_password" ] ; then | |
java_opts="$java_opts -Dhttps.proxyPassword=$https_proxy_password" | |
fi | |
if [ -n "$http_non_proxy_hosts" ] ; then | |
java_opts="$java_opts -Dhttp.nonProxyHosts=\"$http_non_proxy_hosts\"" | |
fi | |
echo $java_opts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment