I'm running RHEL 6.8 for this task. My goal is to create a service that is supposed to kick off a process (it's a Java app) that runs as a different user. The problem that I'm encountering is that whenever I start up this process as a different user, not all of the environment variables are included that of the user.
As user foo, logged in, I get one set of environment variables. As root, I get a second set. And when I do
# sudo -E -u foo env I get a completely third set of variables.
Whenever I use gnome-terminal to run the same application, it works fine. All of the environment variables are included as they should be. My question is, how can I include the same environment variables while running the program as a service in run levels 3, 4 and 5?
I'd like to avoid having to hard code these variables in the script itself.