Skip to content

Instantly share code, notes, and snippets.

@voyeg3r
Created August 26, 2011 19:49
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 voyeg3r/1174264 to your computer and use it in GitHub Desktop.
Save voyeg3r/1174264 to your computer and use it in GitHub Desktop.
Configuração automatica do apt via proxy
#!/bin/bash
# Criado em:Sex 26/Ago/2011 hs 19:07
# Last Change: Sex 26/Ago/2011 hs 19:07
# vim:ft=sh:fdm=syntax:nu:
# Instituicao: none
# Proposito do script: configurar o apt-via proxy e ambiente de usuário
# Autor: Sérgio Luiz Araújo Silva
# site: http://vivaotux.blogspot.com
# twitter: http://www.twitter.com/voyeg3r
# Referências
# http://vivaotux.blogspot.com/2010/08/bash-testando-strings.html
# http://www.readability.com/articles/2i4unf9r?legacy_bookmarklet=1
# http://www.google.com/notebook/#b=BDRiYSgoQmOP7kp4m
# http://www.mail-archive.com/shell-script@yahoogrupos.com.br/msg04431.html
# http://sergioaraujo.pbworks.com/w/page/15863755/apt-via-proxy
# http://aurelio.net/shell/canivete/
# http://br.groups.yahoo.com/group/shell-script/message/33379
# veja também: http://code.google.com/p/libproxy/
# ( O O )
# +===========oOO==(_)==OOo==============+
# | |
# | °v° Sergio Luiz Araujo Silva |
# | /(_)\ Linux User #423493 |
# | ^ ^ voyeg3r  gmail.com |
# +======================================+
# testa se está logado como root
if [ "$EUID" -ne "0" ]; then
echo 'Para executar este script faça login como root!' 2>&1
sleep 2
exit 1
fi
# PROXY="${USUARIO:=aluno}:${SENHA:=aluno}@${IP_SERVER:=192.168.1.11}:${PORTA:=8080}"
# proxy com ip padrão e porta padrão
PROXY="${IP_SERVER:=192.168.1.11}:${PORTA:=8080}"
if ! grep -q 'http::proxy' /etc/apt/apt.conf.d/02proxy 2>> /dev/null; {
cat <<-EOF >> /etc/apt/apt.conf.d/02proxy
# defined by the script https://gist.github.com/1174264
Acquire::http::Proxy "http://${PROXY}";
Acquire::https::Proxy "https://${PROXY}";
Acquire::ftp::Proxy "http://${PROXY}";
EOF
}
# Para o wget dentro do /etc/wgetrc - configuração do proxy para o wget
if [ -z "`grep -i http_proxy /etc/wgetrc 2>> /dev/null`" ]; {
sed -ri "s,^#(.*http://).*,\1${PROXY}/,g" /etc/wgetrc
sed -ri 's/(^#)(use_proxy = on)/\2/g' /etc/wgetrc
alias wget='wget --proxy=on --tries=0'
EOF
}
# ========================= config aria2c
#Configuração para o aria2c
#arquivo de configuração
#$HOME/.aria2/aria2.conf
# config file to aria2c
# file-allocation=none
# max-upload-limit=50K
# remote-time=true
# all-proxy=http://192.168.1.11:8080
echo
echo " 1 - Feche o konsole atual"
echo " 2 - Abra um novo terminal e"
echo " 3 - Rode o apt-get update como root"
echo
sleep 2
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment