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