Re: Update: s6 and utmps rpm package

2024-04-12 Thread Hoël Bézier

Hi,

Am Fri, Apr 12, 2024 at 11:51:21AM +0800 schrieb ericwq...@qq.com:

1. Run btmpd, utmpd, wtmpd as s6 service. But this option will add s6 as extra 
dependency.

2. Run  btmpd, utmpd, wtmpd as systemd service. The dependency is minimal. Only
depends on s6-ipcserver.


Since s6-ipcserver is provided by s6, aren’t these two the same option, 
regarding dependencies?


signature.asc
Description: PGP signature


Re: Update: rpm package for utmps, skalibs.

2024-04-08 Thread Hoël Bézier

Hi,

Am Tue, Apr 09, 2024 at 06:40:36AM +0800 schrieb qi wang:

The next question is about s6.pre-install, s6.pre-upgrade script. they do the 
same thing (setup catchlog user/group), why we need s6.pre-upgrade script if 
the previous installation already setup the catchlog user/group?


Probably because previous versions of the package did not have a pre-install 
script and did not setup the catchlog user/group, so when upgrading from these 
you had to do that in the pre-upgrade script.


Hoël


signature.asc
Description: PGP signature


Re: s6-rc user services on Gentoo

2024-04-08 Thread Hoël Bézier

Hi Alexis, and everyone else,


i guess i'd probably want OpenRC supervising the user s6-svscan
process, mainly because, at this point, i'd like to keep using
OpenRC on my Gentoo system overall: since a lot of my volunteer
tech work involves providing support to others and
writing/maintaining documentation, it's useful to keep my own
system fundamentally similar to what others are running.


I realized I have here just what you need, or at least could use, to do that: 
an OpenRC service definition and an execline script which execs into s6-svscan 
and sets up s6-rc on top of it.


The execline script is a bit hacky (this loopwhilex should be replaced by a 
proper tool waiting for s6-svscan readiness notification), so if anyone wants 
to propose enhancements I’m all hears.


The OpenRC script is specifically written for my user, I guess you could make 
it generic, I didn’t bother to do so. Feel free to adapt. The 
xdg-runtime-dir-bezier-h service referenced in depend() is a service which 
makes sure my user has an existing XDG_RUNTIME_DIR at startup (it usually is 
created on login, but I want my services to be run during the boot sequence).


Both the execline script and the OpenRC service are based on Laurent’s 
s6-svscan OpenRC service for Alpine Linux in which he claims that in the future 
s6-svscan will be pid1 in Alpine. ;)


Enjoy,
Hoël
#!/bin/execlineb -S1
emptyenv -p
export USER ${1}
s6-envuidgid -i -- ${1}
s6-applyuidgid -U --
backtick -in HOME { homeof ${1} }
multisubstitute
{
  importas -i USER USER
  importas -i HOME HOME
  importas -i UID UID
  importas -i GID GID
  importas -i GIDLIST GIDLIST
}
export PATH "/usr/bin:/usr/sbin:/bin:/sbin"
if { install -d -o ${1} -g ${1} -m 0700 /run/${1}/services }
background
{
foreground {
loopwhilex -x 0
s6-rc-init -c ${HOME}/.config/s6-rc/compiled -l /run/${1}/s6-rc 
-d /run/${1}/services
}
s6-rc -l /run/${1}/s6-rc -u change default
}
redirfd -r 0 /dev/null
s6-svscan -- /run/${1}/services
#!/sbin/openrc-run

depend() {
after xdg-runtime-dir-bezier-h
}

name="s6"
command="/lib/s6/s6-usertree"
command_args="bezier-h"
pidfile="/run/s6-bezier-h.pid"
start_stop_daemon_args="-b -m -k 022"


signature.asc
Description: PGP signature


Re: s6-rc user services on Gentoo

2024-04-02 Thread Hoël Bézier

Hi,

(resending this to the list as I only replied to Alexis, sorry Alexis for the 
double send.)


Am Tue, Apr 02, 2024 at 03:42:06PM +1100 schrieb Alexis:


Hi all,

Laurent has suggested i ask on IRC about this, but since (a) i'm
in UTC+10, (b) i'm constantly moving between a few different
networks, and (c) my bouncer is currently out of action (it's a
Story), i thought i'd ask on these lists instead, to facilitate
asynchronous replies. :-)


I feel you. IRC without bouncer is not always great for getting help on some 
topics. ^^’



[snip]

i've had a lot on my plate for a while, but in more recent times
i've had a bit more space to faff around with lower-priority
stuff, and so i'm exploring setting up s6-rc to manage the user
services i need. Once i've done so, i can:

* write a guide on the Gentoo wiki[a]; and

* provide service definitions for others to use via my personal
 overlay[b].

which might help more people to become familiar with the s6
ecosystem in general, and with s6-rc in particular (rather than
trying to use s6 for service management as well as supervision).


Are you planning on having your user services supervisor itself supervised? And 
if so, by OpenRC or another instance of s6-svscan? Just asking out of 
curiosity.



However, i've reached an impasse, and i'm hoping some can tell me
what i'm missing / what i'm doing wrong / what i'm
misunderstanding.

[snip]

* SCANDIR="${XDG_DATA_HOME}/s6-rc/services"

* The above directory contains symlinks to

 ${S6RC_SERVICE_REPO}/{dbus-session-bus,dbus-session-bus-log}

* S6RC_COMPILED="${XDG_STATE_HOME}/s6-rc/compiled"

* Running:

 s6-rc-compile "${S6RC_COMPILED}" "${SCANDIR}"

 completes successfully.

* Running

 s6-svscan -- "${SCANDIR}"

 succeeds, with two s6-supervise processes created.

* HOWEVER, running

 s6-rc-init -c "${S6RC_COMPILED}" -l "${XDG_RUNTIME_DIR}/s6-rc"
 "${SCANDIR}"

 fails, with the error message:

 unable to supervise service directories in
 /run/user/1000/s6-rc/servicedirs: File exists


Your scandir and your service definitions are the same directory, which they 
should not be.


You currently have:
* service_definitions="${xdg_data_home}/s6-rc/services"
* compiled_services="${xdg_state_home}/s6-rc/compiled"
* scandir="${xdg_data_home}/s6-rc/services"
* livedir="${xdg_runtime_dir}/s6-rc"

However service definitions can not be used as a scandir: if your services are 
to be managed by s6-rc they should not be present at start in your scandir but 
should be added there by s6-rc-init.


That’s why s6-rc-init complains about files already existing: it tries to 
create a symlink in the scandir pointing to the services it’s managing but it 
can’t because the service are already present in the scandir.


Moreover, had you had any oneshots in your service definition directory, I 
think s6-svscan would have simply failed to start, or complained about 
directories containing no service (oneshots are not supervised by s6-svscan, 
because there’s nothing to supervise in them, so it doesn’t know about them).


What you should have is:
* service_definitions="${xdg_data_home}/s6-rc/services"
* compiled_services="${xdg_state_home}/s6-rc/compiled"
* scandir="${xdg_runtime_dir}/services"
* livedir="${xdg_runtime_dir}/s6-rc"

Your scandir should be in your runtime dir because it does not contain data but 
the current running configuration of your system. It can be an empty directory 
when you start s6-svscan, there is nothing wrong with that. s6-rc will populate 
it according to the compiled services you feed him.



i've taken a look at s6rc_livedir_create.c:

 
https://git.skarnet.org/cgi-bin/cgit.cgi/s6-rc/tree/src/libs6rc/s6rc_livedir_create.c

but nothing is leaping out to me as explaining what's happening.

Thoughts?


Alexis.

[a] The current s6 and s6-rc pages on the wiki have lot of detail,
without any "quickstart" tutorials that might make it easy for
people to get on board. A while ago i did a big restructure of the
s6 article:

  https://wiki.gentoo.org/wiki/User:Flexibeast/drafts/S6

which i feel improves the current page:

  https://wiki.gentoo.org/wiki/S6

but which has been awaiting review by a more senior wiki editor
than me.

The s6-rc page is similarly detailed and similarly lacking a
"quickstart":

  https://wiki.gentoo.org/wiki/S6-rc


Yeah, these definitely don’t help as much as they should, it’s a good thing 
someone decides on improving them, thanks for that. :)



[b] Various people are providing s6 service definitions,
e.g. https://codeberg.org/alecStewart1/gentoo-s6-scripts, but i'm
not
currently aware of any providing s6-rc service definitions -
pointers welcome. :-)


You can see my own outdated s6-rc system service definitions at:
* https://forge.dotslashplay.it/s6-rc/system-services
and my (also outdated) s6-rc user tree service definitions at:
* https://forge.dotslashplay.it/s6-rc/personal-services

Hoël


signature.asc
Description: PGP signature