I'm writing a shell script to start a few processes for me. Because those processes need sudo access, I run my shell script with sudo. However, I don't have access to my path variables when I do that. I've added a shell script to /etc/profile.d/extra-path.sh that adds those for my user.
Could someone tell me the way I should add those path variables so they can be accessed in the shell script run with sudo, or is there a way to run the commands with my user path in the shell script itself?
Here's the script I'd like to have work:
#!/bin/bash
#start stuff up
nohup mongod
#mongod fails as an unknown command, even though it's part of my path
nohup /cust/env/local/cust/jboss-5.1.0.GA/bin/run.sh -b 0.0.0.0 -Djava.awt.headless=true
#jboss needs access to the JAVA_HOME path variable which
#doesn't exist on the path used in this shell script
man sudoers, you can fiddle around withsecure_path,env_reset,env_keep,env_check, or possibly evenexempt_group.