Filter mirrors for status / delay

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2021-05-15 18:49:40 +02:00
parent 72ef0202c2
commit 38a617e7d5
Signed by: luzifer
GPG key ID: 0066F03ED215AD7D

View file

@ -17,11 +17,22 @@ else
warn "Not running as root, new mirrorlist will be written to ${outfile}" warn "Not running as root, new mirrorlist will be written to ${outfile}"
fi fi
step "Measuring mirror speed, searching 5 fastest mirrors" step "Collecting mirrors"
curl -s "https://archlinux.org/mirrorlist/all/https/" | IFS=$'\n'
sed -e 's/^#Server/Server/' -e '/^#/d' | mirrors=(
$(
curl -sSfL "https://archlinux.org/mirrors/status/json/" |
jq -r '.urls[] | select(.active) | select(.completion_pct == 1.0) | select( .delay < 3600) | select(.protocol == "https") | .url'
)
)
unset IFS
step "Measuring mirror speed, searching 5 fastest mirrors of ${#mirrors[@]} mirrors"
for url in "${mirrors[@]}"; do
echo "Server = ${url}\$repo/os/\$arch"
done |
rankmirrors -n 5 - | rankmirrors -n 5 - |
tee ${outfile} tee "${outfile}"
step "Generating diff from old to new mirrorlist" step "Generating diff from old to new mirrorlist"
diff -wu ${oldlist} ${outfile} diff -wu "${oldlist}" "${outfile}"