Skip to content

Commit

Permalink
added .profile switch
Browse files Browse the repository at this point in the history
  • Loading branch information
ailtonbsj committed May 8, 2019
1 parent f2d225e commit 61387c3
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 19 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

> Easy proxy service switching for browsers and others
Essa ferramenta facilita o chaveamento rápido das configurações de proxy no ambiente linux. Modifica as configurações de proxy dos seguintes apps:

- Firefox
- Google Chrome
- Chromium
- Apt (file apt.conf)
- Wget (file .wgetrc)
- File .profile

![Example](./example.gif)

## With NPM
Expand Down
2 changes: 1 addition & 1 deletion deb_package/DEBIAN/control
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ Priority: optional
Depends: zenity
Homepage: https://github.com/ailtonbsj/proxy-linux
Description: Easy proxy service switching for browsers and others.
Essa ferramenta facilita o chaveamento rápido das configurações de proxy no ambiente linux. Modifica as configurações de proxy dos seguintes apps: Firefox, Google Chrome, Chromium, apt.conf e wgetrc.
Essa ferramenta facilita o chaveamento rápido das configurações de proxy no ambiente linux. Modifica as configurações de proxy dos seguintes apps: Firefox, Chrome, Chromium, Apt, Wget e .profile.
53 changes: 35 additions & 18 deletions deb_package/usr/proxy-linux/main
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ FALSE "Remover Configurações do Proxy"
if [ "$escolha" == "Nenhuma" ] || [ "$escolha" == "Proxy Comum/Autenticada" ]; then
itens=$(
zenity --list --checklist --title="Proxy-Linux" \
--height=230 \
--height=260 \
--text="Quais programas deseja mudar?" \
--column="" \
--column="" \
Expand All @@ -25,7 +25,8 @@ if [ "$escolha" == "Nenhuma" ] || [ "$escolha" == "Proxy Comum/Autenticada" ]; t
TRUE "Chrome" \
TRUE "Chromium" \
TRUE "Apt" \
TRUE "Wget"
TRUE "Wget" \
TRUE "Profile"
)
perfile=~/.mozilla/firefox/$(cat ~/.mozilla/firefox/profiles.ini | grep Path= | cut -d= -f2)/prefs.js
fi
Expand All @@ -41,9 +42,13 @@ case $escolha in
fi
fi
if [[ $itens == *"Wget"* ]]; then
#WGET
echo "#PROXY-LINUX ALTEROU ESSE ARQUIVO! Use ele para modificar!" > ~/.wgetrc
fi
if [[ $itens == *"Profile"* ]]; then
sed -i "/http_proxy/d" ~/.profile
sed -i "/https_proxy/d" ~/.profile
sed -i "/ftp_proxy/d" ~/.profile
fi
;;
"Proxy Comum/Autenticada")
if [ ! -f ~/.config/proxy-linux/host ]; then
Expand Down Expand Up @@ -80,24 +85,36 @@ case $escolha in
sed -i "/\"network.proxy.http_port\"/c\user_pref(\"network.proxy.http_port\", $port);" $perfile
fi
fi

if [ -f ~/.config/proxy-linux/auth ]; then
httpProxyStr="http_proxy=http://$user:$pass@$host:$port"
httpsProxyStr="https_proxy=https://$user:$pass@$host:$port"
ftpProxyStr="ftp_proxy=ftp://$user:$pass@$host:$port"
else
httpProxyStr="http_proxy=http://$host:$port"
httpsProxyStr="https_proxy=https://$host:$port"
ftpProxyStr="ftp_proxy=ftp://$host:$port"
fi

if [[ $itens == *"Wget"* ]]; then
#WGET
if [ -f ~/.config/proxy-linux/auth ]; then
cat << EOF > ~/.wgetrc
use_proxy=yes
http_proxy=http://$user:$pass@$host:$port
https_proxy=https://$user:$pass@$host:$port
ftp_proxy=ftp://$user:$pass@$host:$port
EOF
echo "use_proxy=yes" > ~/.wgetrc
echo "$httpProxyStr" >> ~/.wgetrc
echo "$httpsProxyStr" >> ~/.wgetrc
echo "$ftpProxyStr" >> ~/.wgetrc
fi

if [[ $itens == *"Profile"* ]]; then
if [ "$(grep 'http_proxy' $HOME/.profile)" == "" ]; then
echo "export $httpProxyStr" >> ~/.profile
echo "export $httpsProxyStr" >> ~/.profile
echo "export $ftpProxyStr" >> ~/.profile
else
cat << EOF > ~/.wgetrc
use_proxy=yes
http_proxy=http://$host:$port
https_proxy=https://$host:$port
ftp_proxy=ftp://$host:$port
EOF
sed -i "/http_proxy/c\export $httpProxyStr" ~/.profile
sed -i "/https_proxy/c\export $httpsProxyStr" ~/.profile
sed -i "/ftp_proxy/c\export $ftpProxyStr" ~/.profile
fi
fi

;;
"Remover Configurações do Proxy")
cd ~/.config/proxy-linux/
Expand All @@ -119,4 +136,4 @@ while [[ $saidaSuper != *"GKSU_SUCCESS"* ]]; do
saidaSuper=$(pkexec $(pwd)/supermain "$escolha" "$itens" "$(echo ~)")
done

zenity --info --text "Novas configurações adicionadas com sucesso!";
zenity --info --width=350 --text "Novas configurações adicionadas com sucesso! \n\nPara alguns apps especificos você deve reiniciar!"

0 comments on commit 61387c3

Please sign in to comment.