cfg/bin/updmirrors
Knut Ahlers ed736d6173
Fix: Mirror URL changed
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2021-01-10 21:49:42 +01:00

27 lines
741 B
Bash
Executable file

#!/bin/bash
set -euo pipefail
source ${HOME}/bin/script_framework.sh
check_util rankmirrors # from pacman-contrib
outfile=/etc/pacman.d/mirrorlist
oldlist=/etc/pacman.d/mirrorlist.bak
if [ $(id -u) -eq 0 ]; then
step "Creating backup of current mirrorlist"
cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
else
outfile=/tmp/mirrors.rank
oldlist=/etc/pacman.d/mirrorlist
warn "Not running as root, new mirrorlist will be written to ${outfile}"
fi
step "Measuring mirror speed, searching 5 fastest mirrors"
curl -s "https://archlinux.org/mirrorlist/all/https/" |
sed -e 's/^#Server/Server/' -e '/^#/d' |
rankmirrors -n 5 - |
tee ${outfile}
step "Generating diff from old to new mirrorlist"
diff -wu ${oldlist} ${outfile}