I am trying to modify /etc/init.d/jenkins
script, in order to add my custom java path. My solutions is this:
JAVAPATH=$(type -p java)
PATH=/bin:/usr/bin:/sbin:/usr/sbin:$JAVAPATH
However, when I start the service and look into the logs, I see JAVAPATH variable is empty. On the other hand, if I write, for instance:
PYPATH=$(type -p python)
PATH=/bin:/usr/bin:/sbin:/usr/sbin:$PYPATH
Then PATH variable will include python binary perfectly.
My final goal is removing the file name, just saving dirname so:
JAVAPATH=$(type -p java | xargs dirname)
On my custum scripts and tests, everything works fine, so I assume there is something with java that I don't know. I'm running a Debian 10 and my java path is /usr/lib/jvm/jdk-11.0.9/bin/java
Thanks in advance.
Regards
PATH
should not contain paths to binaries (likejava
andpython
), it should contain paths to directories that the binaries are in. Furthermore,type -p
will only find paths to binaries in directories that're already inPATH
(i.e. those that don't need to be added because they're already there).