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