Blame SOURCES/httpd-2.4.35-apachectl.patch

59234c
diff --git a/docs/man/apachectl.8 b/docs/man/apachectl.8
59234c
index 870a048..32d3ee5 100644
59234c
--- a/docs/man/apachectl.8
59234c
+++ b/docs/man/apachectl.8
59234c
@@ -74,7 +74,7 @@ Restarts the Apache httpd daemon\&. If the daemon is not running, it is started\
59234c
 Displays a full status report from mod_status\&. For this to work, you need to have mod_status enabled on your server and a text-based browser such as \fBlynx\fR available on your system\&. The URL used to access the status report can be set by editing the \fBSTATUSURL\fR variable in the script\&.  
59234c
 .TP
59234c
 \fBstatus\fR
59234c
-Displays a brief status report\&. Similar to the \fBfullstatus\fR option, except that the list of requests currently being served is omitted\&.  
59234c
+Displays a brief status report using systemd\&.
59234c
 .TP
59234c
 \fBgraceful\fR
59234c
 Gracefully restarts the Apache httpd daemon\&. If the daemon is not running, it is started\&. This differs from a normal restart in that currently open connections are not aborted\&. A side effect is that old log files will not be closed immediately\&. This means that if used in a log rotation script, a substantial delay may be necessary to ensure that the old log files are closed before processing them\&. This command automatically checks the configuration files as in \fBconfigtest\fR before initiating the restart to make sure Apache doesn't die\&. This is equivalent to \fBapachectl -k graceful\fR\&.  
59234c
diff --git a/support/apachectl.in b/support/apachectl.in
59234c
index 3281c2e..8ce6f2b 100644
59234c
--- a/support/apachectl.in
59234c
+++ b/support/apachectl.in
59234c
@@ -44,19 +44,20 @@ ARGV="$@"
59234c
 # the path to your httpd binary, including options if necessary
59234c
 HTTPD='@exp_sbindir@/@progname@'
59234c
 #
59234c
-# pick up any necessary environment variables
59234c
-if test -f @exp_sbindir@/envvars; then
59234c
-  . @exp_sbindir@/envvars
59234c
-fi
59234c
 #
59234c
 # a command that outputs a formatted text version of the HTML at the
59234c
 # url given on the command line.  Designed for lynx, however other
59234c
 # programs may work.  
59234c
-LYNX="@LYNX_PATH@ -dump"
59234c
+if [ -x "@LYNX_PATH@" ]; then
59234c
+  LYNX="@LYNX_PATH@ -dump"
59234c
+else
59234c
+  LYNX=none
59234c
+fi
59234c
 #
59234c
 # the URL to your server's mod_status status page.  If you do not
59234c
 # have one, then status and fullstatus will not work.
59234c
 STATUSURL="http://localhost:@PORT@/server-status"
59234c
+
59234c
 #
59234c
 # Set this variable to a command that increases the maximum
59234c
 # number of file descriptors allowed per child process. This is
59234c
@@ -76,9 +77,46 @@ if [ "x$ARGV" = "x" ] ; then
59234c
     ARGV="-h"
59234c
 fi
59234c
 
59234c
+function checklynx() {
59234c
+if [ "$LYNX" = "none" ]; then
59234c
+   echo "The 'links' package is required for this functionality."
59234c
+   exit 8
59234c
+fi
59234c
+}
59234c
+
59234c
+function testconfig() {
59234c
+# httpd is denied terminal access in SELinux, so run in the
59234c
+# current context to get stdout from $HTTPD -t.
59234c
+if test -x /usr/sbin/selinuxenabled && /usr/sbin/selinuxenabled; then
59234c
+  runcon -- `id -Z` /usr/sbin/httpd $OPTIONS -t
59234c
+else
59234c
+  /usr/sbin/httpd $OPTIONS -t
59234c
+fi
59234c
+ERROR=$?
59234c
+}
59234c
+
59234c
+if [ "x$2" != "x" ] ; then
59234c
+    echo Passing arguments to httpd using apachectl is no longer supported.
59234c
+    echo You can only start/stop/restart httpd using this script.
59234c
+    echo If you want to pass extra arguments to httpd, edit the
59234c
+    echo /etc/sysconfig/httpd config file.
59234c
+fi
59234c
+
59234c
 case $ACMD in
59234c
-start|stop|restart|graceful|graceful-stop)
59234c
-    $HTTPD -k $ARGV
59234c
+start|stop|restart|status)
59234c
+    /usr/bin/systemctl $ACMD httpd.service
59234c
+    ERROR=$?
59234c
+    ;;
59234c
+graceful)
59234c
+    if /usr/bin/systemctl -q is-active httpd.service; then
59234c
+        /usr/bin/systemctl reload httpd.service
59234c
+    else
59234c
+        /usr/bin/systemctl start httpd.service
59234c
+    fi
59234c
+    ERROR=$?
59234c
+    ;;
59234c
+graceful-stop)
59234c
+    /usr/bin/systemctl stop httpd.service
59234c
     ERROR=$?
59234c
     ;;
59234c
 startssl|sslstart|start-SSL)
59234c
@@ -88,17 +126,14 @@ startssl|sslstart|start-SSL)
59234c
     ERROR=2
59234c
     ;;
59234c
 configtest)
59234c
-    $HTTPD -t
59234c
-    ERROR=$?
59234c
-    ;;
59234c
-status)
59234c
-    $LYNX $STATUSURL | awk ' /process$/ { print; exit } { print } '
59234c
+    testconfig
59234c
     ;;
59234c
 fullstatus)
59234c
+    checklynx
59234c
     $LYNX $STATUSURL
59234c
     ;;
59234c
 *)
59234c
-    $HTTPD "$@"
59234c
+    /usr/sbin/httpd $OPTIONS "$@"
59234c
     ERROR=$?
59234c
 esac
59234c