Bug 1377601

Summary: Controlling Apache using custom script from JBoss ON UI
Product: [Retired] JBoss Web Server 3 Reporter: bkramer <bkramer>
Component: JON PluginAssignee: Jean-frederic Clere <jclere>
Status: CLOSED EOL QA Contact: Michal Karm Babacek <mbabacek>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 3.0.0CC: hbrock, jdoyle, mfoley, myarboro
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-27 19:46:26 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description bkramer 2016-09-20 08:11:50 UTC
Description of problem:

An attempt to run service script or custom script from JBoss ON UI to control Apache (by setting "Control script path") fails. According to the code in the rhq/source/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerOperationsDelegate.java, everything is hardcoded and parameters -d, -f and -k are always added which is the reason why the actual command run by the agent looks like: 

... -d /etc/httpd -f /etc/httpd/conf/httpd.conf -k restart


So, the only way to work around this is to use a wrapper script that will ignore all arguments except the last one (-k) and then run the script with sudo while passing the last argument (start, stop,...) to it.


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

How reproducible:
Always

Steps to Reproduce:
1. 
2.
3.

Actual results:
Apache instance cannot be controlled using custom script as additional parameters are added by default. 

Expected results:
Apache instance is properly controlled using custom script.

Additional info:

To workaround this create a wrapper script that strips all the arguments except the last one and set it as the "Control Script Path" for the Apache resource (on the Connection Settings page).

For example, the following script will check for the "-k" parameter and send its value (start, stop,...) to the service httpd command:

***********************************************
#!/bin/bash

while [ "$1" != "-k" ] && [ ! $# -eq 1 ]; do
  shift
done

if [ $# -lt 2 ]; then
  echo "Parameter -k not found?" >&2
  exit 2
fi

/usr/bin/sudo /sbin/service httpd $2
exit $?
***********************************************

Comment 1 Michal Karm Babacek 2016-09-21 11:39:10 UTC
@bkramer, please, file a JWS JIRA.  JWS 3 is no longer maintained in Bugzilla.