Bug 1158948

Summary: rhqctl start on solaris 10 shows error- Cannot find the RHQ Agent start script
Product: [JBoss] JBoss Operations Network Reporter: Sunil Kondkar <skondkar>
Component: InstallerAssignee: John Mazzitelli <mazz>
Status: CLOSED CURRENTRELEASE QA Contact: Mike Foley <mfoley>
Severity: high Docs Contact:
Priority: unspecified    
Version: JON 3.3.0CC: hrupp, jmorgan, loleary, mazz, mithomps, myarboro, spinder
Target Milestone: CR03   
Target Release: JON 3.3.0   
Hardware: x86_64   
OS: Solaris   
Whiteboard:
Fixed In Version: Doc Type: Known Issue
Doc Text:
Cause: Bad syntax in rhq-agent.sh and rhq-agent-wrapper.sh - they use $() syntax which is not valid on Solaris 10. Consequence: The agent fails to start. Workaround (if any): Delete line 155 in rhq-agent-wrapper.sh and replace line 96 in rhq-agent.sh with "echo" Result: The agent can now start.
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-12-11 14:01:31 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description Sunil Kondkar 2014-10-30 14:54:49 UTC
Description of problem:

Installed JON 3,3 ER05 build on solaris 10 using Bourne Shell with rhqctl install.
When tried to start with rhqctl start, at the last stage, it shows below error:

Starting RHQ Agent...
ERROR! Cannot find the RHQ Agent start script
Not found: ./bin/rhq-agent.sh

-----------

JON is installed at: /export/home/JON3.3ER05/jon-server-3.3.0.ER05
rhq-agent is at : /export/home/JON3.3ER05/rhq-agent

Also checked that rhq-agent.sh exists at /export/home/JON3.3ER05/rhq-agent/bin


Version-Release number of selected component (if applicable):

JON 3,3 ER05

How reproducible:

Always

Steps to Reproduce:
1. On solaris 10, do ./rhqctl install
2. then ./rhqctl start
3. At the end, it shows the error: 
ERROR! Cannot find the RHQ Agent start script
Not found: ./bin/rhq-agent.sh

Actual results:

rhqctl start shows error and could not find the RHQ Agent start script. RHQ Agent does not start.

Expected results:

rhqctl start works and agent starts successfully

Additional info:

Comment 2 John Mazzitelli 2014-10-30 16:23:35 UTC
i think this works. in rhq-agent-wrapper.sh, in the if-stmt for when there is no readlink:

_WORKINGPATH="`dirname \"$0\"`"
_WORKINGPATH="`(cd \"$_WORKINGPATH\" && pwd )`"
_DOLLARZERO="$_WORKINGPATH"/rhq-agent-wrapper.sh

Comment 3 John Mazzitelli 2014-10-30 16:31:22 UTC
MASTER:

commit 029ef29dc2f25dc34b899058ea8bb06588e4d5da
Author: John Mazzitelli <mazz@redhat.com>
Date:   Thu Oct 30 12:29:50 2014 -0400

    BZ 1158948 - make sure agent can start/stop via rhqctl on solaris 10

3.3 BRANCH:

commit dfbe1e04fd55bb12bf050128b0c9fe9288c53714
Author: John Mazzitelli <mazz@redhat.com>
Date:   Thu Oct 30 12:29:50 2014 -0400

    BZ 1158948 - make sure agent can start/stop via rhqctl on solaris 10
    (cherry picked from commit 029ef29dc2f25dc34b899058ea8bb06588e4d5da)

Comment 4 Simeon Pinder 2014-11-14 04:48:16 UTC
Moving to ON_QA as available for test with build:
https://brewweb.devel.redhat.com//buildinfo?buildID=398756

Comment 5 Sunil Kondkar 2014-11-17 14:27:51 UTC
Tested on version : 3.3.0.GA Build Number : f8f6447:6a2b52e

Solaris version: SunOS solaris10 5.10 Generic_147148-26 i86pc i386 i86pc
Shell: /bin/sh
-------------------------------------------------

 On solaris 10, installed JBoss ON with rhqctl install, when executing rhqctl start, it shows syntax error as below:

 INFO 19:10:02,736 Startup completed! Now serving reads.
WARNING: The readlink command is not available on this platform.
         If this script was launched from a symbolic link, errors may occur.
         Consider installing readlink on this platform.
Trying to start the RHQ Server...
RHQ Server                     (pid 3161   ) is starting
./rhq-agent-wrapper.sh: syntax error at line 155: `_DOLLARZERO=$' unexpected

-------

Comment 7 John Mazzitelli 2014-11-17 16:04:55 UTC
The problem was introduced by $() syntax that isn't valid on Solaris.

We need to change this:

    elif  [ -n "${_DARWIN}" ]; then
       _DOLLARZERO=$(cd `dirname "${BASH_SOURCE[0]}"` && pwd)/`basename "${BASH_SOURCE[0]}"`

to something like:

    elif  [ -n "${_DARWIN}" ]; then
       __tmp_dirname=`dirname "${BASH_SOURCE[0]}"`
       __tmp_basename=`basename "${BASH_SOURCE[0]}"`
       _DOLLARZERO=`cd "${__tmp_dirname}" && pwd`/${__tmp_basename}

This fix for Mac was put in a few places, we probably have to fix this in all the places where the $() syntax was added.

WORKAROUND:

Those on Solaris should just delete or comment out line 155 of rhq-agent-wrapper.sh. That should fix it. Those lines aren't executed on Sol 10 anyway. They are for Mac.

Comment 8 John Mazzitelli 2014-11-17 16:09:04 UTC
there are three files that were changed in commit 04fd1353f62fc38839d82e229de8485a08b048cc that need to be fixed with my above suggestion (or something similar)

rhq-agent.sh
rhq-agent-wrapper.sh
standalone-pc.sh

Comment 9 John Mazzitelli 2014-11-17 16:10:30 UTC
line 96 has to be deleted from rhq-agent.sh as well for things to work on sol 10

Comment 10 John Mazzitelli 2014-11-17 16:13:06 UTC
(In reply to John Mazzitelli from comment #9)
> line 96 has to be deleted from rhq-agent.sh as well for things to work on
> sol 10

and of course that isn't fully correct - you need to have some statement in there. so just replace line 96 with something like "echo"

Comment 12 Larry O'Leary 2014-11-17 16:32:26 UTC
Not sure how we can safely use ${BASH_SOURCE[0]} either. The reason $() is failing is because Solaris does not use BASH. The environment variable BASH_SOURCE and the introduction of arrays is only available in BASH. Solaris does not use BASH by default. Instead it uses Bourne Shell (SH).

Comment 13 John Mazzitelli 2014-11-17 16:35:25 UTC
(In reply to Larry O'Leary from comment #12)
> Not sure how we can safely use ${BASH_SOURCE[0]} either. The reason $() is
> failing is because Solaris does not use BASH. The environment variable
> BASH_SOURCE and the introduction of arrays is only available in BASH.
> Solaris does not use BASH by default. Instead it uses Bourne Shell (SH).

Those lines aren't even used on Sol 10 so it doesn't matter - we could completely delete them and it will be the same (which, in fact, is my proposed workaround).

Those lines with BASH_SOURCE are only ever executed on Mac/OS.

We just need to get rid of $() since Sol 10 sh is parsing those lines even though it doesn't execute them and barfing.

Comment 14 John Mazzitelli 2014-11-17 16:36:30 UTC
(In reply to Larry O'Leary from comment #12)
> and the introduction of arrays is only available in BASH.

That is something - lemme try that. Didn't think about array syntax.

Comment 15 John Mazzitelli 2014-11-17 16:41:33 UTC
(In reply to John Mazzitelli from comment #14)
> (In reply to Larry O'Leary from comment #12)
> > and the introduction of arrays is only available in BASH.
> 
> That is something - lemme try that. Didn't think about array syntax.

Just tried this on Sol 10 and it worked OK. I think array syntax is fine:

in rhq-agent.sh, I replaced line 96 with the following (I also did the same in line 155 of rhq-agent-wrapper.sh):

_DOLLARZERO=${BASH_SOURCE[0]}

So the proposed workarounds and proposed fixes should work.

Comment 18 Mike Thompson 2014-11-17 17:28:22 UTC
Fixed the above three scripts and rhq-cli.sh using the above technique in #c7
commit 5180f0539b678d1c89ed848844dfdd85e423d379
Author: Mike Thompson <mithomps@redhat.com>
Date:   Mon Nov 17 09:20:58 2014 -0800

    [BZ  1158948]  rhqctl start on solaris 10 shows error- Cannot find the RHQ Agent start script. Provide an alternative on OS/X for $() syntax as solaris doesnt like it even if it

Comment 19 John Mazzitelli 2014-11-17 17:39:59 UTC
Cherry picked to release/3.3.x branch:

commit 60e775706faf1c8eec007517667eb35af4fd2a29
Author: Mike Thompson <mithomps@redhat.com>
Date:   Mon Nov 17 09:20:58 2014 -0800

    [BZ  1158948]  rhqctl start on solaris 10 shows error- Cannot find the RHQ Agent start script. Provide an alternative on OS/X for $() syntax as solaris d
    (cherry picked from commit 5180f0539b678d1c89ed848844dfdd85e423d379)
    
    Signed-off-by: John Mazzitelli <mazz@redhat.com>

Comment 20 John Mazzitelli 2014-11-17 17:42:24 UTC
if we respin 3.3 and this fix gets in, we can remove the doc flag - no workaround will be needed.

Comment 22 Jared MORGAN 2014-11-18 00:08:43 UTC
3.3 is getting re-spun. Based on this fact, I'm removing the requires_doc_text flag as the issue no longer requires documenting per Comment 20.

Comment 23 Simeon Pinder 2014-11-18 04:27:28 UTC
Moving to ON_QA as available to test with latest brew build:
https://brewweb.devel.redhat.com//buildinfo?buildID=399113

Comment 24 Sunil Kondkar 2014-11-18 08:26:34 UTC
Verified on Version :	3.3.0.GA Build Number :	4f16df3:e347f77

Verified below on solaris 10 using Bourne Shell:

rhqctl install , rhqctl start works without error.
discovery, import works.
Agent and server are green.
CLI login and getting storage node list using cli works.