Bug 1083557 - rhq-server.sh internal script fails when executed in Bourne shell (sh) rather then Bourne Again SHell (bash)
Summary: rhq-server.sh internal script fails when executed in Bourne shell (sh) rather...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Operations Network
Classification: JBoss
Component: Installer
Version: JON 3.2
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: DR01
: JON 3.2.2
Assignee: John Mazzitelli
QA Contact: Mike Foley
URL:
Whiteboard:
Depends On:
Blocks: 1083572
TreeView+ depends on / blocked
 
Reported: 2014-04-02 13:08 UTC by Tom Fonteyne
Modified: 2018-12-05 17:59 UTC (History)
5 users (show)

Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-07-29 00:16:57 UTC
Type: Bug


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 775703 None None None Never
Red Hat Bugzilla 1099217 None None None Never

Internal Links: 1099217

Description Tom Fonteyne 2014-04-02 13:08:13 UTC
Running "rhqctl install" on a Solaris 10 fails with:

...
./rhq-server.sh: syntax error at line 569: `max_wait_seconds=$' unexpected
15:35:29,279 INFO  [org.jboss.modules] JBoss Modules version 1.2.2.Final-redhat-1
15:35:29,380 INFO  [org.rhq.enterprise.server.installer.InstallerServiceImpl] The server is preconfigured and ready for auto-install.
15:35:29,473 INFO  [org.xnio] XNIO Version 3.0.7.GA-redhat-1
15:35:29,488 INFO  [org.xnio.nio] XNIO NIO Implementation Version 3.0.7.GA-redhat-1
15:35:29,496 INFO  [org.jboss.remoting] JBoss Remoting version 3.2.16.GA-redhat-1
15:35:39,802 ERROR [org.rhq.enterprise.server.installer.Installer] The installer will now exit due to previous errors: java.lang.Exception: Cannot obtain client connection to the RHQ app server!!
....
Caused by: java.io.IOException: java.net.ConnectException: JBAS012144: Could not connect to remote://127.0.0.1:9999. The connection timed out

The reason is simple:

jon-server-3.2.0.GA/bin/internal/rhq-server.sh

line 569:

  max_wait_seconds=$(expr $RHQ_SERVER_STOP_DELAY \* 60)

and line 572:

  waited_seconds=$(expr $waited_seconds + 2)

The $() syntax does not work on Solaris 10 (it does on Solaris 11)

Those lines need to become:

  max_wait_seconds=`expr $RHQ_SERVER_STOP_DELAY \* 60`
...
  waited_seconds=`expr $waited_seconds + 2`

which will work on all *NIX based platforms (old and new)

Comment 1 Larry O'Leary 2014-04-17 16:39:39 UTC
To be clear, this issue is not limited to Solaris 10. This issue is a result of using /bin/sh as the command interpreter. /bin/sh is Bourne shell while /bin/bash is Bourne Again SHell. The scripts appear to be written for BASH as their target. 

The default file system layout for many operating systems do not install /bin/sh by default. As such, the system installed/default command interpreter creates a symbolic link to itself as /bin/sh. Meaning:

 /bin/sh -> /bin/bash

However, if /bin/sh is really installed, it will be used. In the case of rhq-server.sh (and the other JBoss ON scripts) we define the command interpreter as:

#!/bin/sh


That being said, I think that we should probably aim for making the scripts work with Bourne shell as it is still in use by some of the supported platforms used today.

Comment 2 John Mazzitelli 2014-04-23 15:23:14 UTC
needed to fix rhq-agent-wrapper.sh, rhq-server.sh, and rhq-data-migration.sh since they all used the $() syntax.

git commit to master: 6cfdf2d

Comment 3 John Mazzitelli 2014-04-23 15:31:30 UTC
since this is targeted for 3.2.2, I fixed this in release/jon3.2.x branch as well.

There was only one file that needed to be fixed in this branch (rhq-server.sh), the other files hadn't yet used the bad syntax).

release/3.2.x commit: ea6fdbd

Comment 4 John Mazzitelli 2014-04-24 16:56:50 UTC
forgot to fix rhqctl script - committed that fix to master: 1b82fcd5c1e557e4d76cb367bf029c9dca2cb461

Comment 5 Simeon Pinder 2014-05-22 15:15:34 UTC
Via product triage, determined that this bug is to be included for DR01 target milestone.

Comment 6 Stephan Vollmer 2014-05-26 11:10:17 UTC
The update script "apply-updates.sh" for JON 3.2.0 Update 01 is also affected by this problem.

This script uses the Bash-specific "if [[ ... ]]" syntax. When the script is run on Ubuntu 12.04 LTS, error messages like

./apply-updates.sh: 48: ./apply-updates.sh: [[: not found

are displayed. This happens because Ubuntu uses Dash instead of Bash for /bin/sh.

Comment 7 Simeon Pinder 2014-05-30 02:43:32 UTC
Moving to ON_QA as available for test in latest cumulative patch build(DR01):
http://jon01.mw.lab.eng.bos.redhat.com:8042/dist/release/jon/3.2.2.GA/5-29-2014/

Comment 8 Sunil Kondkar 2014-06-04 15:20:36 UTC
Reproduced the issue on JBoss ON 3.2 GA when running 'rhqctl install' on solaris 10 box. 
Applied 3.2.0.GA-Update-02 and tried 'rhqctl install'. The installer completed without error.
Marking this bug as verified.

Comment 9 Larry O'Leary 2014-07-29 00:16:57 UTC
This has been verified and released in Red Hat JBoss Operations Network 3.2 Update 02 (3.2.2) available from the Red Hat Customer Portal[1].



[1]: https://access.redhat.com/jbossnetwork/restricted/softwareDetail.html?softwareId=31783


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