You are not logged in.
Pages: 1
Hey all, I thought I would share this script I made awhile ago to automatically update my pacman mirrorlist. It requires reflector and currently grabs the 8 most recently updated servers and sorts them by speed. It there is no internet connection, pacman is currently running, or reflector fails for some reason it will wait 60 seconds and retry until RETRY_TIMEOUT reaches 0.
#!/bin/sh
[ -e /usr/bin/reflector ] || exit
RETRY_TIMEOUT=10
PACMAN_ISRUNN=1
retry() {
if [ "$RETRY_TIMEOUT" != 0 ]; then
RETRY_TIMEOUT=$(( RETRY_TIMEOUT-1 ))
sleep 60
main
fi
[ -e /etc/pacman.d/mirrorlist.new ] && rm /etc/pacman.d/mirrorlist.new
exit
}
main() {
[ ping -w5 -c3 google.com > /dev/null 2>&1 ] && retry
if [ -e /var/lib/pacman/db.lck ]; then
PACMAN_ISRUNN=1
retry
fi
PACMAN_ISRUNN=0
touch /var/lib/pacman/db.lck
reflector -l 8 --sort rate -p http --save /etc/pacman.d/mirrorlist.new
if ! grep -q ^S /etc/pacman.d/mirrorlist.new; then
rm /var/lib/pacman/db.lck
retry
fi
mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
mv /etc/pacman.d/mirrorlist.new /etc/pacman.d/mirrorlist
rm /var/lib/pacman/db.lck
pacman -Syy > /dev/null 2>&1
}
mainPretty simple, not much really, but if you have any suggestions or comments I'll be here ![]()
Offline
The wiki has https://wiki.archlinux.org/index.php/Mi … _Generator Maybe you can enhance that script?
If you're not sure if the outcome is correct, post it on the wiki talk page first.
Offline
mod action: Moving from Programming & Scripting to Community Contributions.
aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies
Offline
@karol - The script in the wiki does not rely on reflector. Though this script would be nice for users of reflector.
Offline
Pages: 1