[TriLUG] Locked Out Linux box (Denouement)

Steve Litt via TriLUG trilug at trilug.org
Thu Oct 26 13:19:20 EDT 2017


On Tue, 24 Oct 2017 18:51:43 +0000 (UTC)
John Vaughters via TriLUG <trilug at trilug.org> wrote:

> Steve,
> 
> Good reference to runit, I can see this as a good way to manage
> software applications. Especially in the embedded device realm, where
> Debian already supports this software. I see this as a great way to
> manage custom made services without all the systemd hooks. I think it
> is worth a look. 

And here's the "cheaty" way to learn and set up runit...

Make yourself a little part-time Void Linux qemu or Virtualbox guest.
Look it over for awhile to get the feel of runit. Install (via the
xbps-install command) a few daemons, and look in /etc/sv/<daemonname>
for the run script and the conf script to see how things are done.

Then install it runit on the distro of your choice. Every time you want
to install a new daemon on your real machine, install it first on your
Void guest, then copy the run and conf files to your real directory, do
about 10 minutes of editing the scripts because Void sometimes gets it
wrong, especially when NIC and Wifi names are involved. The main thing
you need to remember is you always exec the thing in the foreground, so
those few daemons incapable of being run in the foreground are poor
choices to be run in runit (although they have a kludge to do it).

The way to do daemon dependencies in runit is to test for a correct
response from the dependency daemon, and fail if you don't get it. For
instance, the run script of "mydaemon" where mydaemon is a daemon that
depends on the network and a valid Internet connection, would look
something like this:

==================================================
#!/bin/sh
if ping -c1 -w1 -q > /dev/null; then
  exec mydaemon --my_foreground_operation
fi
sleep 1
==================================================

In the preceding run script, the ping tests for a working network and
Internet connection, and if it succeeds, the run script replaces itself
with mydaemon operating in the foreground.

If the ping fails it means the network or internet connection is not up
yet, so it falls through, sleeps for a second (theoretically a
significant amount of time so maybe the network/internet is now up),
and then runit reruns the run script.

So instead of doing what systemd's new, snazzy, dbus encumbered alert
systemd does and trust the dependent daemon to report its both up and
useful, this runit technique PROVES it's both up and useful before
running itself. Pretty cool. I like it.
 
SteveT

Steve Litt 
October 2017 featured book: Rapid Learning for the 21st Century
http://www.troubleshooters.com/rl21


More information about the TriLUG mailing list