Last active
September 27, 2016 07:19
-
-
Save Fifan31/c7cf107470f5abf10b07e9bd28e1fb6e to your computer and use it in GitHub Desktop.
Shell functions intialisation. Put this script in /etc/profile.d/
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
setproxy() | |
{ | |
proxyhostport="my.proxy.com:portnbr" | |
authok=0 | |
while [ $authok -eq 0 ] ; do | |
echo "Setting proxy environment variables:" | |
echo -n " Username: " | |
read -e username | |
echo -n " Password: " | |
read -es password | |
ret=$(curl -s -D - -x http://${username}:${password}@${proxyhostport} \ | |
-o /dev/null http://www.example.org | head -n 1 | tr -d '\n\r') | |
echo | |
if [ "$ret" == "HTTP/1.0 200 OK" ] ; then | |
authok=1 | |
else | |
echo " *** ERROR: authentification failed ('$ret') ***" | |
fi | |
done | |
export http_proxy="http://${username}:${password}@${proxyhostport}" | |
export https_proxy=$http_proxy | |
export ftp_proxy=$http_proxy | |
export no_proxy="$(hostname),*.my.domain.com,localhost,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16" | |
echo "Proxy environment variables set" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment