dotfiles/config/scripts/arch-rankmirrors
2020-02-17 07:01:26 +01:00

22 lines
433 B
Bash
Executable file

#!/usr/bin/env bash
set -e
if [ $USER != root ]
then
echo "This script should be run as root."
exit 1
fi
if ! pacman -Qq pacman-mirrorlist &> /dev/null
then
pacman -S pacman-mirrorlist
fi
if [ ! -f /etc/pacman.d/mirrorlist.pacnew ]
then
cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.pacnew
fi
egrep -o 'Server = .+' /etc/pacman.d/mirrorlist.pacnew | /usr/bin/rankmirrors -n 6 - > /etc/pacman.d/mirrorlist