Skip to content

Instantly share code, notes, and snippets.

@editicalu
Created September 27, 2018 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save editicalu/a90ce4c7b06c6cfbb6853c2e1bc872e5 to your computer and use it in GitHub Desktop.
Save editicalu/a90ce4c7b06c6cfbb6853c2e1bc872e5 to your computer and use it in GitHub Desktop.
Pacman mirror update
#!/bin/bash
cd /tmp
echo "Creating a backup of the old mirrorlist in /etc/pacman.d/mirrorlist.backup…"
su -c "rm /etc/pacman.d/mirrorlist.pacnew && cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup && sync"
echo "Downloading a new mirrorlist…"
# Change this line to your preferences
# Standard: only servers with HTTPS and IPv6 support.
curl https://www.archlinux.org/mirrorlist/\?country\=all\&protocol\=https\&ip_version\=6 > mirrorlist.new
# Add unofficial mirrors if you want to.
#echo "Adding the faster unofficial TransIP mirror"
#echo '' >> mirrorlist.new
#echo 'Server = https://mirror.transip.net/archlinux/$repo/os/$arch' >> mirrorlist.new
echo "Preparing the new mirrorlist…"
sed "s/#Server/Server/" mirrorlist.new > mirrorlist
mv mirrorlist mirrorlist.new
echo "Testing the mirrors. This may take a while. Go make yourself a cup of coffee. ☕"
rankmirrors mirrorlist.new > mirrorlist
echo "Replacing the old mirrorlist"
su -c "mv mirrorlist /etc/pacman.d/mirrorlist"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment