3 # http://askubuntu.com/questions/53443/how-do-i-ignore-a-proxy-if-not-available
4 # altered because testing a down proxy takes like 2 seconds,
5 # and we would do it like 100 times in a row. so cache a failed result
6 # locally for 10 minutes. Also, using newer option based on man apt.conf.
8 # Once when I was testing, it seemed I needed to have it output
9 # DIRECT after outputing the proxy url
11 # note, the url we are trying to fetch is $1
13 # note, if there is a problem, some ways to debug:
15 # edit /etc/apt/apt.conf.d/02proxy
16 # add, remove the autodetec
17 # Acquire::http::proxy "http://CacheServerIp:3142";
18 # see the /var/log/apt-cacher-ng logs
20 # file:///usr/share/doc/apt-cacher-ng/html/index.html
24 proxy_url
=http
://$proxy_host:$proxy_port/
26 if [[ ! -w /tmp
]]; then
30 modtime
=$
(stat
-c %Y
$f 2>/dev
/null
) ||
:
31 if [[ $modtime ]] && (( $
(( $
(date +%s
) - modtime
)) < 60*10 )); then
37 if getent hosts
$proxy_host &>/dev
/null
&& timeout
1 nc
-z $proxy_host $proxy_port &>/dev
/null
; then
40 if [[ ! -e $f ||
-w $f ]]; then