Last active
December 15, 2015 15:49
-
-
Save jalexanderfox/df6016f35f1eb65951f1 to your computer and use it in GitHub Desktop.
Template Proxy
This file contains 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/bash | |
assignProxy(){ | |
HTTP_PROXY_ENV="http_proxy ftp_proxy all_proxy HTTP_PROXY FTP_PROXY ALL_PROXY" | |
HTTPS_PROXY_ENV="https_proxy HTTPS_PROXY" | |
for envar in $HTTP_PROXY_ENV | |
do | |
export $envar=$1 | |
done | |
for envar in $HTTPS_PROXY_ENV | |
do | |
export $envar=$2 | |
done | |
for envar in "no_proxy NO_PROXY" | |
do | |
export $envar=$3 | |
done | |
} | |
stopProxy(){ | |
assignProxy "" | |
git config --global --unset http.proxy | |
git config --global --unset https.proxy | |
} | |
initProxy(){ | |
http_proxy_value="http://$1:$2@$3:$4" | |
https_proxy_value="https://$1:$2@$3:$4" | |
no_proxy_value="localhost,127.0.0.1,LocalAddress,LocalDomain.com" | |
assignProxy $http_proxy_value $https_proxy_value $no_proxy_value | |
# git config --global http.proxy $http_proxy_value | |
# git config --global https.proxy $https_proxy_value | |
} | |
startProxy(){ | |
read -p "Username: " -s user | |
read -p "Password: " -s pass && echo -e " " | |
domain=!PROXYDOMAIN! | |
port=!PROXYPORT! | |
initProxy $user $pass $domain $port | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment