I want to set the proxy for apt-get and the global proxy in xubuntu like here but with only one command. How would it be? What's the problem with this code? I save it in ~/.functions add the line . ~/.functions to the .bashrc file and when I reload the .bashrc file gives an error about EOF in line 7.
Correct code:
myproxy="http://proxy.server:port/"
proxyhost="proxy.server"
myport=port
# Set Proxy
function setproxy() {
sudo tee -a /etc/environment << EOF
http_proxy="$myproxy"
https_proxy="$myproxy"
ftp_proxy="$myproxy"
no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
HTTP_PROXY="$myproxy"
HTTPS_PROXY="$myproxy"
FTP_PROXY="$myproxy"
NO_PROXY="localhost,127.0.0.1,localaddress,.localdomain.com"
EOF
gsettings set org.gnome.system.proxy mode manual
gsettings set org.gnome.system.proxy.http host "$proxyhost"
gsettings set org.gnome.system.proxy.http port "$myport"
gsettings set org.gnome.system.proxy.https host "$proxyhost"
gsettings set org.gnome.system.proxy.https port "$myport"
sudo tee /etc/apt/apt.conf.d/95proxies << EOF
Acquire::http::proxy "http://$proxyhost:$myport/";
Acquire::ftp::proxy "ftp://$proxyhost:$myport/";
Acquire::https::proxy "https://$proxyhost:$myport/";
EOF
}
#Unset Proxy
function unsetproxy() {
sudo rm /etc/environment
sudo tee /etc/environment << EOF
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
EOF
gsettings set org.gnome.system.proxy mode none
sudo rm /etc/apt/apt.conf.d/95proxies
}