Bug 534611 (RHQ-1391) - Can't run rhq-agent-wrapper.sh as a service if it is symlinked.
Summary: Can't run rhq-agent-wrapper.sh as a service if it is symlinked.
Keywords:
Status: CLOSED NEXTRELEASE
Alias: RHQ-1391
Product: RHQ Project
Classification: Other
Component: Agent
Version: 1.2
Hardware: All
OS: All
high
medium vote
Target Milestone: ---
: ---
Assignee: John Mazzitelli
QA Contact: Corey Welton
URL: http://jira.rhq-project.org/browse/RH...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-01-22 18:27 UTC by Corey Welton
Modified: 2018-01-15 15:21 UTC (History)
0 users

Fixed In Version: 1.2
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Red Hat Enterprise Linux Server release 5.2 (Tikanga) Kernel \r on an \m Linux rlx-0-12.rhndev.redhat.com 2.6.18-92.1.22.el5 #1 SMP Fri Dec 5 09:29:46 EST 2008 i686 i686 i386 GNU/Linux
Last Closed:
cwelton: archived+


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Bugzilla 1088032 None None None Never

Internal Links: 1088032

Description Corey Welton 2009-01-22 18:27:00 UTC
Per new behaviour for rhq-agent, config for running agent as a service includes symlinking to the actual location of the rhq-agent-wrapper.sh script.  Agent fails to launch, however, after doing this.

Steps to repro.

1.  `ln -s /root/rhq-agent/bin/rhq-agent-wrapper.sh  /etc/init.d/rhq-agent-wrapper.sh`
2. `service rhq-agent-wrapper.sh`
3.  optional:  enable debug (add  export RHQ_AGENT_DEBUG=true to top of  rhq-agent-wrapper.sh)
4. View results

Current result.
[root@rlx-0-12 ]# service rhq-agent-wrapper.sh start
Starting RHQ Agent...
ERROR! Cannot find the RHQ Agent start script
Not found: /etc/bin/rhq-agent.sh

If debug enabled:
[root@rlx-0-12 ]# service rhq-agent-wrapper.sh start
rhq-agent-wrapper.sh: RHQ_AGENT_WRAPPER_BIN_DIR_PATH=/etc/init.d
rhq-agent-wrapper.sh: pidfile will be located at /etc/bin/rhq-agent.pid
ERROR! Cannot find the RHQ Agent start script
Not found: /etc/bin/rhq-agent.sh


Expected result:
Agent launches.

Comment 1 John Mazzitelli 2009-01-22 18:31:38 UTC
the problem is this line in rhq-agent-wrapper.sh:

RHQ_AGENT_WRAPPER_BIN_DIR_PATH=`dirname "$0"`

$0 is the value of the sym link, not the real script itself.

Will need to use "readlink" here - need to example $0 and if its a symlink, use "readlink" to get the "real" file that the link points to.

Comment 2 John Mazzitelli 2009-01-22 19:18:12 UTC
Now using the following to follow symlinks - if the script isn't a symlink, it still works:

_DOLLARZERO=`readlink "$0" || echo "$0"`

So, we can now use "$_DOLLARZERO" for the "real" script path, e.g.:

RHQ_AGENT_WRAPPER_BIN_DIR_PATH=`dirname "$_DOLLARZERO"`


Comment 3 Charles Crouch 2009-01-22 23:22:56 UTC
How many flavors of *nix has this been tested on ?

Comment 4 John Mazzitelli 2009-01-22 23:31:48 UTC
This will work on all UNIX's that have "readlink" available and in the path, which from what it looks like is all the ones we care about (I see this working on solaris, rhel and fedora - unsure if readlink is available on aix, hpux, macos - but workaround is simple - provide readlink access to the user running the agent :)

Comment 5 Corey Welton 2009-01-26 18:13:55 UTC
QA Verified.

Comment 6 Red Hat Bugzilla 2009-11-10 20:31:57 UTC
This bug was previously known as http://jira.rhq-project.org/browse/RHQ-1391
This bug relates to RHQ-1752



Note You need to log in before you can comment on or make changes to this bug.