iankelling.org
/
git
/
distro-setup
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
more verbose and robust btrbk wrappers
[distro-setup]
/
filesystem
/
etc
/
apt
/
detect-http-proxy
diff --git
a/filesystem/etc/apt/detect-http-proxy
b/filesystem/etc/apt/detect-http-proxy
index b8ec1d94ea39b01708b241e80ffb8078cdc08275..4bb8f3c8248c18e5b4f983031a43f7e73e333cf5 100755
(executable)
--- a/
filesystem/etc/apt/detect-http-proxy
+++ b/
filesystem/etc/apt/detect-http-proxy
@@
-11,17
+11,18
@@
proxy_host=faiserver
proxy_port=3142
proxy_url=http://$proxy_host:$proxy_port/
f=/tmp/apt_proxy_fail
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
- if [[ -w $f ]]; then
- rm $f
- fi
- 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
fi
-if getent hosts $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
if [[ ! -e $f || -w $f ]]; then
echo $proxy_url
else
if [[ ! -e $f || -w $f ]]; then