GitLab's annual major release is around the corner. Along with a lot of new and exciting features, there will be a few breaking changes. Learn more here.

Verified Commit 0ae19211 authored by Erazem Kokot's avatar Erazem Kokot
Browse files

Use reflector to update mirrorlist

Closes #75.
parent a5af6430
......@@ -144,9 +144,6 @@ config() {
# Full list of locales
localelist="$(grep -E "^#?[a-z].*UTF-8" /etc/locale.gen | sed 's/#//' | awk '{print $1" -"}')"
# List of countries for mirrorlist update
countries=$(echo -e "AS All-Https\n AT Austria\n AU Australia\n BD Bangladesh\n BE Belgium\n BG Bulgaria\n BR Brazil\n BY Belarus\n CA Canada\n CL Chile \n CN China\n CO Colombia\n CZ Czech-Republic\n DE Germany\n DK Denmark\n EE Estonia\n ES Spain\n FI Finland\n FR France\n GB United-Kingdom\n HU Hungary\n IE Ireland\n IL Isreal\n IN India\n IT Italy\n JP Japan\n KR Korea\n KZ Kazakhstan\n LK Sri-Lanka\n LU Luxembourg\n LV Latvia\n MK Macedonia\n NC New-Caledonia\n NL Netherlands\n NO Norway\n NZ New-Zealand\n PL Poland\n PT Portugal\n RO Romania\n RS Serbia\n RU Russia\n SE Sweden\n CH Switzerland\n SG Singapore\n SK Slovakia\n SI Slovenia\n TR Turkey\n TW Taiwan\n UA Ukraine\n US United-States\n UZ Uzbekistan\n VN Viet-Nam\n ZA South-Africa")
# Full list of keymaps
key_maps="$(find /usr/share/kbd/keymaps -type f | sed -n -e 's!^.*/!!p' | grep ".map.gz" | sed 's/.map.gz//g' | sed 's/$/ -/g' | sort)"
......
......@@ -2,109 +2,43 @@
# Copyright (C) 2017 Dylan Schacht
update_mirrors() {
for interface in $(ls /sys/class/net/ | grep -v "lo\|vir"); do
if [[ $(cat /sys/class/net/"${interface}"/carrier) = 1 ]]; then OnLine=true; fi
done
# Until connected loop
until "${OnLine}"; do
if [ -n "${wifi_network}" ]; then
if (yesno "\n${wifi_msg0}" "${yes}" "${no}"); then
wifi-menu
if [ "$?" -gt "0" ]; then
msg "\n${wifi_msg1}"
log "Failed to connect to wifi: Exit 1"
setterm -background black -store
reset
echo "${connect_err1}" | sed 's/\\Z1//;s/\\Zn//'
exit 1
else
log "Connected to: ${wifi_network}"
OnLine=true
fi
else
unset wifi_network
fi
else
msg "\n${connect_err0}"
log "Failed to connect to network: Exit 1"
setterm -background black -store
reset
echo -e "${connect_err1}" | sed 's/\\Z1//;s/\\Zn//'
exit 1
fi
done
# Connect to wifi if we're not online
if ! is_online; then
log "Not online, connecting using wifi"
wifi-menu -o
fi
op_title="${mirror_op_msg}"
while (true); do
edit_mirrors=$(dialog --ok-button "${ok}" --menu "\n${mirror_msg0}\n" 12 60 3 \
if ! edit_mirrors="$(dialog --ok-button "${ok}" --menu "\n${mirror_msg0}\n" 12 60 3 \
"${update_mirrors_msg}" "->" \
"${manual_mirrors}" "->" \
"${cancel_mirrors}" "->" 3>&1 1>&2 2>&3)
if [ "$?" -gt "0" ] || [ "${edit_mirrors}" == "${cancel_mirrors}" ]; then
"${cancel_mirrors}" "->" \
3>&1 1>&2 2>&3)" || [ "${edit_mirrors}" == "${cancel_mirrors}" ]; then
if (yesno "\n${mirror_cancel_msg}" "${yes}" "${no}"); then
break
fi
fi
case "${edit_mirrors}" in
# Automatically update mirrors with reflector
"${update_mirrors_msg}")
code=$(dialog --ok-button "${ok}" --menu "${mirror_msg1}" 17 60 10 \
"${default}" "->" \
${countries} 3>&1 1>&2 2>&3)
if [ "$?" -gt "0" ]; then
if (yesno "\n${mirror_cancel_msg}" "${yes}" "${no}"); then
break
else
continue
fi
fi
case "${code}" in
"${default}")
mirror_url="https://www.archlinux.org/mirrorlist/all/"
;;
"AS") ## All https mirrors
mirror_url="https://www.archlinux.org/mirrorlist/all/https/"
;;
*) ## User selected country
mirror_url="https://www.archlinux.org/mirrorlist/?country=${code}"
;;
esac
if [ "${code}" == "${default}" ]; then
curl -k -s "${mirror_url}" | sed '10,1000d;s/#//' >/etc/pacman.d/mirrorlist.bak &
else
curl -k -s "${mirror_url}" >/etc/pacman.d/mirrorlist.bak &
fi
pid=$! pri=0.1 msg="\n$mirror_load0 \n\n \Z1> \Z2curl ${mirror_url}\Zn" load
if (grep "Server" /etc/pacman.d/mirrorlist.bak &>/dev/null); then
log "Updated Mirrors From: ${code}"
sed -i 's/#//' /etc/pacman.d/mirrorlist.bak
rankmirrors -n 6 /etc/pacman.d/mirrorlist.bak >/etc/pacman.d/mirrorlist &
pid=$! pri=0.8 msg="\n${mirror_load1} \n\n \Z1> \Z2rankmirrors -n 6 /etc/pacman.d/mirrorlist\Zn" load
else
msg "\n${connect_err0}"
log "Failed to connect to wifi: Exit 1"
setterm -background black -store
reset
echo -e "${connect_err1}" | sed 's/\\Z1//;s/\\Zn//'
exit 1
fi
break
log "Automatically updating mirrors"
reflector --verbose --latest 50 --sort rate --save /etc/pacman.d/mirrorlist | log
;;
# Manually update mirrors with a text editor
"${manual_mirrors}")
EDITOR=$(dialog --ok-button "${ok}" --menu "${mirror_editor_msg}" 10 60 3 \
if ! EDITOR="$(dialog --ok-button "${ok}" --menu "${mirror_editor_msg}" 10 60 3 \
"nano" "${nano_msg}" \
"vim" "${vim_msg}" \
"${cancel}" "->" 3>&1 1>&2 2>&3)
if [ "$?" -gt "0" ] || [ "${EDITOR}" == "${cancel}" ]; then
"${cancel}" "->" 3>&1 1>&2 2>&3)" || [ "${EDITOR}" == "${cancel}" ]; then
if (yesno "\n${mirror_cancel_msg}" "${yes}" "${no}"); then
break
fi
else
${EDITOR} /etc/pacman.d/mirrorlist
"${EDITOR}" /etc/pacman.d/mirrorlist
break
fi
;;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment