mirror of
https://github.com/SinTan1729/random.git
synced 2024-12-26 05:08:36 -06:00
change: Only ask for sudo access at the end
This commit is contained in:
parent
a9a52f6ebe
commit
e3db86ebcd
1 changed files with 18 additions and 9 deletions
|
@ -6,19 +6,27 @@
|
|||
# I run it weekly using anacron.
|
||||
|
||||
update_arch() {
|
||||
# Create temporary file to output to
|
||||
TMPFILE_ARCH="$(mktemp)"
|
||||
|
||||
# Rank Arch mirrors
|
||||
echo "===================================================================================================="
|
||||
echo "Ranking Arch mirrors"
|
||||
echo "===================================================================================================="
|
||||
|
||||
rate-mirrors --protocol=https --save=$TMPFILE_ARCH arch
|
||||
|
||||
# Create backup directory if not present already
|
||||
sudo mkdir -p /etc/pacman.d/mirrorlist-backup
|
||||
|
||||
# Place the new mirrorlist and do a backup
|
||||
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 {} \;
|
||||
# Create temporary file to output to
|
||||
TMPFILE_EOS="$(mktemp)"
|
||||
|
||||
# Rank EndeavourOS mirrors
|
||||
echo $'\n'"===================================================================================================="
|
||||
|
@ -26,20 +34,21 @@ update_eos() {
|
|||
echo "===================================================================================================="
|
||||
|
||||
rate-mirrors --protocol=https --save=$TMPFILE_EOS endeavouros
|
||||
|
||||
# Create backup directory if not present already
|
||||
sudo mkdir -p /etc/pacman.d/mirrorlist-backup
|
||||
|
||||
# Place the new mirrorlist and do a backup
|
||||
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)"
|
||||
TMPFILE_EOS="$(mktemp)"
|
||||
# Remove files created by eos-rankmirror, if any
|
||||
sudo find /etc/pacman.d/ -maxdepth 1 -type f -name "endeavouros-mirrorlist\.*" -exec rm -v {} \;
|
||||
}
|
||||
|
||||
# Get the current time
|
||||
TIME="$(date '+%Y.%m.%d-%H.%M.%S')"
|
||||
|
||||
# Create backup directory if not present already
|
||||
sudo mkdir -p /etc/pacman.d/mirrorlist-backup
|
||||
|
||||
if [ "$1" == "arch" ]; then
|
||||
update_arch
|
||||
elif [ "$1" == "eos" ]; then
|
||||
|
|
Loading…
Reference in a new issue