[prev in list] [next in list] [prev in thread] [next in thread]
List: apache-httpd-dev
Subject: apachectl (fwd)
From: Marc Slemko <marcs () znep ! com>
Date: 1999-03-28 22:51:07
[Download RAW message or body]
[Attachment #2 (TEXT/HTML)]
---------- Forwarded message ----------
Date: Thu, 25 Mar 1999 09:21:07 +0000
From: Joseph Pietras <Joseph.Pietras@chironcomputing.com>
To: coar@Apache.Org, marcs@znep.com
Subject: apachectl
Marc and Ken,
I=A0got your email addr off apache.org.
I=A0use apache exclusively.
I=A0have lots of Borne/Korn/Csh/awk/sed experience,
about 500,000 line of "/bin/sh"=A0alone.
I=A0took the shell, apachectl, and made some very minor
additons to make the shell easier across platforms.
Please take a look and if you like please distribute it.
That way I=A0won't have to maintain it here!
Thanks
joseph
=A0
--=A0if it was so it might be, if it were so it would be,
but, as it isn't, it ain't -that's logic!
=A0=A0 Lewis Carrol
=A0
["apachectl" (TEXT/PLAIN)]
#!/bin/sh
#
# chkconfig: 345 72 28
# description: Starts the Apache HTTPD daemon
#
# Apache control script designed to allow an easy command line interface
# to controlling Apache. Written by Marc Slemko, 1997/08/23
#
# The exit codes returned are:
# EXIT_STATUS=
# 0 - operation completed successfully
# 1 - error, missing file or other "UNIX" error
# 2 - usage error
# 3 - httpd could not be started
# 4 - httpd could not be stopped
# 5 - httpd could not be started during a restart
# 6 - httpd could not be restarted during a restart
# 7 - httpd could not be restarted during a graceful restart
# 8 - configuration syntax error
#
# When multiple arguments are given, only the error from the _last_
# one is reported. Run "apachectl help" for usage info
#
#
# |||||||||||||||||||| START CONFIGURATION SECTION ||||||||||||||||||||
# -------------------- --------------------
#
APACHE_ROOT=/usr/local/apache
# the path to your PID file
PIDFILE=${APACHE_ROOT}/logs/httpd.pid;
#
# the path to your httpd binary, including options if necessary
HTTPD=${APACHE_ROOT}/src/httpd;
#
# 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 -dump"
#
# 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/server-status"
#
#
# The definitions
SYMLINK=""; # or SYMLINK=-s for symbolic links
case "`uname -s`" in
HP-UX)
T_LINK=/sbin/init.d/apachectl; # location of the "true" link
K_LINK=/sbin/rc1.d/K99apachectl; # location of the "kill" link
S_LINK=/sbin/rc3.d/S99apachectl; # location of the "start" link
;;
Linux)
T_LINK=/etc/rc.d/init.d/apachectl; # location of the "true" link
K_LINK=/etc/rc.d/rc1.d/K99apachectl; # location of the "kill" link
S_LINK=/etc/rc.d/rc3.d/S99apachectl; # location of the "start" link
;;
SunOS | * ) # default to the /etc/init.d location, a SYS5 solution
T_LINK=/etc/init.d/apachectl; # location of the "true" link
K_LINK=/etc/rc1.d/K99apachectl; # location of the "kill" link
S_LINK=/etc/rc3.d/S99apachectl; # location of the "start" link
;;
esac
#
# -------------------- --------------------
# |||||||||||||||||||| END CONFIGURATION SECTION ||||||||||||||||||||
EXIT_STATUS=0
set_running_status () {
# check for pidfile
if [ -f $PIDFILE ] ; then
PID=`cat $PIDFILE`
if kill -0 $PID; then
STATUS="httpd (pid $PID) running"
RUNNING=1
else
STATUS="httpd (pid $PID?) not running"
RUNNING=0
fi
else
STATUS="httpd (no pid file) not running"
RUNNING=0
fi
}
if [ $# -eq 0 ]; then
set -- help; # load $1 to be ``help''
## set help; # load $1 to be ``help'', if you system does not take ``--''
fi
while [ $# -gt 0 ]; do
ARG="${1}";
case "${ARG}" in
start_msg) echo Start Apache HTTP server;;
stop_msg) echo Stop Apache HTTP server;;
start)
set_running_status;
if [ $RUNNING -eq 1 ]; then
echo "$0 $ARG: httpd (pid $PID) already running"
elif $HTTPD ; then
echo "$0 $ARG: httpd started"
else
echo "$0 $ARG: httpd could not be started"
EXIT_STATUS=3
fi
;;
stop)
set_running_status;
if [ $RUNNING -eq 0 ]; then
echo "$0 $ARG: $STATUS"
elif kill $PID ; then
echo "$0 $ARG: httpd stopped"
else
echo "$0 $ARG: httpd could not be stopped"
EXIT_STATUS=4
fi
;;
restart)
set_running_status;
if [ $RUNNING -eq 0 ]; then
echo "$0 $ARG: httpd not running, trying to start"
if $HTTPD ; then
echo "$0 $ARG: httpd started"
else
echo "$0 $ARG: httpd could not be started"
EXIT_STATUS=5
fi
else
if $HTTPD -t >/dev/null 2>&1; then
if kill -HUP $PID ; then
echo "$0 $ARG: httpd restarted"
else
echo "$0 $ARG: httpd could not be restarted"
EXIT_STATUS=6
fi
else
echo "$0 $ARG: configuration broken, ignoring restart"
echo "$0 $ARG: (run 'apachectl configtest' for details)"
EXIT_STATUS=6
fi
fi
;;
graceful)
set_running_status;
if [ $RUNNING -eq 0 ]; then
echo "$0 $ARG: httpd not running, trying to start"
if $HTTPD ; then
echo "$0 $ARG: httpd started"
else
echo "$0 $ARG: httpd could not be started"
EXIT_STATUS=5
fi
else
if $HTTPD -t >/dev/null 2>&1; then
if kill -USR1 $PID ; then
echo "$0 $ARG: httpd gracefully restarted"
else
echo "$0 $ARG: httpd could not be restarted"
EXIT_STATUS=7
fi
else
echo "$0 $ARG: configuration broken, ignoring restart"
echo "$0 $ARG: (run 'apachectl configtest' for details)"
EXIT_STATUS=7
fi
fi
;;
status)
$LYNX $STATUSURL | awk ' /process$/ { print; exit } { print } '
;;
fullstatus)
$LYNX $STATUSURL
;;
configtest)
if $HTTPD -t; then
:
else
EXIT_STATUS=8
fi
;;
unlink)
if [ -f ${T_LINK} ]; then
echo /bin/rm -f ${K_LINK} ${S_LINK};
/bin/rm -f ${K_LINK} ${S_LINK};
else
echo ${0}, fatal error, file: ${T_LINK} does not exist;
EXIT_STATUS=1;
fi
;;
link)
if [ -f ${T_LINK} ]; then
/bin/rm -f ${K_LINK} ${S_LINK};
/bin/ln ${SYMLINK} ${T_LINK} ${K_LINK};
/bin/ln ${SYMLINK} ${T_LINK} ${S_LINK};
/bin/ls -il ${T_LINK} ${K_LINK} ${S_LINK};
else
echo ${0}, fatal error, file: ${T_LINK} does not exist;
EXIT_STATUS=1;
fi
;;
*)
echo "usage: $0 (start | stop | restart | fullstatus | status | \
graceful | configtest | help | link | unlink | start_msg | stop_msg)"; echo "start \
- start httpd"; echo "stop - stop httpd";
echo "restart - restart httpd if running by sending a SIGHUP or \
start if "; echo " not running";
echo "fullstatus - dump a full status screen; requires lynx and \
mod_status enabled";
echo "status - dump a short status screen; requires lynx and \
mod_status enabled";
echo "graceful - do a graceful restart by sending a SIGUSR1 or \
start if not running"; echo "configtest - do a configuration syntax test";
echo "help - this screen";
echo "start_msg - issues a one line start message, for HP-UX";
echo "stop_msg - issues a one line stop message, for HP-UX";
echo "link - creates these links:";
echo " /bin/ln ${SYMLINK} ${T_LINK} ${K_LINK}";
echo " /bin/ln ${SYMLINK} ${T_LINK} ${S_LINK}";
echo "unlink - removes the above links";
EXIT_STATUS=2
;;
esac
shift; # remove $1
done;
exit $EXIT_STATUS
# ====================================================================
# Copyright (c) 1995-1999 The Apache Group. 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. All advertising materials mentioning features or use of this
# software must display the following acknowledgment:
# "This product includes software developed by the Apache Group
# for use in the Apache HTTP server project (http://www.apache.org/)."
#
# 4. The names "Apache Server" and "Apache Group" 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 names without prior written
# permission of the Apache Group.
#
# 6. Redistributions of any form whatsoever must retain the following
# acknowledgment:
# "This product includes software developed by the Apache Group
# for use in the Apache HTTP server project (http://www.apache.org/)."
#
# THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``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 GROUP 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 Group and was originally based
# on public domain software written at the National Center for
# Supercomputing Applications, University of Illinois, Urbana-Champaign.
# For more information on the Apache Group and the Apache HTTP server
# project, please see <http://www.apache.org/>.
#
["Joseph.Pietras.vcf" (TEXT/X-VCARD)]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic