minor fixes
[distro-setup] / filesystem / etc / apt / detect-http-proxy
index 2e4a962119c8206ff78b9f157bcafe5598dcbee5..a6d1d6fb77fa00b08ca1a7286fa40fcb9e9f4253 100755 (executable)
@@ -16,11 +16,15 @@ if [[ -r $f ]]; 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 && 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