Quickly and easily automate your Arch Linux mirrorlist.

in #arch7 years ago

I won't bother explaining what a mirrorlist file is, as Arch users generally learn that pretty quickly. If you are curious, just do a search for "mirrors, arch" and all will be answered by the most exalted Arch Linux wiki.

What they might not have gotten around to, is automating it. It's very quick and here's the steps.


####get into a terminal####
Only you have the power!

####drop to root user####
su

####install reflector####
pacman -S reflector

####create directory for pacman hooks####
mkdir /etc/pacman.d/hooks

####create pacman hook file with nano####
nano /etc/pacman.d/hooks/mirrorupgrade.hook

####paste into nano window####

[Trigger]
Operation = Upgrade
Type = Package
Target = pacman-mirrorlist

[Action]
Description = Updating pacman-mirrorlist with reflector and removing pacnew...
When = PostTransaction
Depends = reflector
Exec = /usr/bin/env sh -c "reflector --country 'United States' --age 12 --protocol https --sort rate --save /etc/pacman.d/mirrorlist; if [[ -f /etc/pacman.d/mirrorlist.pacnew ]]; then rm /etc/pacman.d/mirrorlist.pacnew; fi"

####save file####
ctrl o
enter

###exit nano####
ctrl x


what else?

nothing. that's it. the next time the pacman-mirrorlist package is updated, this hook will do it's deal.

note: the reflector command include in the hook above will:

"Select the HTTPS mirrors synchronized within the last 12 hours and located in the US, sort them by download speed, and overwrite the file /etc/pacman.d/mirrorlist."

if you are somewhere else, or want it to behave differently, just change the reflector command part of the hook to suit your needs. There are examples on the Arch wiki page for reflector. So, "reflector, arch" will get you there.

May the swartz be with you!

Sort:  

Congratulations @cryptoreturn! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

You got your First payout

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

Congratulations @cryptoreturn! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of upvotes received

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

nice tutorial! hopefully there will be more