altarch-user / rpms / httpd

Forked from rpms/httpd 2 years ago
Clone
Blob Blame History Raw
diff --git a/docs/man/apachectl.8 b/docs/man/apachectl.8
index 870a048..32d3ee5 100644
--- a/docs/man/apachectl.8
+++ b/docs/man/apachectl.8
@@ -74,7 +74,7 @@ Restarts the Apache httpd daemon\&. If the daemon is not running, it is started\
 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\&.  
 .TP
 \fBstatus\fR
-Displays a brief status report\&. Similar to the \fBfullstatus\fR option, except that the list of requests currently being served is omitted\&.  
+Displays a brief status report using systemd\&.
 .TP
 \fBgraceful\fR
 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\&.  
diff --git a/support/apachectl.in b/support/apachectl.in
index 3281c2e..8ce6f2b 100644
--- a/support/apachectl.in
+++ b/support/apachectl.in
@@ -44,19 +44,20 @@ ARGV="$@"
 # the path to your httpd binary, including options if necessary
 HTTPD='@exp_sbindir@/@progname@'
 #
-# pick up any necessary environment variables
-if test -f @exp_sbindir@/envvars; then
-  . @exp_sbindir@/envvars
-fi
 #
 # a command that outputs a formatted text version of the HTML at the
 # url given on the command line.  Designed for lynx, however other
 # programs may work.  
-LYNX="@LYNX_PATH@ -dump"
+if [ -x "@LYNX_PATH@" ]; then
+  LYNX="@LYNX_PATH@ -dump"
+else
+  LYNX=none
+fi
 #
 # the URL to your server's mod_status status page.  If you do not
 # have one, then status and fullstatus will not work.
 STATUSURL="http://localhost:@PORT@/server-status"
+
 #
 # Set this variable to a command that increases the maximum
 # number of file descriptors allowed per child process. This is
@@ -76,9 +77,46 @@ if [ "x$ARGV" = "x" ] ; then
     ARGV="-h"
 fi
 
+function checklynx() {
+if [ "$LYNX" = "none" ]; then
+   echo "The 'links' package is required for this functionality."
+   exit 8
+fi
+}
+
+function testconfig() {
+# httpd is denied terminal access in SELinux, so run in the
+# current context to get stdout from $HTTPD -t.
+if test -x /usr/sbin/selinuxenabled && /usr/sbin/selinuxenabled; then
+  runcon -- `id -Z` /usr/sbin/httpd $OPTIONS -t
+else
+  /usr/sbin/httpd $OPTIONS -t
+fi
+ERROR=$?
+}
+
+if [ "x$2" != "x" ] ; then
+    echo Passing arguments to httpd using apachectl is no longer supported.
+    echo You can only start/stop/restart httpd using this script.
+    echo If you want to pass extra arguments to httpd, edit the
+    echo /etc/sysconfig/httpd config file.
+fi
+
 case $ACMD in
-start|stop|restart|graceful|graceful-stop)
-    $HTTPD -k $ARGV
+start|stop|restart|status)
+    /usr/bin/systemctl $ACMD httpd.service
+    ERROR=$?
+    ;;
+graceful)
+    if /usr/bin/systemctl -q is-active httpd.service; then
+        /usr/bin/systemctl reload httpd.service
+    else
+        /usr/bin/systemctl start httpd.service
+    fi
+    ERROR=$?
+    ;;
+graceful-stop)
+    /usr/bin/systemctl stop httpd.service
     ERROR=$?
     ;;
 startssl|sslstart|start-SSL)
@@ -88,17 +126,14 @@ startssl|sslstart|start-SSL)
     ERROR=2
     ;;
 configtest)
-    $HTTPD -t
-    ERROR=$?
-    ;;
-status)
-    $LYNX $STATUSURL | awk ' /process$/ { print; exit } { print } '
+    testconfig
     ;;
 fullstatus)
+    checklynx
     $LYNX $STATUSURL
     ;;
 *)
-    $HTTPD "$@"
+    /usr/sbin/httpd $OPTIONS "$@"
     ERROR=$?
 esac