From e2e41142993bf849c2e8ff6031fa172200f5c88a Mon Sep 17 00:00:00 2001 From: Tobias Powalowski Date: Sun, 25 Feb 2024 17:36:43 +0100 Subject: [PATCH] add GeoIP mirrorlist on latest image --- usr/bin/archboot-update.sh | 1 + usr/lib/archboot/update/manage.sh | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/usr/bin/archboot-update.sh b/usr/bin/archboot-update.sh index 117b6e8b5..85febb40c 100755 --- a/usr/bin/archboot-update.sh +++ b/usr/bin/archboot-update.sh @@ -47,6 +47,7 @@ fi # Generate new environment and launch it with kexec if [[ -n "${_L_COMPLETE}" || -n "${_L_INSTALL_COMPLETE}" ]] && [[ -z "${_G_RELEASE}" ]]; then _update_installer_check + _geoip_mirrorlist : > /.update _TITLE="Archboot ${_RUNNING_ARCH} | ${_RUNNING_KERNEL} | Basic Setup | New Environment" _new_environment | _dialog --title "${_MENU_TITLE}" --gauge "Waiting for pacman keyring..." 6 75 0 diff --git a/usr/lib/archboot/update/manage.sh b/usr/lib/archboot/update/manage.sh index 8c3324a49..3b04cbdd0 100644 --- a/usr/lib/archboot/update/manage.sh +++ b/usr/lib/archboot/update/manage.sh @@ -75,6 +75,23 @@ _update_installer_check() { fi } +# download geoip mirrorlist for x86_64 +_geoip_mirrorlist() { + if [[ "${_RUNNING_ARCH}" == "x86_64" ]]; then + _COUNTRY="$(${_DLPROG} "http://ip-api.com/csv/?fields=countryCode")" + echo "GeoIP country ${_COUNTRY} detected." >>"${_LOG}" + ${_DLPROG} -o /tmp/pacman_mirrorlist.txt "https://www.archlinux.org/mirrorlist/?country=${_COUNTRY}&protocol=https&ip_version=4&ip_version=6&use_mirror_status=on" + sed -i -e 's|^#Server|Server|g' /tmp/pacman_mirrorlist.txt + if grep -q 'Server = https:' /tmp/pacman_mirrorlist.txt; then + mv "${_PACMAN_MIRROR}" "${_PACMAN_MIRROR}.bak" + cp /tmp/pacman_mirrorlist.txt "${_PACMAN_MIRROR}" + echo "GeoIP activated successfully." >>"${_LOG}" + else + echo "GeoIP setting failed. Using fallback mirror." >>"${_LOG}" + fi + fi +} + _full_system_check() { if [[ -e "/.full_system" ]]; then clear