Skip to content

Instantly share code, notes, and snippets.

@mkysoft mkysoft/proxy.sh
Created Jul 23, 2018

Embed
What would you like to do?
Proxy setter for os, git and maven project by wifi name for mac os
#!/bin/bash
interface="Wi-Fi"
autoProxyURL="http://proxyserver:8080/accelerated_pac_base.pac"
proxyURL="http://proxyuser:proxypass@proxyserver:8080"
SSID=$(networksetup -getairportnetwork en0 | awk -F": " '{print $2}')
echo "WIFI SSID: $SSID"
if [ "$SSID" = "PROXY_NEEDED_WIFI" ]
then
echo "PROXY_NEEDED_WIFI"
git config --global http.proxy "$proxyURL"
echo "proxy added for git."
/usr/sbin/networksetup -setautoproxyurl "$interface" $autoProxyURL
# -setautoproxystate "$interface" on
echo "Auto proxy configured for $interface interface."
sed -i -e '/client.common.proxy/s/^#//g' myproject/config/local.properties
echo "myproject client proxy added."
export ALL_PROXY=$proxyURL
npm config set proxy $proxyURL
else
echo "General network"
git config --global --unset http.proxy
echo "git proxy removed."
/usr/sbin/networksetup -setautoproxystate "$interface" off
echo "Auto proxy closed for $interface interface."
sed -i -e '/client.common.proxy/s/^/#/g' lcwhybris/config/local.properties
echo "myproject client proxy removed."
unset ALL_PROXY
npm config delete proxy
fi
read -p "Operation complated." -n1 -s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.