Line 102 of rhq-agent-wrapper.sh needs to be modified with after -e (Canonical, exists) after the readlink command, eg. # ------------------------------- # Get the location of this script. # Make sure we take into account the possibility $0 # is a symlink to the real agent installation script. _DOLLARZERO=`readlink -e "$0" || echo "$0"` This is because, at least under RHEL using chkconfig, the script called by init is a symlink to another symlink, the /etc/init.d/rhq-agent-wrapper -> /path/to/real/wrapper/file. This causes the following to happen: # # ../rc3.d/S93rhq-agent-wrapper.sh start # ++ readlink ../rc3.d/S93rhq-agent-wrapper.sh # + _DOLLARZERO=../init.d/rhq-agent-wrapper.sh # ++ dirname ../init.d/rhq-agent-wrapper.sh # + RHQ_AGENT_WRAPPER_BIN_DIR_PATH=../init.d Adding the -e option corrects this.. We also need to add some platform-check logic before this, as at least Solaris readlink does not support the -e option. -Mark
Correction: line 104
RHQ-2461 reported the same thing, but says you can use -f option to correct the problem. Does Solaris support the -f option?
No the Solaris version of readlink does not appear to support any options at all. However, in the case of Solaris 10, we should be providing an SMF init script[1], which obsoletes the need for readlink. [1]http://jira.rhq-project.org/browse/RHQ-2449
This bug was previously known as http://jira.rhq-project.org/browse/RHQ-2444 This bug is duplicated by RHQ-2461
Temporarily adding the keyword "SubBug" so we can be sure we have accounted for all the bugs. keyword: new = Tracking + FutureFeature + SubBug
making sure we're not missing any bugs in rhq_triage
we should test which works : -f or -e (or both?) we'll need to write this in such a way that it won't fail on solaris, since apparently neither switch is valid on solaris
readlink -e works on solaris 9 at least: # uname -sr SunOS 5.9 # ls -l /bin lrwxrwxrwx 1 root root 9 Mar 24 2009 /bin -> ./usr/bin # readlink -f /bin /usr/bin I think this should be an easy fix, assuming readlink's -f option is cross-platform across all unix flavors
The -e option is also available on solaris, which is probably the one we'd want to use: # uname -sr SunOS 5.9 # ls -l /bin lrwxrwxrwx 1 root root 9 Mar 24 2009 /bin -> ./usr/bin # readlink -e /bin /usr/bin
the basic change will be made to rhq-agent.sh, rhq-agent-wrapper.sh and rhq-server.sh... it goes something like this: if [ "x${_LINUX}${_SOLARIS}${_CYGWIN}" != "x" ]; then # only certain platforms support the -e argument for readlink _READLINK_ARG="-e" fi _DOLLARZERO=`readlink $_READLINK_ARG "$0" 2>/dev/null || echo "$0"` Note that we'll know what platform we are on via this switch: case "`uname`" in CYGWIN*) _CYGWIN=true ;; Linux*) _LINUX=true ;; Darwin*) _DARWIN=true ;; SunOS*) _SOLARIS=true ;; AIX*) _AIX=true ;; esac MacOS doesn't support the -e flag. Unknown if AIX does, so I leave that alone for now. The main issue is on Fedora/RHEL anyway. We can add ${_AIX} to that if-stmt if we know AIX's version of readlink supports -e
release-3.0.0 branch commit: 58c0104617caf09db42c7802e55d6df3fb420f81 To test: 1a) install an agent (I'll assume it is at /tmp/rhq-agent) 1b) install a server (I'll assume it is at /tmp/rhq-server) 2) Create two test directories: /tmp/test and a /tmp/test/subdir 3) Create a symlink to the agent and server scripts: ln -s /tmp/rhq-agent/bin/rhq-agent.sh /tmp/test/link.sh ln -s /tmp/rhq-agent/bin/rhq-agent-wrapper.sh /tmp/test/link-wrapper.sh ln -s /tmp/rhq-server/bin/rhq-server.sh /tmp/test/server-link.sh 4) Now create links to the links in that test subdir: ln -s /tmp/test/link.sh /tmp/test/subdir/another-link.sh ln -s /tmp/test/link-wrapper.sh /tmp/test/subdir/another-link-wrapper.sh ln -s /tmp/test/server-link.sh /tmp/test/subdir/another-server-link.sh 5) Turn on agent and server debug env vars so you can see the scripts' log messages on console: export RHQ_AGENT_DEBUG=true export RHQ_SERVER_DEBUG=true 6) Now run the links to the links (you don't need to run both agent and server together, we are just confirming the scripts themselves work and can determine the home directories OK - if they start the server and the agent fine its good - look at the debug logs on the console to confirm that RHQ_AGENT_HOME and RHQ_SERVER_HOME is set properly): /tmp/test/subdir/another-link.sh /tmp/test/subdir/another-link-wrapper.sh start /tmp/test/subdir/another-server-link.sh
*** Bug 615322 has been marked as a duplicate of this bug. ***
I tested this on Fedora11. I also confirmed this readlink argument fix works on Solaris 9. This fix is also applicable on Windows/Cygwin, though I didn't test that. This fix is not applicable on AIX or MacOS (AIX because I didnt know if readlink has -e on that platform, and MacOS because it doesn't look it -e is supported there). Therefore, this problem will probably still exist on AIX or MacOS - in those cases, just don't have symlink-to-symlink-to-script. This problem is showing up on RHEL/Fedora because of the way chkconfig creates symlink-to-symlink in rc3.d->init.d
Mass-closure of verified bugs against JON.