diff options
author | Erich Eckner <git@eckner.net> | 2020-06-17 11:43:21 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2020-06-17 11:43:21 +0200 |
commit | 350360576f0a8656201527ea01146847cf62440e (patch) | |
tree | 0fa75a1777e17b9bb009c5d2025d7fe84278ef0f | |
parent | 34bff752de39a7d9d48cabb9f77c75420126351f (diff) | |
download | arch-mirror-350360576f0a8656201527ea01146847cf62440e.tar.xz |
arch-mirror: hard timeouts of 20mins everywhere
-rwxr-xr-x | arch-mirror | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/arch-mirror b/arch-mirror index a2d2bc1..3e62d4c 100755 --- a/arch-mirror +++ b/arch-mirror @@ -13,6 +13,8 @@ mirror_dir='/srv/http/arch' rsync_options='-rtlHp4 --safe-links --timeout=600 --contimeout=60 --delay-updates --no-motd --temp-dir='"${mirror_dir}"'/.tmp --exclude .tmp --exclude .~tmp~' +total_timeout=1200 + if stty &>/dev/null; then rsync_verbose='-v' wget_verbose='-v' @@ -25,12 +27,12 @@ retrieve_listing() { local url="$1" case "${url%%://*}" in 'rsync') - rsync "${url}" \ + timeout ${total_timeout} rsync "${url}" \ | grep '^d' \ | awk '{print $5}' ;; 'https'|'http') - curl -fSsL "${url}" \ + curl -fSsL --max-time ${total_timeout} "${url}" \ | sed ' s@^.*<a href="\([^"]\+\)/">\1/</a>.*$@\1@ t @@ -48,10 +50,10 @@ retrieve_file() { local file="$2" case "${url%%://*}" in 'rsync') - rsync -q "${url}" "${file}" + timeout ${total_timeout} rsync -q "${url}" "${file}" ;; 'https'|'http') - curl -fSsL "${url}" -o "${file}" + curl -fSsL --max-time ${total_timeout} "${url}" -o "${file}" ;; *) >&2 printf 'Unknown protocol: %s\n' "${url%%://*}" @@ -71,11 +73,11 @@ retrieve_content() { case "${url%%://*}" in 'rsync') - rsync ${rsync_options} ${rsync_verbose} ${extra_options} "${url}" "${destination}" \ + timeout ${total_timeout} rsync ${rsync_options} ${rsync_verbose} ${extra_options} "${url}" "${destination}" \ || return $? ;; 'https'|'http') - wget --mirror --prefer-family=Ipv4 -nH -np ${wget_verbose} -P "${destination}" --cut-dirs $( + timeout ${total_timeout} wget --mirror --prefer-family=Ipv4 -nH -np ${wget_verbose} -P "${destination}" --cut-dirs $( echo "${url#*//}" \ | tr -d '\n' \ | tr '/' '\n' \ @@ -119,7 +121,7 @@ resolve_complete_mirror() { } fetch_archlinux_mirrors() { - curl -fSs 'https://www.archlinux.org/mirrors/status/json/' \ + curl -fSs --max-time ${total_timeout} 'https://www.archlinux.org/mirrors/status/json/' \ | sed -n ' s@^[^[]*"urls": \[@@ T |