Any environment variable you want to make available for a whole
supervision tree should be added via a "-e var=value" option to your
s6-linux-init-maker invocation.
Thanks, will do!


 For user supervision trees, I suppose you're not using s6-l-i-m, so
the best place would be to put the variables in an envdir and use
"-E $envdir" (and possibly "-e $var" if you need to substitute $USER
or something) in your s6-usertree-maker invocation. If you're not using these tools, the best way is to do the same thing
they do: put the variables in an envdir somewhere, and source the envdir
both before running s6-svscan and before running your s6-rc-init and
s6-rc script.
I tested s6-usertree-maker, but I does not do everything I need. Anyway, I based my currently working scripts on its output.

This is how it looks right now:


${USER}-sv/run:

#!/bin/execlineb -P

fdmove -c 2 1

define USER Nanderty
define XDG_RUNTIME_DIR /run/${USER}

emptyenv -p

export USER ${USER}

s6-envuidgid -i ${USER}

backtick -in HOME { homeof ${USER} }

multisubstitute
{
  importas -Si USER
  importas -Si HOME
  importas -Si UID
  importas -Si GID
  importas -Si GIDLIST
}

foreground install -d -o ${USER} -g ${USER} -m 700 ${XDG_RUNTIME_DIR} ""
foreground install -d -o ${USER} -g ${USER} /var/log/${USER} ""
foreground install -d -o ${USER} -g ${USER} ${XDG_RUNTIME_DIR}/service ""

export XDG_DATA_HOME ${HOME}/.local/share
export XDG_STATE_HOME ${HOME}/.local/state
export XDG_CACHE_HOME ${HOME}/.cache
export XDG_RUNTIME_DIR ${XDG_RUNTIME_DIR}
export DBUS_SESSION_BUS_ADDRESS unix:path=${XDG_RUNTIME_DIR}/session-bus

s6-applyuidgid -U

s6-svscan -d3 ${XDG_RUNTIME_DIR}/service


${USER}-sv/finish:

#!/bin/execlineb -P

define USER Nanderty

rm -rf /run/${USER}


${USER}-rc/up:

#!/bin/execlineb -P

fdmove -c 2 1

define USER Nanderty

s6-setuidgid ${USER}

foreground {
    s6-rc-init -c /home/${USER}/.local/share/s6-rc/compiled -l /run/${USER}/s6-rc /run/${USER}/service
}

s6-rc -v2 -l /run/${USER}/s6-rc -up change default


${USER}-rc/down:

#!/bin/execlineb -P

define USER Nanderty

s6-setuidgid ${USER}

s6-rc -l /run/${USER}/s6-rc -bDa change

Plus, of course, the catch all logger for the ${USER}-sv process.

I would just export the logging dir variable as I do with the XDG_* vars, so I do not need to source a variable dir. I would need to define them in this script anyway, if I do not want to use the env-dir as a permanent external config file.

Would you consider it a better way to utilize an env-dir as a means of a config and source it in ${USER}-sv/run, thus exporting the vars for all child processes anyway?


Thank you for your input.


Paul

Attachment: OpenPGP_0x71C7C85A2EA30F62.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to