You are not logged in.
I got tired of manually updating my mirrorlist file so I wrote a small script today to update my mirrorlist, you might find it useful as well:
NOTE: I assume ZERO responsibility whatsoever for any harm caused by this script and by using it you agree to these terms and conditions. The script assumes you are based in the US, if you are in another country, adjust your URL below.
#!/bin/bash
# Define tmpfile
tmpfile=/tmp/mirrorlisttmp
# Determine architecture type
archtype=$(uname -m)
# Get latest mirror list and save to tmpfile
wget -O $tmpfile "http://www.archlinux.org/mirrorlist/?country=United+States&protocol=ftp&protocol \
=http&ip_version=4&use_mirror_status=on" >/dev/null 2>&1
# Wrangle txt in saved file
sed -i -e "s/^#Server/Server/g" -e "s/\$arch/"$archtype"/g" $tmpfile
# Backup and replace current mirrorlist file
if [[ ! -f /etc/pacman.d/mirrorlist.orig ]]; then
mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.orig && echo "Successfully backed up original mirrorlist!"
cp $tmpfile /etc/pacman.d/mirrorlist && echo "Successfully applied new mirrorlist!"
else
mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak && echo "Successfully backed up current mirrorlist!"
cp $tmpfile /etc/pacman.d/mirrorlist && echo "Successfully applied new mirrorlist!"
fi
exitNOTE: You will need to copy the text above, place it into a file (call it updatemirrors.sh), run chmod +x on the file and then run it with sudo/root privileges.
Last edited by Archieman (2011-06-01 01:03:22)
A good solution applied with vigor now is better than a perfect solution applied ten minutes later. - George S. Patton
Offline
You can use [ code ] tags when pasting code https://bbs.archlinux.org/help.php#bbcode
For it to really auto-update the mirrorlist it has to be put in a cronjob :-)
If I run it twice, will the original mirrorlist (moved to mirrorlist.bak after the first run) be irrevocably lost?
Just nitpicking: you don't have to use 'g' for global changes in the sed substitutions as there is only one occurrence per line.
Last edited by karol (2011-05-31 03:43:47)
Offline
You can use [ code ] tags when pasting code https://bbs.archlinux.org/help.php#bbcode
For it to really auto-update the mirrorlist it has to be put in a cronjob :-)If I run it twice, will the original mirrorlist (moved to mirrorlist.bak after the first run) be irrevocably lost?
Just nitpicking: you don't have to use 'g' for global changes in the sed substitutions as there is only one occurrence per line.
Thanks Karol - I made the adjustments above to address both comments. The 'g' for sed I think is OK to leave in :-)
Last edited by Archieman (2011-05-31 04:00:55)
A good solution applied with vigor now is better than a perfect solution applied ten minutes later. - George S. Patton
Offline
Just wanted to say thank you for this script. It worked exactly as you described it. Unlike the script listed in the Beginners Guide. Thank you, thank you, thank you.
------------------------------------------------------------------------------------------------------------
"Computers are useless. They can only give you answers." Pablo Picasso
Offline
One minor comment - you don't need to replace the $arch variable with the actual architecture. Just make sure Architecture is set correctly in pacman.conf.
Last edited by tomk (2011-08-14 08:05:22)
Offline
Moderator comment:
Archieman,
"My first inclination is to move this thread to community contributions -- Although I understand why you opened it and concur this sub-forum may be a more appropriate location. I'll leave it here for now, but give me your thoughts
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way
Offline
@Archieman - Thanks for this script. Makes a simple replacement for reflector ![]()
Offline