19 lines
401 B
Bash
Executable file
19 lines
401 B
Bash
Executable file
#!/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
|
|
|
|
if [ ! -f "$INPUT" ]; then
|
|
echo "$INPUT is missing."
|
|
exit 1
|
|
fi
|
|
|
|
cat $INPUT | awk -v "COUNTRY=$country" 'BEGIN { c="" } /^##/ { c=substr($0,4); } /^#Server/ { if(c==COUNTRY) { print substr($0,2); } }' | rankmirrors - | sudo tee $OUTPUT
|
|
|