Slackware scripts started at boot time need env vars from /etc/profile.d/* to be set

environment-variablesrc.localslackware

Hey, I have this problem, that scripts started at boot time from rc.local don't have environment variables (defined at /etc/profile.d/*) set at the time of their startup. What should I do ?


"su – lisak -c /opt/atlassian-jira-enterprise-4.1.1-standalone/bin/startup.sh"

"su – lisak -c /opt/aaa2/at-22/bin/startup.sh"


Best Answer

The scripts at /etc/profile.d/* are executed in their own shells rather than sourced so the environment variables they set are not available anyway.What variables do you need? Can you make use of /etc/environment? Can you write the variables into a file in a var=value format from the appropriate scripts and source that file in your rc.local scripts?

This is from the Bash man page. You may find it helpful.

When bash is started non-interactively, to run a shell script, for example, it looks for the variable BASH_ENV in the environment, expands its value if it appears there, and uses the expanded value as the name of a file to read and execute. Bash behaves as if the following com‐ mand were executed: if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi but the value of the PATH variable is not used to search for the file name.

The Bourne shell similarly uses the ENV variable.

Related Topic