#!/bin/bash

#
# A driver script for the sortmirrors.pl script.  It will handle all
# your /etc/pacman.d/* files in one go.
#

if [ "`id -u`" != "0" ]; then
	echo "I need to run as root."
	exit 1
fi

if [ ! -x /usr/bin/netselect ]; then
	echo "Install the netselect package first."
	exit 1
fi

base=/etc/pacman.d

cd $base
for dbase in *; do
	echo -e "\n\033[1;1m==> Sorting mirror list for \"$dbase\"\033[1;0m\n"
	sortmirrors.pl <$dbase >$dbase.new
	mv $dbase.new $dbase
done

# vim: set ts=2 noet:
