Re: s6/s6-rc policy for Gentoo: config files for service scripts

From: Paul Sopka <psopka_at_sopka.ch>
Date: Thu, 19 Sep 2024 16:40:34 +0200

> A skeleton is not config data, and should thus be in /usr/
> Possibly /usr/.../examples/...
I agree, the reason i put it there ist that /etc/s6-linux-init/skel/
exists (at least on Gentoo Linux), thus for consistency.

>> - The package manager puts service source directories and an initial
>> set of bundles for system services to
>> /etc/s6-rc/system/src/{services,bundles}.
>>
>> - The package manager puts service source directories and an initial
>> set of bundles for both user and system services to
>> /usr/share/s6-rc/{user,system} as a reference of the defaults.
> If you put defaults in /usr, then prefer symlinking them into /etc,
> rather than creating a copy. That'll automatically handle changing
> defaults, and make it obvious what is locally customized.

I am not sure if I understand correctly, the files under
/usr/share/s6-rc/{user,system}
are to be there only as a reference, not to be edited.
Are you trying to say that the non-edited files should be symlinked
rather than copied?

> Void has a nice idiom in their run scripts:
>
> | #!/bin/sh
> | exec 2>&1
> | [ -r conf ] && . ./conf
> | exec acpid -f ${OPTS:=-l}
>
> That achieves 3 things:
> 1) It works out of the box (without a conf file).
> 2) The user can create a conf file containing
> OPTS='-l -d -S'
> to customize the daemon options.
> 3) The user can create a conf file containing
> if [ $((`date +%s` % 100)) -eq 0 ] ; then poweroff ; fi
> exec /usr/local/bin/notreallyacpid --foo
> to completely¹ override the run file.
>
> Note how the KEY=value pair in 2) is actually shell, hopefully
> eliminating any worries about config file format.
>
> HTH,
> Jan
>
> ¹)
> The "exec 2>&1" is an artifact of how runit does logging, and should
> always be done. Hence it comes before the conf entry point. If there was
> a valid use for stderr, lines 2 and 3 could be switched, of course.
Glorious.
Although it has to be done a bit differently when using execline (which
I intend to use):

Take my current version of the seatd-srv:

| #!/bin/execlineb -P
|
| fdmove -c 2 1
|
| multisubstitute
| {
|     define SRV seatd
|     importas -SD /etc/s6-rc S6CONFIGDIR
| }
|
| envfile -I ${S6CONFIGDIR}/system/config/${SRV}.conf
|
| multisubstitute
| {
|     importas -SD "root" SEATD_USER
|     importas -SD "seat" SEATD_GROUP
|     importas -SD "seatd" SRV_EXEC
|     importas -sSD "" SRV_OPTS
| }
|
|
| ${SRV_EXEC}    -n3
|             -u ${SEATD_USER}
|             -g ${SEATD_GROUP}
|             ${SRV_OPTS}

Would turn into:

| #!/bin/execlineb -P
|
| fdmove -c 2 1
|
| importas -SD /etc/s6-rc S6CONFIGDIR
|
| tryexec ${S6CONFIGDIR}/system/config/seatd
|
| seatd -n3 -u root -g seatd

Allowing the sysadmin to completely override the service.
Unfortunately this also forces the sysadmin to override the service for
every so little change,
so your

> 2) The user can create a conf file containing
> OPTS='-l -d -S'
> to customize the daemon options.
wont work anymore but I do not see how one could work around this in
execline.

What do you think?


Regards,

Paul

Received on Thu Sep 19 2024 - 16:40:34 CEST

This archive was generated by hypermail 2.4.0 : Thu Sep 19 2024 - 16:41:18 CEST