add COUNTRY and sleep

This commit is contained in:
Tobias Powalowski 2023-07-22 07:19:58 +02:00
parent 3d9c673ad5
commit a6372f2f40

View file

@ -7,9 +7,10 @@ _TITLE="Archboot ${_RUNNING_ARCH} | Basic Setup | Pacman Configuration"
_select_mirror() { _select_mirror() {
## Download updated mirrorlist, if possible (only on x86_64) ## Download updated mirrorlist, if possible (only on x86_64)
if [[ "${_RUNNING_ARCH}" == "x86_64" ]]; then if [[ "${_RUNNING_ARCH}" == "x86_64" ]]; then
_dialog --infobox "Downloading latest mirrorlist..." 3 40
_COUNTRY="$(curl -s "http://ip-api.com/csv/?fields=countryCode")" _COUNTRY="$(curl -s "http://ip-api.com/csv/?fields=countryCode")"
_dialog --infobox "Downloading latest mirrorlist for Region ${_COUNTRY}..." 3 40
${_DLPROG} "https://www.archlinux.org/mirrorlist/?country=${_COUNTRY}&protocol=https&ip_version=4&ip_version=6&use_mirror_status=on" -O /tmp/pacman_mirrorlist.txt ${_DLPROG} "https://www.archlinux.org/mirrorlist/?country=${_COUNTRY}&protocol=https&ip_version=4&ip_version=6&use_mirror_status=on" -O /tmp/pacman_mirrorlist.txt
sleep 2
if grep -q '#Server = https:' /tmp/pacman_mirrorlist.txt; then if grep -q '#Server = https:' /tmp/pacman_mirrorlist.txt; then
mv "${_MIRRORLIST}" "${_MIRRORLIST}.bak" mv "${_MIRRORLIST}" "${_MIRRORLIST}.bak"
cp /tmp/pacman_mirrorlist.txt "${_MIRRORLIST}" cp /tmp/pacman_mirrorlist.txt "${_MIRRORLIST}"