@conky60 asked me to make this script available for him, so I've put it here as it may benefit someone else too:
#!/bin/bash
##
## 19-10-2017 - handy.
## This is a new version of the allserver script that I initially
## started building in late ~2012 for Manjaro. This version is for
## Arch & Artix based distros.
## The great Manjaro specific "pacman-mirrors -g" command has been
## replaced by some relatively messy script to do the same-ish job,
## in a more clumsy fashion (pacman-mirrors -g is pretty cool).
##
## If your mirrorlists become owned by root, they won't be able to
## be operated on by this script, so check that.
##
## In the /etc/pacman.d/ I use two custom mirrorlists called
## mirrorlist-arch-original & mirrorlist-artix-original each have
## ~ half a dozen or so of the generally fastest mirrors in each
## list (your choice really), which, if/when you choose, will be
## ranked into /etc/pacman.d/mirrorlist-arch & /etc/pacman.d/mirrorlist
## So you need to backup your original mirrorlists & then create the
## two "-original" files named exactly as I called them at the start
## of this paragraph. The other two will be created by the
## rankmirrors command. This is the hardest part of the whole process.
## Once you have your mirrors initially set up, allservers is as easy
## as it ever was. ;)
##
## Run this script from your user $ account as it uses sudo where
## required. I use a ~/.bashrc alias to call it, like so:
## alias as="~/allservers2"
## Then all you have to do is type in the 2 letters "as" without
## the quotes, to run the script. :)
## It is easiest to put the script in /usr/bin or in ~/
## & be sure that it has been made executable, like so:
## [handy@notebang ~]$ chmod -v +x ~/allservers2
##################################################################
err() {
ALL_OFF="\e[1;0m"
BOLD="\e[1;1m"
RED="${BOLD}\e[1;31m"
local mesg=$1; shift
printf "${RED}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
}
msg() {
ALL_OFF="\e[1;0m"
BOLD="\e[1;1m"
GREEN="${BOLD}\e[1;32m"
local mesg=$1; shift
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
}
# The menu:
clear # Clear the screen.
echo
echo -e "\e[1;32m allservers\e[1;37m2"
echo
echo -e " \e[0;33m Enter Your chosen Option's number \e[0;32m[\e[1;37m?\e[0;32m] \e[4;37mOR\e[0m\e[0;32m hit \e[0;31mReturn\e[0;32m to \e[0;31mexit\e[0;32m. "
echo
echo
echo -e " [\e[1;37m1\e[0;32m] Rank Mirrors & update mirrorlist\e[0;33m(s)\e[0;32m: \033[0mrank both Arch & Artix mirrors"
echo -e " \e[0;33m &\e[0;32m then sync/refresh package lists: \033[0mpacman -Syy "
echo
echo -e " \e[0;32m [\e[1;37m2\e[0;32m] Option \e[1;37m1\e[0;32m. \e[0;33mplus\e[0;32m Upgrade the System: \033[0mpacman -Syu --noconfirm "
echo -e " \e[0;33m &\e[0;32m then run pkgCacheClean: \033[0mpkgcacheclean "
echo
echo -e " \e[0;32m [\e[1;37m3\e[0;32m] Option \e[1;37m1\e[0;32m. \e[0;33mplus\e[0;32m Upgrade the System & AUR: \033[0myaourt -Syua --noconfirm "
echo -e " \e[0;33m &\e[0;32m then run pkgCacheClean: \033[0mpkgcacheclean "
echo
echo -e " \e[0;32m [\e[1;37m4\e[0;32m] Upgrade the System only: \033[0mpacman -Syu --noconfirm "
echo -e " \e[0;33m &\e[0;32m then run pkgCacheClean: \033[0mpkgcacheclean "
echo
echo -e " \e[0;32m [\e[1;37m5\e[0;32m] Upgrade the System & AUR only: \033[0myaourt -Syua --noconfirm "
echo -e " \e[0;33m &\e[0;32m then run pkgCacheClean: \033[0mpkgcacheclean "
echo
echo -e " \e[0;32m [\e[1;37m6\e[0;32m] Delete \e[0;33mdb.lck\e[0;32m after interupted upgrade: \033[0mrm /var/lib/pacman/db.lck "
echo -e " \e[0;32m this should remedy the unable to lock database error. "
echo
echo -e "\e[0;33m Enter the Number of Your Choice: \033[0m"
echo
read option
case "$option" in
# Note variable is quoted.
"1")
echo
msg "Processing mirrors:"
echo
#wget https://www.archlinux.org/mirrorlist/all/https/ -O /etc/pacman.d/allservers >& /dev/null
#msg "Editing allservers file"
#sudo sed -i 's/^#Server/Server/' /etc/pacman.d/allservers
msg "Removing comments from server lines in mirrorlist-arch-original"
sudo sed -i 's/^#Server/Server/' /etc/pacman.d/mirrorlist-arch-original
msg "Running rankmirrors on mirrorlist-arch(-original)"
rankmirrors -n 6 /etc/pacman.d/mirrorlist-arch-original > /etc/pacman.d/mirrorlist-arch
msg "Removing comments from server lines in mirrorlist-artix-original"
sudo sed -i 's/^#Server/Server/' /etc/pacman.d/mirrorlist-artix-original
msg "Running rankmirrors on mirrorlist(-artix)"
rankmirrors -n 6 /etc/pacman.d/mirrorlist-artix-original > /etc/pacman.d/mirrorlist
msg "Updating your pacman databases"
echo
msg "Your mirrors have been ranked &"
msg "the mirrorlist(s) have now been refreshed."
echo
msg "Refreshing your pacman database:"
sudo pacman -Syy
echo
msg "Your mirrors & package database are now synchronised."
echo
;;
# Note double semicolon to terminate each option.
"2")
echo
msg "Processing mirrors:"
echo
#wget https://www.archlinux.org/mirrorlist/all/https/ -O /etc/pacman.d/allservers >& /dev/null
#msg "Editing allservers file"
#sudo sed -i 's/^#Server/Server/' /etc/pacman.d/allservers
msg "Removing comments from server lines in mirrorlist-arch-original"
sudo sed -i 's/^#Server/Server/' /etc/pacman.d/mirrorlist-arch-original
msg "Running rankmirrors on mirrorlist-arch(-original)"
rankmirrors -n 6 /etc/pacman.d/mirrorlist-arch-original > /etc/pacman.d/mirrorlist-arch
msg "Removing comments from server lines in mirrorlist-artix-original"
sudo sed -i 's/^#Server/Server/' /etc/pacman.d/mirrorlist-artix-original
msg "Running rankmirrors on mirrorlist(-artix)"
rankmirrors -n 6 /etc/pacman.d/mirrorlist-artix-original > /etc/pacman.d/mirrorlist
msg "Updating your pacman databases"
echo
msg "Your mirrors have been ranked &"
msg "the mirrorlist(s) have now been refreshed."
echo
msg "Refreshing your pacman database:"
sudo pacman -Syy
echo
msg "Your mirrors & package database are now synchronised."
echo
msg "Upgrading System:"
echo
sudo pacman -Syu --noconfirm
echo
msg "System upgrade complete."
echo
msg "pkgCacheClean will now remove all but the 2 most "
msg "recent versions of the installation packages in "
msg "/var/cache/pacman/pkg directory:"
echo
sudo pkgcacheclean
echo
msg "pkgCacheClean has done its job. "
echo
;;
# Note double semicolon to terminate each option.
"3")
echo
msg "Processing mirrors:"
echo
#wget https://www.archlinux.org/mirrorlist/all/https/ -O /etc/pacman.d/allservers >& /dev/null
#echo "Editing allservers file"
#sudo sed -i 's/^#Server/Server/' /etc/pacman.d/allservers
echo "Removing comments from server lines in mirrorlist-arch-original"
sudo sed -i 's/^#Server/Server/' /etc/pacman.d/mirrorlist-arch-original
echo "Running rankmirrors on mirrorlist-arch(-original)"
rankmirrors -n 6 /etc/pacman.d/mirrorlist-arch-original > /etc/pacman.d/mirrorlist-arch
echo "Removing comments from server lines in mirrorlist-artix-original"
sudo sed -i 's/^#Server/Server/' /etc/pacman.d/mirrorlist-artix-original
echo "Running rankmirrors on mirrorlist(-artix)"
rankmirrors -n 6 /etc/pacman.d/mirrorlist-artix-original > /etc/pacman.d/mirrorlist
echo "Updating your pacman databases"
echo
msg "Your mirrors have been ranked &"
msg "the mirrorlist have now been refreshed."
echo
msg "Refreshing your pacman database:"
sudo pacman -Syy
echo
msg "Your mirrors & package database are now synchronised."
echo
msg "Upgrading System & AUR:"
echo
yaourt -Syua --noconfirm
echo
msg "System including AUR packages are up to date."
echo
msg "pkgCacheClean will now remove all but the 2 most "
msg "recent versions of the installation packages in "
msg "/var/cache/pacman/pkg directory:"
echo
sudo pkgcacheclean
echo
msg "pkgCacheClean has done its job. "
echo
;;
# Note double semicolon to terminate each option.
"4")
echo
msg "Upgrading System:"
echo
sudo pacman -Syu --noconfirm
echo
msg "System update complete."
echo
msg "pkgCacheClean will now remove all but the 2 most "
msg "recent versions of the installation packages in "
msg "/var/cache/pacman/pkg directory:"
echo
sudo pkgcacheclean
echo
msg "pkgCacheClean has done its job. "
echo
;;
# Note double semicolon to terminate each option.
"5")
echo
msg "Upgrading System & AUR: "
echo
yaourt -Syua --noconfirm
echo
msg "System including AUR packages are up to date. "
echo
msg "pkgCacheClean will now remove all but the 2 most "
msg "recent versions of the installation packages in "
msg "/var/cache/pacman/pkg directory:"
echo
sudo pkgcacheclean
echo
msg "pkgCacheClean has done its job. "
echo
;;
# Note double semicolon to terminate each option.
"6")
echo
msg "About to delete /var/lib/pacman/db.lck: "
echo
sudo rm /var/lib/pacman/db.lck
echo
msg "File db.lck removed, re-attempt your intended installation. "
echo
;;
# Note double semicolon to terminate each option.
esac
exit 0
Just put copy the script into your text editor, name it allservers (or anything you want for that matter) place it in your ~/ or in your /usr/bin , set the executable bit & call it from a bash terminal, or at least a bash compatible terminal. I use the "as" alias that is mentioned in the commented out notes at the start of the script.
Have fun.