Created
November 18, 2014 12:27
-
-
Save prurigro/ced1749b05d35355b6e5 to your computer and use it in GitHub Desktop.
(ArchAssault) Select the best set of AA mirrors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
MIRRORLIST="/etc/pacman.d/archassault-mirrorlist" | |
# if mirrorlist.pacnew exists, copy to mirrorlist.complete | |
[[ -f "${MIRRORLIST}.pacnew" ]] && mv "${MIRRORLIST}.pacnew" "${MIRRORLIST}.complete" && sed -i 's/^#//' "${MIRRORLIST}.complete" | |
# if mirrorlist.complete is missing, copy mirrorlist to mirrorlist.complete | |
if [ ! -f "${MIRRORLIST}.complete" ]; then | |
[[ -f "$MIRRORLIST" ]] \ | |
&& sed 's/^#//' "$MIRRORLIST" > "${MIRRORLIST}.complete" | |
[[ -f "$MIRRORLIST" ]] \ | |
|| echo "Couldn't create ${MIRRORLIST}.complete" \ | |
&& exit 1 | |
fi | |
# uncomment all the servers | |
sed -i 's/^#Server/Server/' "${MIRRORLIST}.complete" | |
# generate the mirrorlist from the top 6 servers | |
rankmirrors -n 6 "${MIRRORLIST}.complete" > "$MIRRORLIST" | |
# remove all lines with comments from mirrorlist | |
sed -i '/^#/ d' "$MIRRORLIST" | |
# update the pacman repo to reflect our new list | |
pacman -Syy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment