Skip to content

Instantly share code, notes, and snippets.

@clairtonluz
Last active March 21, 2018 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clairtonluz/0cee833bbe89de28a81e8659b019f1d2 to your computer and use it in GitHub Desktop.
Save clairtonluz/0cee833bbe89de28a81e8659b019f1d2 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [[ $(whoami) != 'root' ]]; then
echo 'Execute o comando como super usuário: "sudo proxy-config.sh"'
exit 1
fi
echo Digite o endereço ip ou dominio do proxy
read PROXY
echo Digite a porta do proxy
read PROXY_PORT
echo Qual é o usuario do proxy?
read PROXY_USER
echo Qual é a senha do proxy?
read -s PROXY_PASSWORD
echo Onde está o certificado ProxyCert.der?
read PROXY_CERT_DER
echo Onde está o certificado ProxyCert.pem?
read PROXY_CERT_PEM
echo "configuração do proxy"
echo "domain/ip: $PROXY"e
echo "port: $PROXY_PORT"
echo "username: $PROXY_USER"
echo "password: $PROXY_PASSWORD"
echo "Cert.der: $PROXY_CERT_DER"
echo "Cert.pem: $PROXY_CERT_PEM"
read -n1 -r -p "Press any key to continue..." key
if [[ ! -f $PROXY_CERT_PEM ]]; then
echo "$PROXY_CERT_PEM Not found"
exit 1;
fi
if [[ ! -f $PROXY_CERT_DER ]]; then
echo "$PROXY_CERT_DER Not found"
exit 1;
fi
# Configura o proxy no sistema operacional
echo "Configurando proxy no S.O";
echo "export http_proxy=http://${PROXY_USER}:${PROXY_PASSWORD}@${PROXY}:${PROXY_PORT}" > /etc/profile.d/proxy.sh
echo "export https_proxy=http://${PROXY_USER}:${PROXY_PASSWORD}@${PROXY}:${PROXY_PORT}" >> /etc/profile.d/proxy.sh
echo "export FTP_PROXY=http://${PROXY_USER}:${PROXY_PASSWORD}@${PROXY}:${PROXY_PORT}" >> /etc/profile.d/proxy.sh
echo "export ftp_proxy=http://${PROXY_USER}:${PROXY_PASSWORD}@${PROXY}:${PROXY_PORT}" >> /etc/profile.d/proxy.sh
echo "export all_proxy=socks://${PROXY_USER}:${PROXY_PASSWORD}@${PROXY}:${PROXY_PORT}" >> /etc/profile.d/proxy.sh
echo "export ALL_PROXY=socks://${PROXY_USER}:${PROXY_PASSWORD}@${PROXY}:${PROXY_PORT}" >> /etc/profile.d/proxy.sh
echo "export no_proxy=localhost,127.0.0.1" >> /etc/profile.d/proxy.sh
# Configurando certificados do proxy
echo "Configurando certificados do proxy";
sudo cp $PROXY_CERT_DER /usr/local/share/ca-certificates/
mkdir ~/.certs
cp $PROXY_CERT_PEM $PROXY_CERT_DER ~/.certs
sudo cp $PROXY_CERT_PEM /etc/ssl/certs/
sudo update-ca-certificates
# Configura proxy para o apt-get
echo "Configura proxy para o apt-get"
cp /etc/apt/apt.conf /etc/apt/apt.conf.bkp
echo "Acquire::http::proxy \"http://${PROXY_USER}:${PROXY_PASSWORD}@${PROXY}:${PROXY_PORT}\";" > /etc/apt/apt.conf
echo "Acquire::https::proxy \"http://${PROXY_USER}:${PROXY_PASSWORD}@${PROXY}:${PROXY_PORT}\";" >> /etc/apt/apt.conf
# Configura proxy para o curl
echo "configura proxy para o curl"
echo "proxy=http://${PROXY_USER}:${PROXY_PASSWORD}@${PROXY}:${PROXY_PORT}" > ~/.curlrc
read -p "deseja configurar proxy para o git Y/n?" CONFIGURAR_GIT
if [[ -z "$CONFIGURAR_GIT" ]]; then
CONFIGURAR_GIT="Y"
fi
# Configurando proxy para git
if [[ $CONFIGURAR_GIT == 'Y' || $CONFIGURAR_GIT == 'y' ]]; then
echo "Configurando proxy para git..."
git config --global http.proxy http://${PROXY_USER}:${PROXY_PASSWORD}@${PROXY}:${PROXY_PORT}
git config --global https.proxy http://${PROXY_USER}:${PROXY_PASSWORD}@${PROXY}:${PROXY_PORT}
fi
echo "Veja o final do script para ver como configurar o proxy para o google-chrome ou chromium-browser";
#configura proxy no chrome
# referencia https://askubuntu.com/questions/513840/google-chrome-proxy-settings
# Start Ubuntu Software Center, search for "gksu", then click Install (if not already installed).
# Press Alt+F2 and type gksu nautilus and hit Enter
# Type your password then press Ctrl+L and type /usr/share/applications/ and press Enter
# Now find google-chrome and right-click on chrome icon and select "Properties".
# Next, Add the following option at the end of command text box, there.
# --proxy-server="IP proxy Server:port" (ex: --proxy-server="127.0.0.1:8080")
# depois abrar o navegado e instale o certificado pem como AUTHORITIES
# sudo apt install gksu -y
# faça esse procedimento para o google-chrome e o chromium
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment