Content of /opt/scripts/jvm/jvm.script.sh
#!/bin/bash JAVA_HOME='/java' PATH="$PATH:/$JAVA_HOME/bin" java -cp ./classes:./lib com.mystuff.bar.foo.myclass &
Content of /etc/init.d/init.script.sh
home='/opt/scripts/jvm' program=jvm.script.sh su scriptuser -c "$home/$program"
/opt/scripts/jvm
is symlinked to /data/shellscripts
(meaning /data/shellscripts
exists as a real directory).
Running the init script fails with cannot find class com.mystuff.bar.foo.myclass
but if I su to the same user and run it, it works, why?
When I run su scriptuser -c 'declare -p JAVA_HOME'
I get JAVA_HOME not found
, but if I su to the user first (using su scriptuser
) and run it, I get JAVA_HOME="/java"
This may sound crazy, but it seems to fix the issue if I add a trailing slash to the home variable in the init script.
So:
home='/opt/scripts/jvm'
becomes
home='/opt/scripts/jvm/'
It almost seems like something environmental is messing with the way the symlinks are being handled.
declare -p JAVA_HOME
?su scriptuser
or withsu - scriptuser
?