Last modified: 2021-10-12 11:43

uinit - Process Controller

uinit (think of "micro init", "user init" or "you init") is a simple process controller. It is designed after the old UNIX /sbin/init (or just init) and I started it out of curiosity when I read about systemd in Debian some years ago. My question was what it would take to write something that works similar to init. Later I found some interesting use cases.

  1. I work on Raspberry Pis with the standard Raspbian OS. That comes with systemd, which I don't like very much. I prefer to have my own uinit.service and whenever I need a service I configure it in the uinit.tab passing by systemd's interface.

  2. Raspberry Pis are versatile devices. Most Raspberry applications (I'm not speaking of a "an" application software but about applying the Raspi for something) require starting and stopping services. uinit is a handy tool to do that, without going through the system configuration in /etc. That makes it easier to use the same Raspi in different applications or to test something new without thinking about conflicting side effects.

Here's an example to show what uinit is.

smbd::restart:/usr/sbin/smbd --foreground
nmbd::restart:/usr/sbin/nmbd --foreground
sshd::re,helper:/path/to/sshd-helper start

would start three services: smbd, nmbd and sshd. That's also what you can get from systemd (with three unit files) but it's just as an example for illustration.

Here is another. This uinit.tab starts the services dhcpd and apd and both create a W-LAN hotspot on your Pi.

dhcpd:::dnsmasq -k -i wlan0 -F 192.168.1.11,192.168.1.55,255.255.255.0,24h
apd::restart:$THIS apd
ex1::exit:$THIS exit

There are two interesting things (which you cannot fully see in the example lines but see wlan-hotspot for the full script):

  1. The $THIS does some "magic". There is no such thing as an apd service (or an ex1 handler to exit from the hotspot). Instead, this is implemented as some shell script code, which is bundled with everything else (like uinit's configuration file) into a single shell script.

  2. The hotspot services are started and stopped from a single shell script when needed. This "ad-hoc services" are uinit's primary use case. Of course, you could run the script also as permanent service using ExecStart from a systemd service unit or another uinit.