arch_update-mirrors-by-speed.sh 723 B

1234567891011121314151617181920212223242526
  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. FILE=/etc/pacman.d/mirrorlist.backup
  12. if [ -f "$FILE" ]; then
  13. echo "Mirrorlist $FILE backup file exists."
  14. else
  15. echo "Mirrorlist $FILE backup file does not exists. Creating backup"
  16. $su cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup
  17. fi
  18. echo -e "\033[33;5m THIS WILL TAKE SEVERAL MINUTES... \033[0m"
  19. curl -s "https://archlinux.org/mirrorlist/?protocol=https&use_mirror_status=on" | sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -n 5 - > ~/mirrorlist.new
  20. $su cp ~/mirrorlist.new /etc/pacman.d/mirrorlist