artix_update-mirrors-by-speed.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/bash
  2. # fail if any commands fails
  3. set -e
  4. # debug log
  5. #set -x
  6. # Set superuser privileges command if not set
  7. if [[ -z $su ]]; then
  8. export su="sudo"
  9. fi
  10. $su pacman -S pacman-contrib
  11. arch_file=/etc/pacman.d/mirrorlist-arch.backup
  12. artix_file=/etc/pacman.d/mirrorlist.backup
  13. if [ -f "$artix_file" ]; then
  14. echo "Mirrorlist $artix_file backup file exists."
  15. else
  16. echo "Mirrorlist $artix_file backup file does not exists. Creating backup"
  17. $su cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup
  18. fi
  19. if [ -f "$arch_file" ]; then
  20. echo "Mirrorlist $arch_file backup file exists."
  21. else
  22. echo "Mirrorlist $arch_file backup file does not exists. Creating backup"
  23. $su cp /etc/pacman.d/mirrorlist-arch /etc/pacman.d/mirrorlist-arch.backup
  24. fi
  25. echo -e "\033[33;5m THIS WILL TAKE SEVERAL MINUTES... \033[0m"
  26. curl -s "https://gitea.artixlinux.org/packages/artix-mirrorlist/raw/branch/master/mirrorlist" | sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -n 5 - > ~/mirrorlist.new
  27. $su cp ~/mirrorlist.new /etc/pacman.d/mirrorlist
  28. echo -e "\033[33;5m THIS WILL TAKE SEVERAL MINUTES... \033[0m"
  29. curl -s "https://archlinux.org/mirrorlist/?protocol=https&use_mirror_status=on" | sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -n 5 - > ~/mirrorlist-arch.new
  30. $su cp ~/mirrorlist-arch.new /etc/pacman.d/mirrorlist-arch