Append the following function to: /etc/profile and modify the variable: proxy to fit your requirements:
proxy_switch()
{
local proxy=
case "$1" in
on)
proxy="http://10.0.0.10:3128"
;;
off)
proxy=
;;
*)
printf "Usage: %s on|off\n" "${FUNCNAME[0]}"
;;
esac
export http_proxy="$proxy"
export https_proxy="$proxy"
export ftp_proxy="$proxy"
export socks_proxy="$proxy"
export HTTP_PROXY="$proxy"
export HTTPS_PROXY="$proxy"
export FTP_PROXY="$proxy"
export SOCKS_PROXY="$proxy"
}
Relogin or source /etc/profile and the new function is available in the CLI:
18:55:52 [user@localhost]:~$ proxy_switch
Usage: proxy_switch on|off
Comments