code.fastix.org

Dateiansicht:

Datei:Projekte -> Ubuntu,Debian,Apt:set-apt-proxy -> set-apt-proxy.sh
md5:c3aab44aab8f5443f83f07350aa83c86
sha1:5eed9ad0d22afecd28a67abf03af3f28185f1cf5
  1. #!/usr/bin/sudo /bin/bash
  2.  
  3. #####  Configuration   #####
  4. netAptProxy='192.168.1.251';
  5. netAptProxyPort='3142';
  6. ##### / Configuration  #####
  7.  
  8. tempfile=$(mktemp);
  9. isProxy=$(wget -O ${tempfile} http://${netAptProxy}:${netAptProxyPort} 2>&1 | grep '406 Usage Information' | wc -l);
  10. rm ${tempfile};
  11.  
  12. if [ 1 -eq ${isProxy} ]; then
  13.         echo "Acquire::http { 'Proxy ${netAptProxy}:${netAptProxyPort};' };" | tee /etc/apt/apt.conf.d/02proxy;
  14. else
  15.         echo "#Acquire::http { 'Proxy ${netAptProxy}:${netAptProxyPort};' };" | tee /etc/apt/apt.conf.d/02proxy;
  16. fi
  17.  
  18. chmod 664 /etc/apt/apt.conf.d/02proxy
  19.