I have a server which runs Fedora 19. When the server boots up, I need to run bunch of commands. I do this in
/etc/rc.d/rc.local file. This works well. Now I need to start my
nodejs server from this script.
I don't want to start the server program as
root. So I tried something like the following in the
su myuser -c /home/myuser/project/path/prod_start.sh
myuser. But in
prod_start.sh, I am changing the directory to the applications root directory. It also expects some environment variables to be set before running. But since these environment variables are defined in
bash_profile for user
myuser, none of them took effect and the the script failed.
I'm wondering how I can run a command as a different user with all the environment variables required set for him? Should I set all these environment variables at the system level so that it is available to all users?