Created
March 15, 2013 23:45
-
-
Save nemtsov/5174097 to your computer and use it in GitHub Desktop.
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
function setProxy { | |
local proxy=$1 | |
echo "Setting proxy: $proxy" | |
#TODO: set proxy here | |
} | |
function maybeSetProxy { | |
local proxy=$1 | |
echo "Detecting whether a proxy is needed..." | |
env -i bash -c "curl -sm2 example.com" | |
if [ $? -ne 0 ] | |
then | |
echo "Looks like a proxy is needed. Trying with a proxy..." | |
env -i bash -c "export http_proxy=$proxy; curl -sm2 example.com" | |
if [ $? -ne 0 ] | |
then | |
echo "Setting a proxy won't help. Exiting." 1>&2 | |
exit 1 | |
else | |
setProxy $proxy | |
fi | |
else | |
echo "No proxy is necessary" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment