Local mirror inactivity got you down?

Then use SLP!

I setup my home network with openslp and wrote a little script that writes a script for portage to execute. The concept goes a little like this:

You run a local rsync/distfile mirror. You have clients that want to use emerge and you don’t want it to suck up your bandwidth. Tell them to use your local services like this:

Server side:
emerge openslp

edit /etc/slp.reg so it looks like the following:

description=Gentoo Portage rsync tree
description=Gentoo Portage distfiles mirror
(yes I know I shouldn’t have a /distfiles at the end of the URL, but I messed up my apache config and am too lazy to change it)

now do /etc/init.d/slpd start and you’re done with the server!

Client side:
emerge openslp

Using your favorite editor, create /usr/local/bin/portage-slp-services (or some other suitable location for a file to execute when a network device comes up) and add the following:

SLP_SYNC=$(slptool findsrvs service:portage.rsync | sed -r -e 's/service:portage.(.*),(.*)/\1/g')
SLP_HTTP=$(slptool findsrvs service:portage.http | sed -r -e 's/service:portage.(.*),(.*)/\1/g')
GENTOO_MIRRORS="${SLP_HTTP} $(portageq gentoo_mirrors)"

Then edit /etc/make.conf and add source /etc/portage-slp.sh to the end.

Finally, edit /etc/conf.d/net and add the following:

postup() {

and you’re done!

do a touch /etc/portage-slp.sh the first time so portageq doesn’t barf(it barfs when trying to source a non-existent file) and restart your network device. You should find that you’ll use your local mirrors first if found when the network device came up.

There is one security concern: At this moment, we assume that whoever publishes a slp record is honest, there is no checking. until we have tree signing in place, you can use gpg to sign the slp record and then verify it on the client, both that the record is correct and signed by someone you trust.

That’s it for now, keep tuned for more developments!

3 thoughts on “Local mirror inactivity got you down?”

  1. I like the idea, it’s not bad at all.

    But as I already said, I’d like to see something traversing above router borders, which isn’t going to happen. For example at work we have seperated networks, like .6 for all employees and .7 for all the server boxen.

    But the ftp (and thus the mirror carrying the SLP) is in a seperated network (DMZ), which somewhat defeats all the above .. 🙁

    Even if I would put a seperate box (or even a seperate NIC) into the server subnet, only a part of those would see the SLP.

  2. put SLP on the router(s). The SLP protocol isn’t (easily) routed, but the rest are. There is no reason why the slpd service has to reside on the rsync/distfiles server other than ease.

Comments are closed.