You are not logged in.
Hi everyone,
I am fighting with systemd, I ExecStart a script but can not access any environment variable from it. How can I get back in my script any global environment variable, such as $HOME (and others)..
there is my service:
[Unit]
Description=xxx
Before=sleep.target
[Service]
User=%i
Type=forking
Environment=DISPLAY=:0
ExecStart=myscript
[Install]
WantedBy=sleep.targetI already dug a lot, I can not use any variable with the environment.d way. And I can not find a way to get back an os global environment variable from a script called from systemd, I would like something similar to os.environ in python.
Thanks for your time.
Last edited by Yann (2019-08-11 15:43:24)
all different - all equal
Offline
not sure, but can you try something like this:
Environment=User=%ihttps://balaskas.gr
Linux System Engineer - Registered Linux User #420129
Offline
$HOME is a shell environment variable so it will not be set by systemd or a service started by systemd which does not have a shell as its parent.
Offline
$HOME is only set if you specify User=, see https://github.com/systemd/systemd/issu … -441452963 .
Offline
Thanks for the answers.
%i will represent the user calling the script, however, as it needs to be root, I will be root. But I would like to be me in this case ![]()
Also, I am talking about any shell environment variable, $HOME was an example.
I do agree with the loqs comment .. Any tips to perform that?
Thanks for your time.
all different - all equal
Offline