apache resource script patch

"Martin Bene" <[email protected]> Thu, 9 May 2002 14:49:03 +0200
Newsgroups gmane.linux.failsafe
Message-ID <[email protected]>
Hi Lars,

I've found the apache resource script lacking in three places for use on my
system:
	* there's no way to specify aditional comandline parameters. For 
	example, running the SSL enabled (mod_ssl) apache, needs a "-DSSL" 
	parameter

	* for some setups, I need some aditional stuff set up, like ulimit,
	environment variables (oracle DB access)...

	* it doesn't find the httpd binary in the default location used by 
	the apache distribution if I compile it localy.

The attached patch changes these: it adds /usr/local/apache/bin to the
places to check for the httpd executable and adds two parameters to the
apache resource:
	pre_startup_script
	httpd_params

pre_startup script gets sourced prior to apache startup, httpd_params just
gets added to the commandline.

if left at their default ("none") setting, the script behaves just as
before. BTW, is there a better way of defining optional resource parameters?


Bye, Martin
apache.diff (application/octet-stream, 4.5 KB)
Index: cluster_services/cmd/srm/scripts/apache/Apache.gui-resource
===================================================================
RCS file: /cvs/failsafe/FailSafe/cluster_services/cmd/srm/scripts/apache/Apache.gui-resource,v
retrieving revision 1.1
diff -u -r1.1 Apache.gui-resource
--- cluster_services/cmd/srm/scripts/apache/Apache.gui-resource	2001/03/06 22:09:53	1.1
+++ cluster_services/cmd/srm/scripts/apache/Apache.gui-resource	2002/05/09 12:35:04
@@ -108,3 +108,29 @@
         This should be the absolute path to the default "home page" \
         displayed by the server. It is used to verify that the \
         server's data filesystem is mounted before the server starts.
+
+Apache.pre_startup_script.label = \
+	Pre-startup script
+
+Apache.pre_startup_script.glossary = \
+	glossary.Apache.pre_startup_script
+
+glossary.Apache.pre_startup_script = \
+	<B>Pre-startup script</B><P>\
+	This is the absolute path of a script to be called before apache \
+	startup. Typically, this can be used to set up special environment \
+	requirements for apache (environment variables, ulimits etc).<br>\
+	This parameter is optional, use "none" for none.
+
+Apache.httpd_params.label = \
+	Additional Parameters
+
+Apache.httpd_params.glossary = \
+	glossary.Apache.httpd_params
+
+glossary.Apache.httpd_params = \
+	<B>Additional command-line parameters</B><P>\
+	If you need to start apache with aditional command-line parameters \
+	they can be entered here. -DSSL for startup of SSL-enabled apache \
+	using mod_ssl is an example.<br>\
+	This parameter is optional, use "none" for none.
Index: cluster_services/cmd/srm/scripts/apache/apache_lib.sh
===================================================================
RCS file: /cvs/failsafe/FailSafe/cluster_services/cmd/srm/scripts/apache/apache_lib.sh,v
retrieving revision 1.4
diff -u -r1.4 apache_lib.sh
--- cluster_services/cmd/srm/scripts/apache/apache_lib.sh	2001/03/07 21:37:33	1.4
+++ cluster_services/cmd/srm/scripts/apache/apache_lib.sh	2002/05/09 12:35:05
@@ -81,6 +81,8 @@
 	APACHE=/usr/bin/httpd
     elif [ -x /usr/sbin/apache ] ; then
 	APACHE=/usr/sbin/apache
+    elif [ -x /usr/local/apache/bin/httpd ] ; then
+	APACHE=/usr/local/apache/bin/httpd
     else
 	APACHE=/usr/bin/apache
     fi
@@ -133,6 +135,10 @@
     fi
     local server_root=$(s2_get_attribute_value server-root "$RESOURCES")
     local server_conf=$(s2_get_attribute_value server-conf "$RESOURCES")
+    local pre_startup=$(s2_get_attribute_value pre_startup_script "$RESOURCES")
+    local httpd_params=$(s2_get_attribute_value httpd_params "$RESOURCES")
+    test "$pre_startup" = "none" && unset pre_startup
+    test "$httpd_params" = "none" && unset httpd_params
     if [ -z "$server_root" -o ! -d "$server_root" -o \
 	 -z "$server_conf" -o ! -f "$server_conf" ] ; then
 	echo "Apache: ServerRoot or httpd.conf not available, aborting start" > ${STATFILE} 2>&1
@@ -143,7 +149,10 @@
 	echo "Apache: default-page-location \"$default_page\" not available, aborting start" > ${STATFILE} 2>&1
 	return 1
     fi
-    local HA_CMD="${apache} -d ${server_root} -f ${server_conf}"
+    if [ -n "$pre_startup" -a -x "$pre_startup" ] ; then
+	. $pre_startup
+    fi
+    local HA_CMD="${apache} -d ${server_root} -f ${server_conf} ${httpd_params}"
     s2_run_command "${HA_CMD}" "starting the webserver server located at $server_root"  > $STATFILE 2>&1
     local status=$?
     if [ $status -ne 0 ]; then
Index: cluster_services/cmd/srm/scripts/apache/create_resource_type
===================================================================
RCS file: /cvs/failsafe/FailSafe/cluster_services/cmd/srm/scripts/apache/create_resource_type,v
retrieving revision 1.3
diff -u -r1.3 create_resource_type
--- cluster_services/cmd/srm/scripts/apache/create_resource_type	2002/05/03 11:16:12	1.3
+++ cluster_services/cmd/srm/scripts/apache/create_resource_type	2002/05/09 12:35:05
@@ -88,7 +88,7 @@
 _ACTION_MAXEXECTIME_4=400000	\
 _ACTION_MONINTERVAL_4=0 \
 _ACTION_STARTMONTIME_4=0 \
-_NUM_RESOURCE_KEYS=5		\
+_NUM_RESOURCE_KEYS=7		\
 _RESOURCE_KEY_0=server-root	\
 _RESOURCE_KEY_DATATYPE_0=string	\
 _RESOURCE_KEY_1=port-number	\
@@ -100,6 +100,12 @@
 _RESOURCE_KEY_DATATYPE_3=string		\
 _RESOURCE_KEY_4=web-ipaddr 		\
 _RESOURCE_KEY_DATATYPE_4=string		\
+_RESOURCE_KEY_5=pre_startup_script	\
+_RESOURCE_KEY_DATATYPE_5=string		\
+_RESOURCE_KEY_DEFAULT_5=none		\
+_RESOURCE_KEY_6=httpd_params		\
+_RESOURCE_KEY_DATATYPE_6=string		\
+_RESOURCE_KEY_DEFAULT_6=none
 
 if [ $? -ne 0 ]; then
     echo "restypeModify command failed"