Skip to content

Instantly share code, notes, and snippets.

@ByScripts
Created August 28, 2012 08:19
Show Gist options
  • Save ByScripts/3496113 to your computer and use it in GitHub Desktop.
Save ByScripts/3496113 to your computer and use it in GitHub Desktop.
Script to automate use of Pacman Mirrorlist Generator
#!/bin/sh
[ "$UID" != 0 ] && su=sudo
country='US'
url="http://www.archlinux.org/mirrorlist/?country=$country&protocol=ftp&protocol=http&ip_version=4&use_mirror_status=on"
tmpfile=$(mktemp --suffix=-mirrorlist)
# Get latest mirror list and save to tmpfile
wget -qO- "$url" | sed 's/^#Server/Server/g' > "$tmpfile"
# Backup and replace current mirrorlist file
{ echo " Backing up the original mirrorlist..."
$su mv -i /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.orig; } &&
{ echo " Rotating the new list into place..."
$su mv -i "$tmpfile" /etc/pacman.d/mirrorlist; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment