File tree Expand file tree Collapse file tree 1 file changed +32
-2
lines changed
Expand file tree Collapse file tree 1 file changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -71,10 +71,40 @@ echo "--> content of /root/packages:"
7171ls "/root/packages/"
7272echo "end of content of /root/packages. <---"
7373
74- echo "---> generating actual ranked mirrorlist to fetch packages for offline install / back up original to repace later---> "
74+ echo "---> generating actual ranked mirrorlist to fetch packages for offline install---> "
75+ echo "---> back up original to replace later---> "
7576cp "/etc/pacman.d/mirrorlist" "/etc/pacman.d/mirrorlist.later"
7677mkdir -p "/etc/pacman.d/"
77- reflector --country "$( curl -s https://ipapi.co/country_name/) " --protocol https --sort rate --latest 10 --save /etc/pacman.d/mirrorlist
78+ echo "---> generate mirrorlist safely ---> "
79+ get_country() {
80+ for url in \
81+ "https://ipapi.co/country_code" \
82+ "https://ifconfig.co/country-iso" \
83+ "https://ipinfo.io/country"; do
84+
85+ code="$( curl -fs " $url " 2> /dev/null | grep -oE ' ^[A-Z]{2}$' ) "
86+ [[ -n "$code " ]] && echo "$code " && return
87+ done
88+ }
89+
90+ COUNTRY="$( get_country) "
91+
92+ if [[ -n "$COUNTRY " ]]; then
93+ reflector \
94+ --country "$COUNTRY " \
95+ --protocol "https" \
96+ --sort "rate" \
97+ --latest "10" \
98+ --save "/etc/pacman.d/mirrorlist"
99+ else
100+ reflector \
101+ --protocol "https" \
102+ --sort "rate" \
103+ --latest "20" \
104+ --save "/etc/pacman.d/mirrorlist"
105+ fi
106+
107+ echo "---> generate mirrorlist done ---> "
78108
79109pacman -Sy
80110pacman -U --noconfirm --needed -- "/root/packages/"*".pkg.tar.zst"
You can’t perform that action at this time.
0 commit comments