41a6c3
41a6c3
- fail gracefully if links is not installed on target system
41a6c3
- source sysconfig/httpd for custom env. vars etc.
41a6c3
- make httpd -t work even in SELinux
41a6c3
- pass $OPTIONS to all $HTTPD invocation
41a6c3
41a6c3
Upstream-HEAD: vendor
41a6c3
Upstream-2.0: vendor
41a6c3
Upstream-Status: Vendor-specific changes for better initscript integration
41a6c3
41a6c3
--- httpd-2.4.1/support/apachectl.in.apctl
41a6c3
+++ httpd-2.4.1/support/apachectl.in
41a6c3
@@ -44,19 +44,25 @@ ARGV="$@"
41a6c3
 # the path to your httpd binary, including options if necessary
41a6c3
 HTTPD='@exp_sbindir@/@progname@'
41a6c3
 #
41a6c3
-# pick up any necessary environment variables
41a6c3
-if test -f @exp_sbindir@/envvars; then
41a6c3
-  . @exp_sbindir@/envvars
41a6c3
-fi
41a6c3
 #
41a6c3
 # a command that outputs a formatted text version of the HTML at the
41a6c3
 # url given on the command line.  Designed for lynx, however other
41a6c3
 # programs may work.  
41a6c3
-LYNX="@LYNX_PATH@ -dump"
41a6c3
+if [ -x "@LYNX_PATH@" ]; then
41a6c3
+  LYNX="@LYNX_PATH@ -dump"
41a6c3
+else
41a6c3
+  LYNX=none
41a6c3
+fi
41a6c3
 #
41a6c3
 # the URL to your server's mod_status status page.  If you do not
41a6c3
 # have one, then status and fullstatus will not work.
41a6c3
 STATUSURL="http://localhost:@PORT@/server-status"
41a6c3
+
41a6c3
+# Source /etc/sysconfig/httpd for $HTTPD setting, etc.
41a6c3
+if [ -r /etc/sysconfig/httpd ]; then
41a6c3
+   . /etc/sysconfig/httpd
41a6c3
+fi
41a6c3
+
41a6c3
 #
41a6c3
 # Set this variable to a command that increases the maximum
41a6c3
 # number of file descriptors allowed per child process. This is
41a6c3
@@ -76,9 +82,27 @@ if [ "x$ARGV" = "x" ] ; then 
41a6c3
     ARGV="-h"
41a6c3
 fi
41a6c3
 
41a6c3
+function checklynx() {
41a6c3
+if [ "$LYNX" = "none" ]; then
41a6c3
+   echo "The 'links' package is required for this functionality."
41a6c3
+   exit 8
41a6c3
+fi
41a6c3
+}
41a6c3
+
41a6c3
+function testconfig() {
41a6c3
+# httpd is denied terminal access in SELinux, so run in the
41a6c3
+# current context to get stdout from $HTTPD -t.
41a6c3
+if test -x /usr/sbin/selinuxenabled && /usr/sbin/selinuxenabled; then
41a6c3
+  runcon -- `id -Z` $HTTPD $OPTIONS -t
41a6c3
+else
41a6c3
+  $HTTPD $OPTIONS -t
41a6c3
+fi
41a6c3
+ERROR=$?
41a6c3
+}
41a6c3
+
41a6c3
 case $ACMD in
41a6c3
 start|stop|restart|graceful|graceful-stop)
41a6c3
-    $HTTPD -k $ARGV
41a6c3
+    $HTTPD $OPTIONS -k $ARGV
41a6c3
     ERROR=$?
41a6c3
     ;;
41a6c3
 startssl|sslstart|start-SSL)
41a6c3
@@ -88,17 +112,18 @@ startssl|sslstart|start-SSL)
41a6c3
     ERROR=2
41a6c3
     ;;
41a6c3
 configtest)
41a6c3
-    $HTTPD -t
41a6c3
-    ERROR=$?
41a6c3
+    testconfig
41a6c3
     ;;
41a6c3
 status)
41a6c3
+    checklynx
41a6c3
     $LYNX $STATUSURL | awk ' /process$/ { print; exit } { print } '
41a6c3
     ;;
41a6c3
 fullstatus)
41a6c3
+    checklynx
41a6c3
     $LYNX $STATUSURL
41a6c3
     ;;
41a6c3
 *)
41a6c3
-    $HTTPD "$@"
41a6c3
+    $HTTPD $OPTIONS "$@"
41a6c3
     ERROR=$?
41a6c3
 esac
41a6c3