Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bajcmartinez/a7286d935066b948c9c4cdfb06baee14 to your computer and use it in GitHub Desktop.
Save bajcmartinez/a7286d935066b948c9c4cdfb06baee14 to your computer and use it in GitHub Desktop.
Configuration for development with a corporate proxy
Host github.com
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_github
Include "config_base"
Include "config_base"
Host *
ProxyCommand corkscrew {PROXY_HERE} %h %p
ServerAliveInterval 10
#!/bin/bash
COM_PROXY=194.138.0.11:9400
connect_office() {
export HTTP_PROXY=$COM_PROXY
export HTTPS_PROXY=$COM_PROXY
export ALL_PROXY=$COM_PROXY
git config --global http.proxy http://$COM_PROXY
npm config set proxy http://$COM_PROXY
npm config set https-proxy http://$COM_PROXY
echo "{\"proxy\":\"http://$COM_PROXY\", \"https-proxy\":\"http://$COM_PROXY\"}" > ~/.bowerrc
echo "{\"proxies\":{\"default\":{\"httpProxy\": \"http://$COM_PROXY\",\"httpsProxy\": \"http://$COM_PROXY\",\"noProxy\": \"*.test.example.com,.example2.com\"}}}" > ~/.docker/config.json
cp ~/.ssh/config_office ~/.ssh/config
}
connect_home() {
export HTTP_PROXY=
export HTTPS_PROXY=
export ALL_PROXY=
git config --global --unset http.proxy
npm config rm proxy
npm config rm https-proxy
cp ~/.ssh/config_home ~/.ssh/config
rm ~/.bowerrc
rm ~/.docker/config.json
}
case $1 in
"office")
echo "Setting up environment for 'Office'"
connect_office
;;
"home")
echo "Setting up environment for 'Home'"
connect_home
;;
*)
echo "Restarting environment..."
connect_home
echo "Checking current environment..."
if curl https://www.google.com --connect-timeout 2 -s > /dev/null; then
echo "No proxy detected, looks like you are at home :)"
echo "Done!"
else
echo "No direct internet connection, let's check if you are in the Office network..."
export HTTPS_PROXY=$COM_PROXY
if curl https://www.google.com --connect-timeout 2 -s > /dev/null; then
echo "Setting up environment for 'Office'"
connect_office
echo "Done!"
else
echo "No internet connection found!"
connect_home
fi
fi
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment