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 ?
su <username> -c "<command>"inherits the current environment. The OP's issue is that they had-, specifying a login shell.