lots of fixes and improvements
[distro-setup] / filesystem / etc / apt / detect-http-proxy
index 56804025e1ff5a4e3d0fc921dfa4e97f389b1dd1..4bb8f3c8248c18e5b4f983031a43f7e73e333cf5 100755 (executable)
@@ -15,15 +15,12 @@ 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
-        if [[ -w $f ]]; then
-            rm -f $f
-        fi
-    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 getent hosts $proxy_host &>/dev/null && timeout 1 nc -z $proxy_host $proxy_port &>/dev/null; then
     echo $proxy_url