mirror of
https://github.com/SinTan1729/random.git
synced 2024-12-26 13:18:35 -06:00
new: Added args for get-best-mirrors.sh
This commit is contained in:
parent
be806fc459
commit
a9a52f6ebe
1 changed files with 35 additions and 20 deletions
|
@ -2,6 +2,33 @@
|
|||
|
||||
# This is a simple script to fetch and update Arch and EndeavourOS mirrors
|
||||
# using rate-mirrors.
|
||||
# Syntax get-best-mirrors.sh <arch|eos|both> (nothing means both)
|
||||
# I run it weekly using anacron.
|
||||
|
||||
update_arch() {
|
||||
# Rank Arch mirrors
|
||||
echo "===================================================================================================="
|
||||
echo "Ranking Arch mirrors"
|
||||
echo "===================================================================================================="
|
||||
|
||||
rate-mirrors --protocol=https --save=$TMPFILE_ARCH arch
|
||||
sudo mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist-backup/mirrorlist.$TIME
|
||||
sudo mv $TMPFILE_ARCH /etc/pacman.d/mirrorlist
|
||||
}
|
||||
|
||||
update_eos() {
|
||||
# Remove files created by eos-rankmirror, if any
|
||||
sudo find /etc/pacman.d/ -maxdepth 1 -type f -name "endeavouros-mirrorlist\.*" -exec rm -v {} \;
|
||||
|
||||
# Rank EndeavourOS mirrors
|
||||
echo $'\n'"===================================================================================================="
|
||||
echo "Ranking EndeavourOS mirrors"
|
||||
echo "===================================================================================================="
|
||||
|
||||
rate-mirrors --protocol=https --save=$TMPFILE_EOS endeavouros
|
||||
sudo mv /etc/pacman.d/endeavouros-mirrorlist /etc/pacman.d/mirrorlist-backup/endeavouros-mirrorlist.$TIME
|
||||
sudo mv $TMPFILE_EOS /etc/pacman.d/endeavouros-mirrorlist
|
||||
}
|
||||
|
||||
# Create temporary files to output to
|
||||
TMPFILE_ARCH="$(mktemp)"
|
||||
|
@ -13,26 +40,14 @@ TIME="$(date '+%Y.%m.%d-%H.%M.%S')"
|
|||
# Create backup directory if not present already
|
||||
sudo mkdir -p /etc/pacman.d/mirrorlist-backup
|
||||
|
||||
# Remove files created by eos-rankmirror, if any
|
||||
sudo find /etc/pacman.d/ -maxdepth 1 -type f -name "endeavouros-mirrorlist\.*" -exec rm -v {} \;
|
||||
|
||||
# Rank Arch mirrors
|
||||
echo "===================================================================================================="
|
||||
echo "Ranking Arch mirrors"
|
||||
echo "===================================================================================================="
|
||||
|
||||
rate-mirrors --protocol=https --save=$TMPFILE_ARCH arch
|
||||
sudo mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist-backup/mirrorlist.$TIME
|
||||
sudo mv $TMPFILE_ARCH /etc/pacman.d/mirrorlist
|
||||
|
||||
# Rank EndeavourOS mirrors
|
||||
echo $'\n'"===================================================================================================="
|
||||
echo "Ranking EndeavourOS mirrors"
|
||||
echo "===================================================================================================="
|
||||
|
||||
rate-mirrors --protocol=https --save=$TMPFILE_EOS endeavouros
|
||||
sudo mv /etc/pacman.d/endeavouros-mirrorlist /etc/pacman.d/mirrorlist-backup/endeavouros-mirrorlist.$TIME
|
||||
sudo mv $TMPFILE_EOS /etc/pacman.d/endeavouros-mirrorlist
|
||||
if [ "$1" == "arch" ]; then
|
||||
update_arch
|
||||
elif [ "$1" == "eos" ]; then
|
||||
update_eos
|
||||
else
|
||||
update_arch
|
||||
update_eos
|
||||
fi
|
||||
|
||||
# Do some cleanup, keep only the last 3 backups
|
||||
echo $'\n'"===================================================================================================="
|
||||
|
|
Loading…
Reference in a new issue