You are not logged in.

#1 2021-08-20 21:28:25

Foxhole
Member
Registered: 2015-08-14
Posts: 37

[SOLVED] Add custom mirror on top of reflector's output

Hello,
I'd need to change reflector's output by including a custom mirror automatically on top.
Reflector's command itself doesn't seem to include an option to force add another entry on top of it (or do am I missing something?).
I can do it with a script, but I'd like to change the systemd unit only, but that complex reflector systemd unit looks too hard to edit. I would like to keep all the safety constraints set by the reflector unit for this script too.

Right now the script I'm using is very dirty, it is something like:

echo 'Updating mirrors...'
reflector --verbose --protocol https --sort rate  --save /etc/pacman.d/mirrorlist
echo 'Injecting link http://custommirrorcache/repo/archlinux/$repo/os/$arch ...'
echo 'Server = http://custommirrorcache/repo/archlinux/$repo/os/$arch' > /etc/pacman.d/mirrorlist.tmp1
cat /etc/pacman.d/mirrorlist.tmp1 /etc/pacman.d/mirrorlist > /etc/pacman.d/mirrorlist.tmp
mv /etc/pacman.d/mirrorlist.tmp /etc/pacman.d/mirrorlist
rm /etc/pacman.d/mirrorlist.paco
echo 'Done!'

Any hint/suggestion is appreciated

Last edited by Foxhole (2021-08-21 16:48:01)

Offline

#2 2021-08-20 21:55:06

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,500
Website

Re: [SOLVED] Add custom mirror on top of reflector's output

Well that code is ... complicated.  If all you want to do is append reflector output to your single line, then do just that, cut out the acrobatics.

First, remove or comment the --save line from the reflector.conf, then create a drop-in to make the Exec line(s) as follows:

[Service]
ExecStart=
ExecStart=echo 'Server = http://custom/whatever' > /etc/pacmand.d/mirrorlist
ExecStart=/usr/bin/reflector @/etc/xdg/reflector/reflector.conf >> /etc/pacman.d/mirrorlist

Or even easier, just list your custom mirror in your pacman.conf before including the mirrorlist:

# ...

[core]
Server = http://custom/whatever
Include = /etc/pacman.d/mirrorlist

# ... repeat for each repo

Personally I'd go with the second approach.

Last edited by Trilby (2021-08-20 21:56:22)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2021-08-21 16:47:38

Foxhole
Member
Registered: 2015-08-14
Posts: 37

Re: [SOLVED] Add custom mirror on top of reflector's output

Well that code is ...

trash and awful, feel free to say it, i know, that's why I asked for help big_smile.
The second approach you proposed is absolutely awesome and clean, and the first one too. I'll mark this as solved and proceed with the second one, thank you very much!

Offline

Board footer

Powered by FluxBB