X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=filesystem%2Fetc%2Fapt%2Fdetect-http-proxy;h=4bb8f3c8248c18e5b4f983031a43f7e73e333cf5;hb=e8591d75202b91bd2f5e73f603f991e0a2c14dcb;hp=2e4a962119c8206ff78b9f157bcafe5598dcbee5;hpb=1b5b229e5c33db2aa7d1175567ff013f68acce4f;p=distro-setup diff --git a/filesystem/etc/apt/detect-http-proxy b/filesystem/etc/apt/detect-http-proxy index 2e4a962..4bb8f3c 100755 --- a/filesystem/etc/apt/detect-http-proxy +++ b/filesystem/etc/apt/detect-http-proxy @@ -11,16 +11,21 @@ proxy_host=faiserver proxy_port=3142 proxy_url=http://$proxy_host:$proxy_port/ f=/tmp/apt_proxy_fail -if [[ -r $f ]]; then - if (( $(( $(date +%s) - $(stat -c %Y $f ) )) < 60*10 )); then - echo DIRECT - exit 0 - else - rm $f - fi +if [[ ! -w /tmp ]]; then + echo DIRECT + exit 0 +fi +modtime=$(stat -c %Y $f 2>/dev/null ) ||: +if [[ $modtime ]] && (( $(( $(date +%s) - modtime )) < 60*10 )); then + echo DIRECT + exit 0 +else + rm -f $f fi -if host $proxy_host && nc -z $proxy_host $proxy_port; then +if getent hosts $proxy_host &>/dev/null && timeout 1 nc -z $proxy_host $proxy_port &>/dev/null; then echo $proxy_url else - touch $f + if [[ ! -e $f || -w $f ]]; then + touch $f + fi fi