Date
1 - 3 of 3
[OE-core] How to trigger Yocto Linux /etc/profile or shell scripts in /etc/profile.d without shell logging in?
Federico Pellegrin
Hi Jupiter, /etc/profile and similar are interactive shell (/bash) concepts, not really system startup ones. So indeed: just on a login (be it local, ssh and so on) they are executed. If you want to execute something else without the need for logging it, you should look elsewhere, depending on your system manager: if systemd you should create a service and enable it, if sysvinit a init.d script. HTH, Federico
Il giorno lun 11 ott 2021 alle ore 06:30 JH <jupiter.hce@...> ha scritto: Hi,
|
|
JH
Hi Federico,
Thanks for your response. /etc/profile and similar are interactive shell (/bash) concepts, not reallyUnderstood, here is what I try to figure out. I use several systemd services to start my tasks, each task is not just a system process, I found it also has a system environment similar in user login from /etcprofile, /home/user/.profile, my question is where is a system environment file that each systemd service runs from? I also thought that /etc/profile.d files should be automatically invoked for each user login, but a systemd service does not run /etc/profile.d files. If you want to execute something else without the need for logging it, youUnderstood, that was what I did originally, I have to run the setup system environment in each service ExecStart script, that is why I am looking for a global environment setup file to avoid duplication of putting my environment scripts in each ExecStart execution file. Thank you. Kind regards, - jupiter HTH, -- "A man can fail many times, but he isn't a failure until he begins to blame somebody else." -- John Burroughs
|
|
Federico Pellegrin
Hi Jupiter, To centralize, agreed that you are using systemd, one way I could see is setting the variables in systemd-system.conf using the DefaultEnvironment directive, see: https://freedesktop.org/software/systemd/man/systemd-system.conf.html This states: ---- DefaultEnvironment= ΒΆConfigures environment variables passed to all executed processes. Takes a space-separated list of variable assignments. See environ(7) for details about environment variables. Simple " Example: DefaultEnvironment="VAR1=word1 word2" VAR2=word3 "VAR3=word 5 6"
Sets three variables
" ---- This should have you variables management in each. Otherwise as you mention one can put in each script with either Environment to have them explicitly enumerated or with EnvironmentFile to read from a file, which may also fit your centralization hopes (but still require one line per startup script at least) and could be further sourced by non-systemd components as well if needed. (https://www.freedesktop.org/software/systemd/man/systemd.exec.html under Environment section) HTH, Federico
Il giorno lun 11 ott 2021 alle ore 11:05 Jupiter <jupiter.hce@...> ha scritto: Hi Federico,
|
|