Great script to localize garuda-update's mirror list

This script finds your wan ip and country based on that ip. Then changes main-update with the appropriate code. I have been using this for a few months. I would like this run every time garuda-update is updated but I have not figured that part out yet.

#!/bin/sh
country=(whois $(dig +short myip.opendns.com @resolver1.opendns.com) | awk ' /[Cc]ountry/{print $2}')"

echo "Changing rate-mirrors mirror list form global to $country"
sed -i 's/using rate-mirrors,/using rate-mirrors for $country and close Neighbours,/' /usr/lib/garuda/garuda-update/main-update
sed -i 's/&& rate-mirrors --allow-root/&& rate-mirrors --protocol https --max-jumps 1 --concurrency 5 --entry-country $country --country-test-mirrors-per-country 7 --country-neighbors-per-country 1 --allow-root/' /usr/lib/garuda/garuda-update/main-update

echo "Changing reflector mirror list from global to $country"
sed -i 's/using reflector,/using reflector for $country,/' /usr/lib/garuda/garuda-update/main-update
sed -i 's/--age 2 --fastest/--age 2 --country $country --fastest/' /usr/lib/garuda/garuda-update/main-update

wrong category..... sorry. I am sure someone with more privileges can move this.

I wanted to add something like this to garuda-update before, actually. But discussion in the team has convinced me not to, because rate-mirrors simply doesn't need this, really.
What's your reasoning for wanting to force rate-mirrors to use a specific country?

4 Likes

As @ TNE said, it is not needed to have nearest mirror, but the best one in terms of speed, ping and reliability. Many users might be there with not a single mirror in their country.

That's why we don't change it in garuda-update

6 Likes

Since I can not program :slight_smile:
Once determine the country. Germany (or DE). :smiley:
and then

sudo sed -i 's/reflector --latest/reflector --country Germany --latest/' /usr/lib/garuda/garuda-update/main-update

Done.

The question remains, why?

Even if there are good and fast servers in DE, those in the Netherlands, Belgium, France, Poland, Austria ...
might be better at the time of the update. :slight_smile:

2 Likes

I find that I have been pulling updates from across the pond instead of more local mirrors. When the garuda-update is looking for more/latest mirrors it only looks at the same mirrors and not ones that are closer to me. I have found that when using closer mirrors the response times are a lot better than one across the pond.

This not only forces rate-mirrors to use more localized resources, but works for reflector as well. Rate mirrors was testing 30+ mirrors around the world, while never testing anything that was remotely close to me. This doesn't mean that rate-mirrors found the best mirrors, only the best mirrors of those tested. This script makes changes to test 10 mirrors that are closer. Resulting in a faster update, as that searching takes a significant amount of time.

Rate-mirrors will not only look at that specific country but those around it that are close.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.