Wednesday, July 20, 2011

custom dependencies in openrc

Anyone ever searched for such a option? I did. The reason is simple. I have a really neat alix system with gentoo on it. The problem with this system is that it has no battery, means, every time you boot it up the time is set to 01012000. A good solution to update the time is via ntp-client and since its the gateway to the internet for my local network, it also has an ntpd damon for the local pcs.

Now i also run darkstat on this alix device, just for fun to see the traffic. Well, i said every time i boot it up the time is set to 01012000. The darkstat init script usually always runs before the ntp-client and thus getting the date from 2000. It's a funny because if i look at the darkstat site it shows something like "running for 4234 days, since 2000-01-01". Though that would be awesome but unfortunately its wrong.

A solution now would be to edit the darkstat init script and add to depend() "need ntp-client". It's a oneliner but it's not the correct way and with every update or reinstall of darkstat etc-update would overwrite it (though updates of darkstat are really seldom). Anyway there is a better (and correct) solution. Via /etc/rc.conf you can add/remove dependencies for any init scripts in gentoo.

The correct onliner in /etc/rc.conf is rc_darkstat_after="ntp-client"

That's all and it works perfectly.

No comments:

Post a Comment