arrfab / rpms / httpd

Forked from rpms/httpd 5 years ago
Clone

Blame SOURCES/httpd-2.4.1-apctl.patch

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