-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdatemirror
More file actions
executable file
·45 lines (35 loc) · 1.11 KB
/
updatemirror
File metadata and controls
executable file
·45 lines (35 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
# Update Archlinux mirrorlist using reflector
MIRRORLIST="/etc/pacman.d/mirrorlist"
# output color:
#COLOR="\033["
WHITE="\033[38;1m"
GREEN="\033[32;1m"
BLUE="\033[34;1m"
CLOSE="\033[0m"
# prefixes:
WORK=$BLUE"::"$CLOSE
INFO=$GREEN" >"$CLOSE
ARROW=$BLUE"->"$CLOSE
echo -en $WORK $WHITE"Update mirrorlist"$CLOSE ;
if [ -a "/etc/pacman.d/mirrorlist.pacnew" ]; then
# Backup mirrorlist and mirrorlist.pacnew
echo -e "\n \t" $ARROW $WHITE"Backup mirrorlist"$CLOSE ;
if [ -a $MIRRORLIST ]; then
sudo mv $MIRRORLIST $MIRRORLIST.backup ;
sudo cp /etc/pacman.d/mirrorlist.pacnew /etc/pacman.d/mirrorlist_complete ;
fi
# Get best 4 mirror (near me)
echo -en "\t" $ARROW $WHITE"Generate new mirrorlist"$CLOSE ;
sudo reflector -l4 -c France -c Germany -c Italy --sort rate --save /etc/pacman.d/mirrorlist ;
# If we have mirrorlist, clean pacnew file
if [ -a "/etc/pacman.d/mirrorlist" ]; then
sudo rm /etc/pacman.d/mirrorlist.pacnew ;
fi
fi
DIFF=$(diff $MIRRORLIST $MIRRORLIST.backup)
if [ "$DIFF" != "" ]; then
echo " (Mirror change)" ;
else
echo " (No new mirror)" ;
fi