Understanding s6-rc oneshots

From: Damir Simunic <damir.simunic_at_gmail.com>
Date: Mon, 7 Apr 2025 14:22:15 +0200

Hi,

I’m trying to get going with s6-rc (0.5.5.0), by trying to set up a simple oneshot that sets an ip address.

The service definition looks like this:

local-ip/
├── down
├── env
│ └── IP_ADDR
├── type
└── up


type:
oneshot

up:
s6-envdir env
importas IP_ADDR IP_ADDR
/sbin/ifconfig lo0 alias ${IP_ADDR}/32

down:
s6-envdir env
importas IP_ADDR IP_ADDR
/sbin/ifconfig lo0 -alias ${IP_ADDR}

env/IP_ADDR
127.0.0.8

When I cd into the service’s directory and manually run `sudo execlineb up`, the alias gets added. Conversely, `sudo execlineb down` removes the alias.

I have s6-svscan running as root, and I go through the s6-rc-compile/s6-rc-init/s6-rc-update dance without errors, scandir symlinks to the livedir, bunch of different directories get created.

 `sudo s6-rc-db -l $LIVEDIR list oneshots` shows `local-ip` is present.

s6-svscan runs with two children, so I presume I got the compilation procedure right:

s6-supervise s6rc-fdholder
s6-supervise s6rc-oneshot-runner

However, no alias is created on lo0 after s6-rc-init/-update, and there are no erros in s6-svscan log.

How do I debug this? Is there a way to check the exit status of a oneshot?

I tried:

> sudo s6-rc -l $LIVEDIR list local-ip
local-ip

But am unclear what exactly does this mean.

Finally, if I try:

> sudo s6-rc -l $LIVEDIR start local-ip
s6-envdir: fatal: unable to envdir env: No such file or directory
s6-rc: warning: unable to start service local-ip: command exited 111

It appears that s6-rc doesn’t like the relative path to `env` directory in the `up` script?

(I also tried running th above s6-rc command from the service directory and also setting CWD=<path-to-service-dir> sudo -E …, but that didn’t help, either).

In the s6-rc/examples, dns-cache/run uses `s6-envdir env`, but that’s a longrun. I didn’t run it, but I presume this is how it should be written. Is there a difference when compiling oneshots with s6-rc-compile?


Thanks,
Damir
Received on Mon Apr 07 2025 - 14:22:15 CEST

This archive was generated by hypermail 2.4.0 : Mon Apr 07 2025 - 14:22:58 CEST