I recently attempted to run a boot up script which failed I didn't know why it failed so I posted a question about that here.
chkconfig bootup script failing, script runs good manually
Where the user schaiba suggested I add >> /tmp/test.log 2>&1 at the end of my start up script to log and figure why it doesn't start.
I realized that it has the following problem.
sudo: sorry, you must have a tty to run sudo failed
I looked in my script and found this line, pretty much the important line that starts up my java program. (which is the $cmd)
javaCommand="java" # name of the Java launcher without the path
javaArgs="-classpath .:recaptcha4j-0.0.8.jar:mysql-connector-java-3.0.17-ga-bin.jar ChatServer" # arguments for Java launcher
javaCommandLine="$javaCommand $javaArgs" # command line to start the Java service application
cmd="nohup $javaCommandLine >>$serviceLogFile 2>&1 & echo \$! >$pidFile"
# Don't forget to add -H so the HOME environment variable will be set correctly.
sudo -u $serviceUser -H $SHELL -c "$cmd" || return 1
When looking what to do with that error about sudo failing.. Lots of solutions state I should disable the Defaults require-tty in etc/sudoers which another article wrote would give me a security vulnerability where SSH users could see my root password, even though SSH already logs in root haha, anyways I don't want to disable any security.
My guess is I need to add that -H to some Home environment variable which I have no idea what that means anyone know what I have to do there?
Also $SHELL variable isn't found anywhere in the script, $serviceUser is another word for root.