Init.d script gets return code 1 when calling itself, how can I get output?
- by Per
My question is, how can I modify the script so that it will tell me what goes wrong?
The scenario is this:
I'm trying to get Sonatype Nexus to start as a service in Ubuntu 10.04, and it just will not work.
(I'm not looking for help on how to run Nexus, but on how to get some useful output from a script)
It works when invoking it with
sudo /etc/init.d/nexus start
but fails when using
sudo service nexus start
I have run the update-rc.d command on it, and done everything according to instructions.
The nexus init.d-script has a point where it calls itself when it detects that it should run as another user ('nexus'):
su -m $RUN_AS_USER -c "\"$REALPATH\" $2"
which expands to
su -m nexus -c '"/opt/nexus-2.0.2/bin/jsw/linux-x86-64/nexus" start'
when adding the -x debug flag to the script. This command results in return code 1. It never executes - I've set -x debug flag on the script, placed echo commands with redirect to file at the start of script to trace, etc.
I cannot get any output telling me why the command will not execute. I've tried appending redirect to file after the above script line, inside the quotes, outside, any way I could imagine. All info I can get is by inserting a line
echo $?
after the su line, which outputs '1'.
Is there a way I can see what happens when the su command runs?