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