I'm working on an embedded device that runs Yocto Poky as distro.
The final product will have several applications that are started by
SysVinit. There is only one
I have some scripts, both in
/etc/profile.d that add some environment variables needed by our applications. The problem I'm facing is that, if I run the app "by hand" (so I have an interactive shell) they run nicely, since the scripts in
/etc/profile.d/ were sourced, but when ran by
SysVinit, they cannot find the environment populated (obviously). We are using
sh as shell.
I read about different files like
.profile and some variables like
BASH_ENV. I tried to define my variables there, but without luck. A small workaround I found is launching my main application in a login shell (from
2:12345:once:/bin/sh -lc /usr/bin/my_app
So my questions are:
- How can I set the environment during boot (aka without logging in) or let
SysVinitdo it in a nice way?
- The exports performed in
/etc/init.dscripts do not propagate to my environment at all; that's because those scripts are run in a subshell, and not sourced in the current one (that will required login two) I guess, so how can I export variables from there?
- Is my workaround a valid solution?