From 61387c37b17ec4d39df3236708fa7866fe033768 Mon Sep 17 00:00:00 2001 From: ailtonbsj Date: Wed, 8 May 2019 03:09:34 -0300 Subject: [PATCH] added .profile switch --- README.md | 9 ++++++ deb_package/DEBIAN/control | 2 +- deb_package/usr/proxy-linux/main | 53 +++++++++++++++++++++----------- 3 files changed, 45 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index b002583..b0d4cae 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/deb_package/DEBIAN/control b/deb_package/DEBIAN/control index 70cf9a8..d2f4d4d 100755 --- a/deb_package/DEBIAN/control +++ b/deb_package/DEBIAN/control @@ -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. diff --git a/deb_package/usr/proxy-linux/main b/deb_package/usr/proxy-linux/main index ff2b9b9..990d797 100755 --- a/deb_package/usr/proxy-linux/main +++ b/deb_package/usr/proxy-linux/main @@ -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="" \ @@ -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 @@ -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 @@ -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/ @@ -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!"