S6 init system with s6-66 service manager in Antix-init-diversity spin

So Obarun should be OK, but the init spins, which are all Debian based, will need this modification.

A user will automatically get a global tree.
Is this the same global tree as root uses?

If I also make a user owned tree, which tree will it put services in?
and
I dont understand the connection between making a tree and setting up a scandir. They seem separate to me?

I understand s6-rc is also impacted by this.

Would it be possible to write a 66 service that resolves this?
eg
On user every user login a 66 service or module to do a

export PATH=ā€œ/lib/execline/bin:/usr/lib/execline/bin:/usr/libexec:$PATHā€

before running a scandir?

1 Like

Here is my edit

# Add sbin directories to PATH.  This is useful on systems that have sudo
#echo $PATH | grep -Eq "(^|:)/sbin(:|)"     || PATH=$PATH:/sbin
#echo $PATH | grep -Eq "(^|:)/usr/sbin(:|)" || PATH=$PATH:/usr/sbin
echo $PATH | grep -Eq ā€œ(^|:)/sbin(:|)ā€ || PATH=$PATH:/sbin:/lib/execline/bin:/usr/lib/execline/bin:/usr/libexec 
echo $PATH | grep -Eq ā€œ(^|:)/usr/sbin(:|)ā€ || PATH=$PATH:/usr/sbin:/lib/execline/bin:/usr/lib/execline/bin:/usr/libexec

and it fails

$ source ~/.bashrc
bash: /home/nevj/.bashrc: line 118: syntax error near unexpected token `('
bash: /home/nevj/.bashrc: line 118: `echo $PATH | grep -Eq ā€œ(^|:)/sbin(:|)ā€ || PATH=$PATH:/sbin:/lib/execline/bin:/usr/lib/execline/bin:/usr/libexec'

That is weird, the part with ( is unchangedā€¦ you just added to PATH
Oh, I see, discourse has substituted a different type of "
SOLVED

Discourse should not do thatā€¦ you put it in code box ?

1 Like

I think I used a blockquote. Is there a shortcut to use a code box?

$ 66 -t spice-tree start spice-vdagent
signal: info: Successfully started service: spice-vdagent-log
signal: info: Successfully started service: spice-vdagent
$ 66 tree status
Name        : spice-tree
Current     : no
Enabled     : yes
Allowed     : nevj
Groups      : user
Depends     : None
Required by : None
Contents    : None

Name        : global
Current     : no
Enabled     : yes
Allowed     : nevj
Groups      : user
Depends     : None
Required by : None
Contents    : spice-vdagent-log spice-vdagent

It has not moved spice-vdagent from global to spice-tree ?

The -t option is not working? It left it in the global tree
Maybe the frontend is defective and it failed before it put it in the spice-tree?
Here is the frontend

[main]
@type=classic
@description="spice-vdagent daemon"
@version=0.0.1
@user=(nevj)

[start]
@execute=(
    /usr/bin/spice-vdagent -d
)

66 start spice-vdagent fails
It needs to do
mkdir -p /run/spice-vdagent and a chmod
but it cant because user nevj does not have permission

and
the global tree as seen by root does not contain spice-vdagentd

# 66 tree status global
Name        : global
Current     : no
Enabled     : yes
Allowed     : root
Groups      : admin
Depends     : None
Required by : None
Contents    : dbus-log dbus seatd-log seatd slimski-log slimski
              connmand-log connmand nmbd-log nmbd smbd-log smbd ufw
              bluetoothd-log bluetoothd sshd-log sshd elogind-log
              elogind vsftpd-log vsftpd

so spice-vdagentd is not in any tree, but it still starts?
Found it, it is in the boot tree ??? How did it get there?

It seems my understanding of trees is deficient.

and I have to do

66 scandir create
66 scandir start

every time I boot , if I want to run user process.
The directory /run/66/scandir/1000 disappears
but the directory /run/66/scandir/0 does not disappear.
How can I make the user scandir permanent? ā€¦ or maybe user services are not meant to be permanent?

I havenā€™t used spice-vdagent to be too usefull but the way I understood the online dcumentation

spice-vdagentd & spice-vdagent are 2 different daemons:
spice-vdagentd : system-wide daemon (run as root)
spice-vdagent: an X11 session daemon (run as user - as I understand)

Command below

66 -t spice-tree enable spice-vdagent

adds spice-vdagent to spice-tree (I just realised I had posted wrong command earlier - sorry for that).

1 Like

Thanks for that. It may not be the only problem.

I am going to remove spice-vdagentdā€¦ to get it out of the boot treeā€¦ then start it from scratch again.

I think your understanding of the spice daemons is correct.
In some distros, spice-vdagent is triggered by a user starting an X sessionā€¦ so there could be more than one instance of the daemon in a multiuser system
In Antix it does not trigger, at least not with S6.

No, services for root and services for regular account are separated. if you look at /var/lib/66/system and ~/.66/system you will see the same directory structure but, /var/lib/66 contains your root services and at ~/.66/system contains your regular user services.

As i said before, 66 reacts as the same manner with root and regular user. With root service, by default if no tree are specified the service go to the global tree. Thatā€™s exactly the same for user service by default the service go the global tree. So, we have a global tree for root and an another global tree the user. These two trees are separated from each others.

yes, a tree contains services and a scandir is the place where services are monitored.

Sure that the role of the -e option at scandir start command. According to the help of the scandir create command :

$ 66 scandir start -h
scandir: usage: 66 scandir start [ -h ] [ -d notif ] [ -s rescan ] [ -e environment ] [ -b|B ]

start a scandir

options:
   -h: print this help
   -d notif: notify readiness on file descriptor notif
   -s rescan: scan scandir every rescan milliseconds
   -e environment: use environment as environment directory
   -b: create scandir (if it doesn't exist yet) for a boot process
   -B: create scandir (if it doesn't exist yet) for a boot process inside a container

With the -e option you can specify a directory which contain file declaring key=value pair.
As the environment variable is define at scandir start, every single service inherit from the scandir its environment variable. For instance, a file /etc/66/environment (or whatever the directory you choose to use) containing PATH=ā€œ/lib/execline/binā€ will be propagated to every service monitored by the scandir.

Ok, so dealing with user services is simple, as you saw a command applied as root user can also be applied to user service. Command and behavior are the same. So, in theory, starting a user service should be straightforward.
In practice, user service are a little more complicated to deal with mostly with an automatic way.

The very first problem is how i know if the user logon or logoff ?

The vast majority of user service make assumptions about the presence e.g. of the XDG_RUNTIME_DIR A.K.A. /run/user/<uid_of_user>. How i can create this repository as /run is owned by root and so user cannot create directly this directory?

User service also expect some well-known environment variable definition like XDG_DATA_HOME, SHELL, DISPLAY and so on. How i can define properly those variables?

As you can see, things goes in complexity. This is where user tracking software comes into play (consolekit, seatd, turnstile, utlogd, elogind, ā€¦).
Those software are responsible to track the user and prepare the things for the user login in or login out.

When an user login, the tracking user software used will define some variable like XDG_RUNTIME_DIR, create the directories and launch user services.

I will not come into details here, but i think you get the point here.

Well, i provided a service boot-user@ which can be used for that purpose in conjunction of any tracking user software. This service will prepare some good environment variables, configure your ~/.xinitrc or ~/.xession file, start the scandir for the user with environment variable and start service of the user.
To be honest, iā€™m not really happy of this service, but well, it works as expected.
This service need to be run as root user, then at some point it will drop privileges to start the scandir with the user privileges.

For instance, on my Obarun the boot-user@ service will go on a tree called session.

# 66 enable boot-user@nevj
# 66 configure boot-user@nevj # make the changes desired
# 66 reconfigure boot-user@nevj

Now, we need some extra service for the user like dbus. Dbus have two differents daemon like spice-vdagent, one for root and one for user.
So simple, as regular user

% 66 enable dbus@nevj

and voilĆ . At next reboot, the user service should be started when the user logon.

Note, if you want to make test about environment variable definition, start an user scandir using the -e option, then create the following frontend user service file at ~/.66/service/test_env

[main]
@type = oneshot
@version = 0.0.1
@description = "trying to test the environment variable"
@user = ( user )

[start]
@execute = ( printenv )

Finally,

% 66 start test_env
% 66 status -o logfile test_env

and 66 should display you the current environment variable define for the service.

3 Likes

Can confirm that this works

66 scandir start -e /etc/66/environment

& could be enabled (with conditional checks that 66 is running) as contents of

~/.desktop-session/startup

However I see this as a workaround.

I couldnā€™t figure out a way for 66 to do this in antiX, I tried compiling boot-user & scandir-0.4.1 services from the Obarun gitlab but for some reason they donā€™t work on antiX

look at /usr/bin/init, it should declare something like

66 boot -e <environment_directory>

the boot command is responsible to create the primary scandir (PID1) and start it. So, the boot command pass the -e option to the scandir start command. The loop is closed.

I think I must have not explained my problem correctly:

There isnā€™t a problem with the root (PID1) services & scandir.
Root services & trees work perfectly (the init we are using passes the -e correctly on boot )

The problem I am struggling with is starting user services & trees automatically after logging in, as a user:

eg when I freshly log-in there are no user services up (although enabled) & running

demo@init-diversity:~
$ 66 start foo
start: fatal: scandir: /run/66/scandir/1000 is not running: No such file or directory

I have to run:

demo@init-diversity:~
$ (66 scandir start -e /etc/66/environment &)& 
[1] 31513
demo@init-diversity:~
$ 66 start foo
start: info: Initialized successfully: foo
signal: info: Succesfully started service: foo
[1]+ Done
demo@init-diversity:~

and the service starts (but this doesnā€™t persist a reboot even when enabled)

2 Likes
66 remove spice-vdagentd
removes it from boot@system tree
66 start spice-vdagentd
parses it and starts in in theglobal tree , where it should be.

Now, how do I correctly setup a user service spice-vdagent?

nevj@antix-init-diversity:~
$ (66 scandir start -e /etc/66/environment &)& 
[1] 3342
nevj@antix-init-diversity:~
$ scandir: info: create scandir /run/66/scandir/1000 ...

[1]+  Done                    ( 66 scandir start -e /etc/66/environment & )
nevj@antix-init-diversity:~
$ 66 start spice-vdagent
start: info: Initialized successfully: spice-vdagent
start: info: Initialized successfully: spice-vdagent-log
signal: info: Successfully started service: spice-vdagent-log
signal: info: Successfully started service: spice-vdagent
nevj@antix-init-diversity:~
$ ps ax | grep spice
 1751 ?        S      0:00 s6-supervise spice-vdagentd-log
 1752 ?        S      0:00 s6-supervise spice-vdagentd
 1759 ?        Ss     0:00 /usr/bin/s6-log -d3 n3 s1000000 /var/log/66/spice-vdagentd
 1763 ?        Ssl    0:00 /sbin/spice-vdagentd -x -d
 3761 pts/1    S      0:00 s6-supervise spice-vdagent-log
 3762 pts/1    S      0:00 s6-supervise spice-vdagent
 3769 ?        Ss     0:00 /usr/bin/s6-log -d3 n3 s1000000 /home/nevj/.66/log/spice-vdagent

so I still have an issue, probably with the frontend for spice-vdagent.

Name                  : spice-vdagent
Version               : 0.0.1
In tree               : global
Status                : disabled, down (exitcode 1) 0 seconds, normally up, want up, ready 0 seconds

So it starts then stops ?
Look at log

$ 66 -v 4 start spice-vdagent
start: (debug_flag(): 74): tracing: requested flags to build the graph:  toparse topropagate wantup
....
signal: (doit(): 374): tracing: sending -wu -u to: /run/66/scandir/1000/spice-vdagent
signal: (state_write(): 52): tracing: write status file at: /run/66/state/1000/spice-vdagent/state/status
signal: (announce(): 216): tracing: delete down file: /run/66/scandir/1000/spice-vdagent/down
signal: (announce(): 230): info: Successfully started service: spice-vdagent

So there is no error logged. It starts by hand


$ spice-vdagent -x 
spice-vdagent[11567]: vdagent started
spice-vdagent[11567]: display: failed to call GetCurrentState from mutter over DBUS
spice-vdagent[11567]:    error message: Cannot invoke method; proxy is for the well-known name org.gnome.Mutter.DisplayConfig without an owner, and proxy was constructed with the G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START flag
spice-vdagent[11567]: No guest output map, using output index as display id
spice-vdagent[11567]: Received Graphics Device Info:

$ ps ax | grep spice
 1751 ?        S      0:00 s6-supervise spice-vdagentd-log
 1752 ?        S      0:00 s6-supervise spice-vdagentd
 1759 ?        Ss     0:00 /usr/bin/s6-log -d3 n3 s1000000 /var/log/66/spice-vdagentd
 1763 ?        Ssl    0:00 /sbin/spice-vdagentd -x -d
10746 pts/1    S      0:00 s6-supervise spice-vdagent-log
10747 pts/1    S      0:00 s6-supervise spice-vdagent
10754 ?        Ss     0:00 /usr/bin/s6-log -d3 n3 s1000000 /home/nevj/.66/log/spice-vdagent
11567 pts/0    Sl     0:00 spice-vdagent -x

The error message mentions dbusā€¦ it may be something to do with user dbus?
Will investigate

@obarun

The XDG_RUNTIME_DIR is not /run/user/1000

 nevj@antix-init-diversity:~
$ echo $XDG_RUNTIME_DIR
/tmp/1000/.run

does that matter? It contains

$ ls -F .run
dbus-1/      pipewire-0.lock      pipewire-0-manager.lock
pipewire-0=  pipewire-0-manager=  pulse/

No I think that is OK.
I think I need to be looking at boot-user@

1 Like

@obarun
I have downloaded compiled & installed the boot-user & scandir-0.4.1 service modules

demo@init-diversity:~
$ sudo 66 start boot-user@demo
start: info: Initialized successfully: boot-user@demo
start: info: Initialized successfully: scandir@demo
signal: info: Successfully started service: slimski-log
signal: info: Successfully started service: slimski
signal: info: Initialized successfully: scandir@demo:setenv@demo
signal: info: Successfully started service: seatd
signal: info: Successfully started service: seatd-log
signal: info: Successfully started service: scandir@demo:svscan@demo-log
signal: warning: unable to start service: scandir@demo:setenv@demo -- exited with signal: 111
signal: warning: unable to start service: scandir@demo -- exited with signal: 111
demo@init-diversity:~
$ sudo 66 reconfigure boot-user@demo
signal: info: Successfully stopped service: boot-user@demo
stop: info: Unsupervised successfully: boot-user@demo
stop: fatal: unable to find hash id of: boot-user@demo:mount-run@demo -- please make a bug reports

I obviously did a configure & a reconfigure of the modules before trying to start them, contents of how they were configured below:

demo@init-diversity:~
$ sudo 66 configure -e nano boot-user@demo
## Uncomment it to use a display manager.
## Can be any display manager as long as the
## corresponding frontend file exist on your system
## e.g sddm,lightdm,...
## It also prepare the .xsession file.
DISPLAY_MANAGER=slimski
## Uncomment it to use a console tracker.
## Can be any console tracker as long as the
## corresponding frontend file exist on your system
## e.g consolekit,seatd,turnstile,...
CONSOLE_TRACKER=seatd
## Create and mount the XDG_RUNTIME directory
## at /run/user/demo [yes|no]
XDG_RUNTIME=!yes
## Command to use in your .xinitrc
## to launch your desktop e.g.: openbox-session.
## If commented the .xinitrc file is not configured.
DESKTOP_CMDLINE=!icewm
sudo 66 configure -e nano scandir@demo
## Run the scandir at LIVE_DIRECTORY.
## Need to be an absolute path.
## If commented the default is /run/66
#LIVE_DIRECTORY=/run/66
## Create an associated logger [yes|no]
LOGGER=!yes
## Launch the scandir with a environment [yes|no].
## The environment directory is: $HOME/.66/conf/svscan@demo
USE_ENVIRONMENT=!yes
## Use notification [yes|no]
NOTIFY=!yes
## Level of verbosity [0-5]
VERBOSITY_LEVEL=!3
2 Likes

This is curious as runtime directory but why not. It seems to be populated correctly

1 Like

Apparently you hit a bug. But i cannot reproduce it.
Can you please send me a email at eric@obarun.org with an archive containing your /usr/share/66/service/{boot-user, scandir} and /etc/66/service/{boot-user@demo,scandir@demo} directories?

2 Likes

I have just emailed those through.

While you are trying to debug that , I thought I would test spice-vdagent as root .
So
start spice-vdagentd first
Make a frontend in /etc/66/service
66 parse spice-vdagent
66 start spice-vdagent
it does not start

#66 status spice-vdagent
root@antix-init-diversity:/home/nevj# 66 status spice-vdagent
Name                  : spice-vdagent
Version               : 0.0.1
In tree               : global
Status                : disabled, down (exitcode 1) 0 seconds, normally up, want up, ready 0 seconds
Type                  : classic
Description           : spice-vdagent daemon
Part of               : None
Notify                : 0
Max death             : 5
Earlier               : 0
Source                : /etc/66/service/spice-vdagent
Live                  : /run/66/scandir/0/spice-vdagent
Dependencies          : spice-vdagent-log
Required by           : None
Contents              : None
Optional dependencies : None
Start script          : 
                        #!/usr/lib/execline/bin/execlineb -P
                        /usr/lib/execline/bin/fdmove -c 2 1
                            /usr/bin/spice-vdagent -x 
Stop script           : 
                        None
Environment source    : None
Environment file      : None
Log name              : spice-vdagent-log
Log destination       : /var/log/66/spice-vdagent
Log file              : 

(spice-vdagent:18693): Gtk-WARNING **: 10:31:10.342: cannot open display: 
spice-vdagent[18697]: vdagent started

(spice-vdagent:18697): Gtk-WARNING **: 10:31:11.367: cannot open display: 
spice-vdagent[18701]: vdagent started
5 more messages the same

Do you know what the message means?
It is in a display window ( in the VM) .

root@antix-init-diversity:/etc/66/service# echo $XDG_RUNTIME_DIR
/tmp/1000/.run

It does the same if I login to the VM with ssh, only then XDG_RUNTIME_DIR is not set.

It seems spice-vdagent interacts with X in some way.

The man page says
ā€œspice-vdagent gets automatically started in desktop environments
which honor /etc/xdg/autostart, and under gdm.ā€
but does not mention any other type of interaction with X.

So spice-vdagent has problems not related to 66 user services.

I tried installing the package xdg-desktop-portal-gtk. It had no effect.
xhost + does not help

trying to find the troubleā€¦

2 Likes

That means that the DISPLAY variable is not set at your service environment variable. Something like DISPLAY=:0

1 Like