From: natemaia Date: Sat, 27 Apr 2019 22:47:15 +0000 (-0700) Subject: Fix: mirror sorting via rankmirrors X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=4c6c9775e5538fe7edc461010b5b71b749c728d6;p=pacbang-linux%2Finstaller-arch.git Fix: mirror sorting via rankmirrors --- diff --git a/archlabs-installer b/archlabs-installer index 3636316..863165d 100755 --- a/archlabs-installer +++ b/archlabs-installer @@ -5,7 +5,7 @@ # Some ideas and code reworked from other resources # 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 MNT="/mnt" # install mountpoint ANS="/tmp/ans" # dialog answer file @@ -1630,17 +1630,27 @@ install_mirrorlist() if hash reflector >/dev/null 2>&1; then reflector --score 120 -l 50 -f 5 --sort rate --save "$mfile" elif hash rankmirrors >/dev/null 2>&1; then - i="$(json 'ip' "check&?access_key=5f29642060ab983b31fdf4c2935d8c56&fields=ip")" - c="$(json 'country_code' "${i}?access_key=5f29642060ab983b31fdf4c2935d8c56&fields=country_code")" - if [[ $c && $c =~ (CA|US) ]]; then - m="https://www.archlinux.org/mirrorlist/?country=US&country=CA&use_mirror_status=on" - elif [[ $c ]]; then - m="https://www.archlinux.org/mirrorlist/?country=${c}&use_mirror_status=on" + ip_add="$(curl -fsSL "http://api.ipstack.com/check&?access_key=5f29642060ab983b31fdf4c2935d8c56&fields=ip" | + python -c "import sys, json; print(json.load(sys.stdin)['ip'])")" + + country="$(curl -fsSL "http://api.ipstack.com/${ip_add}?access_key=5f29642060ab983b31fdf4c2935d8c56&fields=country_code" | + python -c "import sys, json; print(json.load(sys.stdin)['country_code'])")" + + 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 - 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 - 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 + return 0 } @@ -2318,11 +2328,6 @@ msg() fi } -json() -{ - curl -s "http://api.ipstack.com/$2" | python3 -c "import sys, json; print(json.load(sys.stdin)['$1'])" -} - yesno() { local title="$1" body="$2" yes='Yes' no='No'