Fix: mirror sorting via rankmirrors
This commit is contained in:
parent
10f40e52d3
commit
4c6c9775e5
@ -5,7 +5,7 @@
|
|||||||
# Some ideas and code reworked from other resources
|
# Some ideas and code reworked from other resources
|
||||||
# AIF, Cnichi, Calamares, Arch Wiki.. Credit where credit is due
|
# AIF, Cnichi, Calamares, Arch Wiki.. Credit where credit is due
|
||||||
|
|
||||||
VER="2.0.46" # installer version
|
VER="2.0.47" # installer version
|
||||||
DIST="ArchLabs" # linux distributor
|
DIST="ArchLabs" # linux distributor
|
||||||
MNT="/mnt" # install mountpoint
|
MNT="/mnt" # install mountpoint
|
||||||
ANS="/tmp/ans" # dialog answer file
|
ANS="/tmp/ans" # dialog answer file
|
||||||
@ -1630,17 +1630,27 @@ install_mirrorlist()
|
|||||||
if hash reflector >/dev/null 2>&1; then
|
if hash reflector >/dev/null 2>&1; then
|
||||||
reflector --score 120 -l 50 -f 5 --sort rate --save "$mfile"
|
reflector --score 120 -l 50 -f 5 --sort rate --save "$mfile"
|
||||||
elif hash rankmirrors >/dev/null 2>&1; then
|
elif hash rankmirrors >/dev/null 2>&1; then
|
||||||
i="$(json 'ip' "check&?access_key=5f29642060ab983b31fdf4c2935d8c56&fields=ip")"
|
ip_add="$(curl -fsSL "http://api.ipstack.com/check&?access_key=5f29642060ab983b31fdf4c2935d8c56&fields=ip" |
|
||||||
c="$(json 'country_code' "${i}?access_key=5f29642060ab983b31fdf4c2935d8c56&fields=country_code")"
|
python -c "import sys, json; print(json.load(sys.stdin)['ip'])")"
|
||||||
if [[ $c && $c =~ (CA|US) ]]; then
|
|
||||||
m="https://www.archlinux.org/mirrorlist/?country=US&country=CA&use_mirror_status=on"
|
country="$(curl -fsSL "http://api.ipstack.com/${ip_add}?access_key=5f29642060ab983b31fdf4c2935d8c56&fields=country_code" |
|
||||||
elif [[ $c ]]; then
|
python -c "import sys, json; print(json.load(sys.stdin)['country_code'])")"
|
||||||
m="https://www.archlinux.org/mirrorlist/?country=${c}&use_mirror_status=on"
|
|
||||||
|
if [[ "$country" ]]; then
|
||||||
|
if [[ $country =~ (CA|US) ]]; then
|
||||||
|
mirror="https://www.archlinux.org/mirrorlist/?country=US&country=CA&use_mirror_status=on"
|
||||||
|
elif [[ $country =~ (AU|NZ) ]]; then
|
||||||
|
mirror="https://www.archlinux.org/mirrorlist/?country=AU&country=NZ&use_mirror_status=on"
|
||||||
|
else
|
||||||
|
mirror="https://www.archlinux.org/mirrorlist/?country=${country}&use_mirror_status=on"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
m="https://www.archlinux.org/mirrorlist/?country=US&country=CA&country=NZ&country=GB&country=AU&use_mirror_status=on"
|
mirror="https://www.archlinux.org/mirrorlist/?country=all&use_mirror_status=on"
|
||||||
fi
|
fi
|
||||||
curl -s "$m" | sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -t -n 10 - | tail -n 10 >"$mfile"
|
|
||||||
|
curl -fsSL "$mirror" | sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -n 6 - >/etc/pacman.d/mirrorlist
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2318,11 +2328,6 @@ msg()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
json()
|
|
||||||
{
|
|
||||||
curl -s "http://api.ipstack.com/$2" | python3 -c "import sys, json; print(json.load(sys.stdin)['$1'])"
|
|
||||||
}
|
|
||||||
|
|
||||||
yesno()
|
yesno()
|
||||||
{
|
{
|
||||||
local title="$1" body="$2" yes='Yes' no='No'
|
local title="$1" body="$2" yes='Yes' no='No'
|
||||||
|
Reference in New Issue
Block a user