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
fi
fi
fi
-if getent hosts $proxy_host && nc -z $proxy_host $proxy_port &>/dev/null; then
+if getent hosts $proxy_host &>/dev/null && timeout 1 nc -z $proxy_host $proxy_port &>/dev/null; then
echo $proxy_url
else
if [[ ! -e $f || -w $f ]]; then