Skip to content

Instantly share code, notes, and snippets.

@alst74
Last active March 12, 2018 13:31
Show Gist options
  • Save alst74/faf8c1f647411a630d614a6c42c61b94 to your computer and use it in GitHub Desktop.
Save alst74/faf8c1f647411a630d614a6c42c61b94 to your computer and use it in GitHub Desktop.
BASH proxy
PROXYSRV=proxy.example.com:8080
NOPROXY="localhost,127.0.0.1,.example.com"
proxy () {
case $1 in
'on')
echo -n "Enter passwd: "
read -s PASSWD
PROXY="http://${USER}:${PASSWD}@${PROXYSRV}"
export http_proxy="${PROXY}" https_proxy="${PROXY}" no_proxy="${NOPROXY}"
VAGRANT_HTTP_PROXY=${PROXY}
VAGRANT_HTTPS_PROXY=${PROXY}
VAGRANT_FTP_PROXY=${PROXY}
VAGRANT_NO_PROXY=${NOPROXY}
export VAGRANT_HTTP_PROXY VAGRANT_HTTPS_PROXY VAGRANT_FTP_PROXY VAGRANT_NO_PROXY
;;
'off')
#unset HTTP_PROXY HTTPS_PROXY FTP_PROXY SOCKS_PROXY NO_PROXY
unset http_proxy no_proxy VAGRANT_HTTP_PROXY VAGRANT_HTTPS_PROXY VAGRANT_FTP_PROXY VAGRANT_NO_PROXY
;;
*)
echo "Proxyerror - usage: proxy on|off"
;;
esac
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment