Handling environment in s6

2020-11-10 Thread billa chaitanya
Hi team,

Is there anything in s6 equivalent to below of systemd?

/bin/systemctl set-environment SERVICEFILE=$SERVICEFILE

Thanks,
Chaitanya


Re: Handling environment in s6

2020-11-10 Thread Laurent Bercot

Is there anything in s6 equivalent to below of systemd?

/bin/systemctl set-environment SERVICEFILE=$SERVICEFILE


 There is not.
 The process supervisor itself (s6-supervise) and the service scanner
(s6-svscan) do not use the environment. Services can define their
own environment in their run script.

 There are several tools that help you define an environment in a run
script. The most idiomatic one is s6-envdir:
 https://skarnet.org/software/s6/s6-envdir.html

 If you have EnvironmentFiles that come from systemd, or overall
prefer to define your environment variables in a file, you may find
the envfile program useful - it's in the execline package:
 https://skarnet.org/software/execline/envfile.html

 Or you can simply write your run script in shell, and define your
environment variables via the shell syntax, or via sourcing a file,
as a lot of distributions do with /etc/default/*.conf or similar
mechanisms.

 Providing a command that changes the supervisor's environment at
run time is one of the many useless - and in this case, harmful -
features of systemd. It is harmful because it introduces changes
between what's written on disk (which is what will happen at boot time,
and what the user can see when studying files) and the current state
of the supervisor, so future service operations will violate the
principle of least surprise. It destroys the "if it's working now then
it will work after I reboot" property. And of course having the
supervisor rely on externally modifiable environment variables makes
it more vulnerable.

 If I'm judging from your recent batch of questions these last few
weeks, you are trying to convert a set of systemd services to a s6
installation. This is a very good idea (;)) and I commend you for
taking up this task.
 However, listing all the systemd features and asking 'how do I
accomplish this in s6?' is not the right way to go about this. The
systemd features have been designed with the systemd mindset, and
individually they make sense (or not) in the context and with the
architecture of systemd. Trying to exactly map the features one-to-one
would result in writing another systemd behemoth, as the author of
uselessd discovered to their dismay.

 The s6 mindset is very different from the systemd one, and there is
no direct mapping from one to the other. In order to convert a set of
services, you need to take a step back and look at the big picture:
what high-level functionality do I need? how am I expressing that
functionality with systemd? what is the way to express it with s6?
It requires a deeper rework than just a syntactic one, which is why it
is really difficult to write an automatic converter, and why it is also
generally difficult to answer questions like yours without going into
the details of what exactly you're trying to do.

--
 Laurent



Missing "$@" at the end of the s6-linux-init invocation in basedir/bin/init script

2020-11-10 Thread Muhammad Mahendra Subrata

Hello everyone,

I don't know if this problem is specific to me or I just missed some 
steps, after running s6-linux-init-maker with below invocation:


s6-linux-init-maker -c /etc/s6/init/current -u adm -G 'agetty 38400 
tty12 linux' -1 -p '/usr/bin:/usr/sbin:/bin:/sbin' -t 2 -D 3 
/etc/s6/init/current


I got the generated /etc/s6/init/current/bin/init script like below:

#!/bin/execlineb -S0

s6-linux-init -c "/etc/s6/init/current" -m 0022 -p 
"/usr/bin:/usr/sbin:/bin:/sbin" -D "3"


Using that generated script, I tried to boot my system by adding "4" in 
kernel command line hoping that it will boot to that runlevel instead of 
the default one (in this case it's 3) but it still booted to runlevel 3. 
I then looked at other scripts inside /etc/s6/init/current/bin and all 
of them had "$@" at the end of their respective s6-linux-init-* 
invocation. So I tried adding "$@" at the end of s6-linux-init 
invocation in /etc/s6/init/current/bin/init and tried booting to 
runlevel 4 again using kernel command line option as before and it 
booted successfully to runlevel 4.


So, is that "$@" supposed to be there or not?

Thanks!



Re: Missing "$@" at the end of the s6-linux-init invocation in basedir/bin/init script

2020-11-10 Thread Laurent Bercot

So, is that "$@" supposed to be there or not?


 It absolutely is! You found a bug. Thanks for the report!
 Now fixed in release 1.0.5.1, which I cut immediately because it is
pretty critical.

--
 Laurent