# offer to choose mirror country
askmirrors() {
iroot askmirrors 1
- curl -s 'https://www.archlinux.org/mirrorlist/all/' | grep -i '<option value' >/tmp/mirrors.html
- grep -v '>All<' /tmp/mirrors.html | sed 's/.*<option value=".*">\(.*\)<\/option>.*/\1/g' |
- sed -e "1iauto detect mirrors (not recommended for speed)" |
- imenu -l "choose mirror location" >/tmp/mirrorselect
- if ! grep -q 'auto detect' </tmp/mirrorselect; then
- cat /tmp/mirrors.html | grep ">$(cat /tmp/mirrorselect)<" | grep -o '".*"' | grep -o '[^"]*' | iroot i countrycode
+ MIRRORCODE="$({
+ echo 'auto detect mirrors (not recommended for speed)'
+ curl -s 'https://archlinux.org/mirrorlist/all/' | grep '##' | grep -iEv '(linux|arch|generated|filter)' |
+ grep -o '[^# ]*' | grep '.....'
+ } | imenu -l 'select mirror location')"
+
+ if grep -q 'auto detect' <<<"$MIRRORCODE"; then
+ iroot automirrors 1
+ else
+ iroot countrycode "$MIRRORCODE"
if echo '> manually sorting mirrors may take a long time
use arch ranking score (recommended)
sort all mirrors by speed' | imenu -l 'choose mirror settings' | grep -q 'speed'; then
iroot sortmirrors 1
fi
- else
- iroot automirrors 1
fi
}
COUNTRYCODE="$(iroot countrycode)"
echo "fetching mirrors for $COUNTRYCODE"
- curl -s "https://www.archlinux.org/mirrorlist/?country=$COUNTRYCODE&protocol=http&protocol=https&ip_version=4&use_mirror_status=on" |
+ curl -s "https://archlinux.org/mirrorlist/?country=$COUNTRYCODE&protocol=http&protocol=https&ip_version=4&use_mirror_status=on" |
grep -iE '(Server|generated)' |
sed 's/^#Server /Server /g' >/tmp/mirrorlist