Permalink
Switch branches/tags
Nothing to show
Find file
0c249e9 Mar 19, 2014
executable file 42 lines (37 sloc) 1.25 KB
#!/bin/bash
sudo -v -p "Please enter you admin password: "
function setup {
echo -e "\e[32mSet-up the proxy:\e[0m ${proxy}"
echo "export http_proxy=\"http://${proxy}\"" | sudo tee /etc/bash.bashrc -a
echo "export https_proxy=\"http://${proxy}\"" | sudo tee /etc/bash.bashrc -a
echo "Acquire::http::Proxy \"http://${proxy}\";" | sudo tee /etc/apt/apt.conf.d/proxy -a
if [[ -f /usr/share/applications/google-chrome.desktop ]]
then
sudo sed -i "s_Exec=/opt/google/chrome/google-chrome %U_Exec=/opt/google/chrome/google-chrome %U --proxy-server=${proxy}_" /usr/share/applications/google-chrome.desktop
fi
export http_proxy="http://${proxy}"
export https_proxy="http://${proxy}"
}
function remove {
echo -e "\e[32mRemove the proxy\e[0m"
sudo sed -i '/export http_proxy=/d' /etc/bash.bashrc
sudo sed -i '/export https_proxy=/d' /etc/bash.bashrc
if [[ -f /etc/apt/apt.conf.d/proxy ]]
then
sudo rm /etc/apt/apt.conf.d/proxy
fi
if [[ -f /usr/share/applications/google-chrome.desktop ]]
then
sudo sed -i "s_Exec=/opt/google/chrome/google-chrome %U --proxy-server=.*_Exec=/opt/google/chrome/google-chrome %U_" /usr/share/applications/google-chrome.desktop
fi
unset http_proxy
unset https_proxy
}
if [[ $1 != "" ]]
then
proxy=$1
remove
setup
else
remove
fi