AW: apache resource script patch

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

> OK. I just try to prevent adding additional parameters to the 
> instance ;-) 

understandable - changing the resource definition is a pain in the neck from
a compatibility point of view.

> The original resource I had had the path to the 
> apache binary as a configureable option, but that didn't work 
> out too well.

> What about this: The resource name is actually pretty much 
> unused so far. What if the script tried to source a 
> "profile.<resource name>", similiar to how it
> finds the httpd.conf ?

Ok, that IS a feasible alternative. should work fine for me without changing
the existing resource parameters. actually, we don't even need the resource
name here I think: since the httpd.conf filename is already hardcoded
(relative to server root), we know that the server root is resource
specific. we can just use an "apache_profile" file in the same directory
where httpd.conf is.

> It probably should also look for the httpd binary in
> $server_root/(s)bin/httpd, while I am at it.

$server_root/bin/httpd: yes, don't think the sbin version makes sense here.

Which should give a patch somewhat like the attached.

Bye, Martin
apache.diff (application/octet-stream, 2.8 KB)
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 18:00:06
@@ -73,7 +73,10 @@
     local RESOURCES="$1"
     local APACHE=
     local SERVER_CONF=
+    local SERVER_PROFILE=
 
+    local server_root=$(s2_get_attribute_value server-root "$RESOURCES")
+
     # find the location of the server binary
     if [ -x /usr/sbin/httpd ] ; then
 	APACHE=/usr/sbin/httpd
@@ -81,12 +84,14 @@
 	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
+    elif [ -x $server_root/bin/httpd ] ; then
+	APACHE=$server_root/bin/httpd
     else
 	APACHE=/usr/bin/apache
     fi
 
-    local server_root=$(s2_get_attribute_value server-root "$RESOURCES")
-
     # set the server root and the primary config file.
     if [ -f ${server_root}/conf/httpd.conf ] ; then
 	SERVER_CONF=${server_root}/conf/httpd.conf
@@ -99,6 +104,13 @@
         s2_exit 1
     fi
 
+    # set profile script for resource - specific configuration
+    if [ -x ${server_root}/conf/apache_profile ] ; then
+	SERVER_PROFILE=${server_root}/conf/apache_profile
+    elif [ -x ${server_root}/apache_profile ] ; then
+	SERVER_PROFILE=${server_root}/apache_profile
+    fi
+
     # might as well grab the PID file...
     HTTP_PID_FILE=`awk '/^PidFile/ {print $2; exit 0}' ${SERVER_CONF}`
 
@@ -109,6 +121,7 @@
     echo "server-conf $SERVER_CONF"
     echo "apache-bin $APACHE"
     echo "pid-file $HTTP_PID_FILE"
+    echo "server-profile $SERVER_PROFILE"
 
     return 0
 }
@@ -133,6 +146,7 @@
     fi
     local server_root=$(s2_get_attribute_value server-root "$RESOURCES")
     local server_conf=$(s2_get_attribute_value server-conf "$RESOURCES")
+    local server_profile=$(s2_get_attribute_value server-profile "$RESOURCES")
     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
@@ -142,6 +156,9 @@
     if [ -z "$default_page" -o ! -f "$default_page" ] ; then
 	echo "Apache: default-page-location \"$default_page\" not available, aborting start" > ${STATFILE} 2>&1
 	return 1
+    fi
+    if [ -n "$server_profile" -a -x "$server_profile" ] ; then
+	. $server_profile
     fi
     local HA_CMD="${apache} -d ${server_root} -f ${server_conf}"
     s2_run_command "${HA_CMD}" "starting the webserver server located at $server_root"  > $STATFILE 2>&1