apachectl.in revision 26f3a893a0221238d498d03cc19c11c0373f61d6
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# Copyright (c) 2000 The Apache Software Foundation.
7a529f63e60dfdccc23d61808c20ba40d9901e47Lennart Poettering# See license at the end of this file.
7a529f63e60dfdccc23d61808c20ba40d9901e47Lennart Poettering# Apache control script designed to allow an easy command line interface
7a529f63e60dfdccc23d61808c20ba40d9901e47Lennart Poettering# to controlling Apache. Written by Marc Slemko, 1997/08/23
7a529f63e60dfdccc23d61808c20ba40d9901e47Lennart Poettering# The exit codes returned are:
7a529f63e60dfdccc23d61808c20ba40d9901e47Lennart Poettering# 0 - operation completed successfully
7a529f63e60dfdccc23d61808c20ba40d9901e47Lennart Poettering# 2 - usage error
7a529f63e60dfdccc23d61808c20ba40d9901e47Lennart Poettering# 3 - httpd could not be started
7a529f63e60dfdccc23d61808c20ba40d9901e47Lennart Poettering# 4 - httpd could not be stopped
7a529f63e60dfdccc23d61808c20ba40d9901e47Lennart Poettering# 5 - httpd could not be started during a restart
7a529f63e60dfdccc23d61808c20ba40d9901e47Lennart Poettering# 6 - httpd could not be restarted during a restart
7a529f63e60dfdccc23d61808c20ba40d9901e47Lennart Poettering# 7 - httpd could not be restarted during a graceful restart
7a529f63e60dfdccc23d61808c20ba40d9901e47Lennart Poettering# 8 - configuration syntax error
7a529f63e60dfdccc23d61808c20ba40d9901e47Lennart Poettering# When multiple arguments are given, only the error from the _last_
7a529f63e60dfdccc23d61808c20ba40d9901e47Lennart Poettering# one is reported. Run "apachectl help" for usage info
7a529f63e60dfdccc23d61808c20ba40d9901e47Lennart Poettering# |||||||||||||||||||| START CONFIGURATION SECTION ||||||||||||||||||||
7a529f63e60dfdccc23d61808c20ba40d9901e47Lennart Poettering# -------------------- --------------------
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# the path to your PID file
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# the path to your httpd binary, including options if necessary
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# a command that outputs a formatted text version of the HTML at the
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# url given on the command line. Designed for lynx, however other
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# programs may work.
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# the URL to your server's mod_status status page. If you do not
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# have one, then status and fullstatus will not work.
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-SzmekSTATUSURL="http://localhost:@PORT@/server-status"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# -------------------- --------------------
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# |||||||||||||||||||| END CONFIGURATION SECTION ||||||||||||||||||||
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek # check for pidfile
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek if [ "x$PID" != "x" ] && kill -0 $PID 2>/dev/null ; then
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek STATUS="httpd (pid $PID) running"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek STATUS="httpd (pid $PID?) not running"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek STATUS="httpd (no pid file) not running"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek echo "$0 $ARG: httpd (pid $PID) already running"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek echo "$0 $ARG: httpd started"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek echo "$0 $ARG: httpd could not be started"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek echo "$0 $ARG: httpd stopped"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek echo "$0 $ARG: httpd could not be stopped"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek echo "$0 $ARG: httpd not running, trying to start"
7a529f63e60dfdccc23d61808c20ba40d9901e47Lennart Poettering echo "$0 $ARG: httpd started"
7a529f63e60dfdccc23d61808c20ba40d9901e47Lennart Poettering echo "$0 $ARG: httpd could not be started"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek if $HTTPD -t >/dev/null 2>&1; then
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek echo "$0 $ARG: httpd restarted"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek echo "$0 $ARG: httpd could not be restarted"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek echo "$0 $ARG: configuration broken, ignoring restart"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek echo "$0 $ARG: (run 'apachectl configtest' for details)"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek echo "$0 $ARG: httpd not running, trying to start"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek echo "$0 $ARG: httpd started"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek echo "$0 $ARG: httpd could not be started"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek if $HTTPD -t >/dev/null 2>&1; then
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek echo "$0 $ARG: httpd gracefully restarted"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek echo "$0 $ARG: httpd could not be restarted"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek echo "$0 $ARG: configuration broken, ignoring restart"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek echo "$0 $ARG: (run 'apachectl configtest' for details)"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek $LYNX $STATUSURL | awk ' /process$/ { print; exit } { print } '
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek echo "usage: $0 (start|stop|restart|fullstatus|status|graceful|configtest|help)"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekstart - start httpd
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekstop - stop httpd
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekrestart - restart httpd if running by sending a SIGHUP or start if
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekfullstatus - dump a full status screen; requires lynx and mod_status enabled
7a529f63e60dfdccc23d61808c20ba40d9901e47Lennart Poetteringstatus - dump a short status screen; requires lynx and mod_status enabled
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekgraceful - do a graceful restart by sending a SIGWINCH or start if not running
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekconfigtest - do a configuration syntax test
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekhelp - this screen
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# ====================================================================
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# The Apache Software License, Version 1.1
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# Copyright (c) 2000 The Apache Software Foundation. All rights
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# Redistribution and use in source and binary forms, with or without
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# modification, are permitted provided that the following conditions
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# 1. Redistributions of source code must retain the above copyright
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# notice, this list of conditions and the following disclaimer.
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# 2. Redistributions in binary form must reproduce the above copyright
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# notice, this list of conditions and the following disclaimer in
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# the documentation and/or other materials provided with the
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# 3. The end-user documentation included with the redistribution,
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# if any, must include the following acknowledgment:
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# "This product includes software developed by the
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# Apache Software Foundation (http://www.apache.org/)."
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# Alternately, this acknowledgment may appear in the software itself,
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# if and wherever such third-party acknowledgments normally appear.
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# 4. The names "Apache" and "Apache Software Foundation" must
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# not be used to endorse or promote products derived from this
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# software without prior written permission. For written
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# permission, please contact apache@apache.org.
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# 5. Products derived from this software may not be called "Apache",
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# nor may "Apache" appear in their name, without prior written
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# permission of the Apache Software Foundation.
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# ====================================================================
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# This software consists of voluntary contributions made by many
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# individuals on behalf of the Apache Software Foundation. For more
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# information on the Apache Software Foundation, please see
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# Portions of this software are based upon public domain software
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# originally written at the National Center for Supercomputing Applications,
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek# University of Illinois, Urbana-Champaign.