I am trying to make an init.d script to launch my app.
I have two scripts, the first one is the init.d script myapp :
#!/bin/bash
export MYAPP_HOME="/srv/myapp"
su - myuser -c "exec $COMMAND_LINE"
The second is a script to launch myapp.
I want to use the variable MYAPP_HOME in the second script.
Can anybody help me ?
The problem is that you are creating a login shell by using the
-argument tosu, so a new environment is created. Either don’t use a login shell (omit the-), pass the variable as a command-line argument, or place the environment variable in one of the start-up files, like.bash_profile.