forked from opendevstack/ods-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
set_java_proxy.sh
31 lines (25 loc) · 1.21 KB
/
set_java_proxy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
# this script checks for env variable HTTP_PROXY and adds it to the java sys vars
#
if [[ $HTTP_PROXY != "" ]]; then
proxy=$(echo $HTTP_PROXY | sed -e "s|https://||g" | sed -e "s|http://||g")
proxy_hostp=$(echo $proxy | cut -d "@" -f2)
proxy_host=$(echo $proxy_hostp | cut -d ":" -f1)
JAVA_OPTS="$JAVA_OPTS -Dhttp.proxyHost=$proxy_host -Dhttps.proxyHost=$proxy_host"
proxy_port=$(echo $proxy_hostp | cut -d ":" -f2)
JAVA_OPTS="$JAVA_OPTS -Dhttp.proxyPort=$proxy_port -Dhttps.proxyPort=$proxy_port"
proxy_userp=$(echo $proxy | cut -d "@" -f1)
if [[ $proxy_userp != $proxy_hostp ]];
then
proxy_user=$(echo $proxy_userp | cut -d ":" -f1)
JAVA_OPTS="$JAVA_OPTS -Dhttp.proxyUser=$proxy_user -Dhttps.proxyUser=$proxy_user"
proxy_pw=$(echo $proxy_userp | sed -e "s|$proxy_user:||g")
JAVA_OPTS="$JAVA_OPTS -Dhttp.proxyPassword=$proxy_pw -Dhttps.proxyPassword=$proxy_pw"
fi
fi
if [[ $NO_PROXY != "" ]]; then
noproxy_host=$(echo $NO_PROXY | sed -e 's|\,\.|\,\*\.|g')
noproxy_host=$(echo $noproxy_host | sed -e "s/,/|/g")
JAVA_OPTS="$JAVA_OPTS -Dhttp.nonProxyHosts=$noproxy_host -Dhttps.nonProxyHosts=$noproxy_host"
fi
export JAVA_OPTS=$JAVA_OPTS;