configfiles/scripts/pacrank.sh

15 lines
329 B
Bash
Raw Normal View History

2015-05-29 21:08:06 +02:00
#!/bin/bash
if [ $# -ne 1 ]; then
echo "$0 <Country>"
exit 1
fi
country=$1
INPUT=/etc/pacman.d/mirrorlist.pacnew
OUTPUT=/etc/pacman.d/mirrorlist
cat $INPUT | awk -v "COUNTRY=$country" 'BEGIN { c="" } /^##/ { c=substr($0,4); } /^#Server/ { if(c==COUNTRY) { print substr($0,2); } }' | rankmirrors - | sudo tee $OUTPUT