38 lines
1.1 KiB
Bash
Executable File
38 lines
1.1 KiB
Bash
Executable File
#
|
|
# This script sets up http_proxy and https_proxy environment variables
|
|
# when the first positional command line parameter is 'on'
|
|
# and unsets them when the first positional command line parameter is 'off'
|
|
#
|
|
# proxy locations are documented at:
|
|
# https://confluence.oraclecorp.com/confluence/pages/viewpage.action?spaceKey=CORPNET&title=Corporate+Proxy+Environment
|
|
#
|
|
# this will get the first defined proxy from the PAC file:
|
|
# WPAD=http://wpad.oraclecorp.com/wpad.dat
|
|
# L_PROXY=$(curl -s "$WPAD" | \
|
|
# grep 'proxies =' | sed -n 's/^[^"]*"\(.*\)".*/\1/p' | \
|
|
# tr ';' '\n' | grep 'PROXY' | head -1 | sed 's/PROXY //')
|
|
#
|
|
# usage:
|
|
# source proxy off
|
|
# source proxy on
|
|
|
|
conffile="$HOME/.proxies"
|
|
|
|
if [ "$1" = "on" ]; then
|
|
if [ -f "$conffile" ]; then
|
|
source "${conffile}"
|
|
export http_proxy https_proxy
|
|
echo "https_proxy: ${https_proxy}"
|
|
echo "http_proxy: ${http_proxy}"
|
|
else
|
|
echo "create $conffile"
|
|
fi
|
|
elif [ "$1" = "off" ]; then
|
|
unset http_proxy https_proxy
|
|
echo "Proxy is off"
|
|
fi
|
|
|
|
|
|
# vim formatting
|
|
# vim: set ts=4 sw=4 tw=0 noet ft=bash:
|