Add updmirrors script to fetch fastest Arch mirrors
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
a8ba81fe7c
commit
4e57e6333a
1 changed files with 27 additions and 0 deletions
27
bin/updmirrors
Executable file
27
bin/updmirrors
Executable file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/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://www.archlinux.org/mirrorlist/?country=all&protocol=https&use_mirror_status=on" |
|
||||||
|
sed -e 's/^#Server/Server/' -e '/^#/d' |
|
||||||
|
rankmirrors -n 5 - |
|
||||||
|
tee ${outfile}
|
||||||
|
|
||||||
|
step "Generating diff from old to new mirrorlist"
|
||||||
|
diff -wu ${oldlist} ${outfile}
|
Loading…
Add table
Add a link
Reference in a new issue