X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=filesystem%2Fetc%2Fapt%2Fdetect-http-proxy;h=1cfdaf978b878dd6f76aa2e94c371a8fcfb902db;hb=8c9f3c9c69a1f76d8ffba1343fc0ab308fb4661a;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..1cfdaf9 100755 --- a/filesystem/etc/apt/detect-http-proxy +++ b/filesystem/etc/apt/detect-http-proxy @@ -11,16 +11,24 @@ proxy_host=faiserver proxy_port=3142 proxy_url=http://$proxy_host:$proxy_port/ f=/tmp/apt_proxy_fail +if [[ ! -w /tmp ]]; then + echo DIRECT + exit 0 +fi if [[ -r $f ]]; then if (( $(( $(date +%s) - $(stat -c %Y $f ) )) < 60*10 )); then echo DIRECT exit 0 else - rm $f + if [[ -w $f ]]; then + rm $f + fi fi 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