|
|
af9b8b |
#!/bin/bash
|
|
|
af9b8b |
#
|
|
|
af9b8b |
# httpd Startup script for the Apache HTTP Server
|
|
|
af9b8b |
#
|
|
|
af9b8b |
# chkconfig: - 85 15
|
|
|
af9b8b |
# description: The Apache HTTP Server is an efficient and extensible \
|
|
|
af9b8b |
# server implementing the current HTTP standards.
|
|
|
af9b8b |
# processname: httpd
|
|
|
af9b8b |
# config: $sysconfdir/httpd/conf/httpd.conf
|
|
|
af9b8b |
# config: $sysconfdir/sysconfig/httpd
|
|
|
af9b8b |
# pidfile: $localstatedir/run/httpd/httpd.pid
|
|
|
af9b8b |
#
|
|
|
af9b8b |
### BEGIN INIT INFO
|
|
|
af9b8b |
# Provides: httpd
|
|
|
af9b8b |
# Required-Start: $local_fs $remote_fs $network $named
|
|
|
af9b8b |
# Required-Stop: $local_fs $remote_fs $network
|
|
|
af9b8b |
# Should-Start: distcache
|
|
|
af9b8b |
# Short-Description: start and stop Apache HTTP Server
|
|
|
af9b8b |
# Description: The Apache HTTP Server is an extensible server
|
|
|
af9b8b |
# implementing the current HTTP standards.
|
|
|
af9b8b |
### END INIT INFO
|
|
|
af9b8b |
|
|
|
af9b8b |
# Source function library.
|
|
|
af9b8b |
. /etc/rc.d/init.d/functions
|
|
|
af9b8b |
|
|
|
af9b8b |
if [ -f $sysconfdir/sysconfig/httpd ]; then
|
|
|
af9b8b |
. $sysconfdir/sysconfig/httpd
|
|
|
af9b8b |
fi
|
|
|
af9b8b |
|
|
|
af9b8b |
# Start httpd in the C locale by default.
|
|
|
af9b8b |
HTTPD_LANG=${HTTPD_LANG-"C"}
|
|
|
af9b8b |
|
|
|
af9b8b |
# This will prevent initlog from swallowing up a pass-phrase prompt if
|
|
|
af9b8b |
# mod_ssl needs a pass-phrase from the user.
|
|
|
af9b8b |
INITLOG_ARGS=""
|
|
|
af9b8b |
|
|
|
af9b8b |
# Set HTTPD=$sbindir/httpd.worker in /etc/sysconfig/httpd to use a server
|
|
|
af9b8b |
# with the thread-based "worker" MPM; BE WARNED that some modules may not
|
|
|
af9b8b |
# work correctly with a thread-based MPM; notably PHP will refuse to start.
|
|
|
af9b8b |
|
|
|
af9b8b |
# Path to the apachectl script, server binary, and short-form for messages.
|
|
|
af9b8b |
apachectl=$sbindir/apachectl
|
|
|
af9b8b |
httpd=${HTTPD-$sbindir/httpd}
|
|
|
af9b8b |
prog=httpd
|
|
|
af9b8b |
pidfile=${PIDFILE-$localstatedir/run/httpd/httpd.pid}
|
|
|
af9b8b |
lockfile=${LOCKFILE-$localstatedir/lock/subsys/httpd}
|
|
|
af9b8b |
RETVAL=0
|
|
|
af9b8b |
STOP_TIMEOUT=${STOP_TIMEOUT-10}
|
|
|
af9b8b |
|
|
|
af9b8b |
# The semantics of these two functions differ from the way apachectl does
|
|
|
af9b8b |
# things -- attempting to start while running is a failure, and shutdown
|
|
|
af9b8b |
# when not running is also a failure. So we just do it the way init scripts
|
|
|
af9b8b |
# are expected to behave here.
|
|
|
af9b8b |
start() {
|
|
|
af9b8b |
echo -n $"Starting $prog: "
|
|
|
af9b8b |
mkdir -p `dirname $lockfile`
|
|
|
af9b8b |
LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
|
|
|
af9b8b |
RETVAL=$?
|
|
|
af9b8b |
echo
|
|
|
af9b8b |
[ $RETVAL = 0 ] && touch ${lockfile}
|
|
|
af9b8b |
return $RETVAL
|
|
|
af9b8b |
}
|
|
|
af9b8b |
|
|
|
af9b8b |
# When stopping httpd, a delay (of default 10 second) is required
|
|
|
af9b8b |
# before SIGKILLing the httpd parent; this gives enough time for the
|
|
|
af9b8b |
# httpd parent to SIGKILL any errant children.
|
|
|
af9b8b |
stop() {
|
|
|
af9b8b |
echo -n $"Stopping $prog: "
|
|
|
af9b8b |
killproc -p ${pidfile} -d ${STOP_TIMEOUT} $httpd
|
|
|
af9b8b |
RETVAL=$?
|
|
|
af9b8b |
echo
|
|
|
af9b8b |
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
|
|
|
af9b8b |
}
|
|
|
af9b8b |
reload() {
|
|
|
af9b8b |
echo -n $"Reloading $prog: "
|
|
|
af9b8b |
if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
|
|
|
af9b8b |
RETVAL=6
|
|
|
af9b8b |
echo $"not reloading due to configuration syntax error"
|
|
|
af9b8b |
failure $"not reloading $httpd due to configuration syntax error"
|
|
|
af9b8b |
else
|
|
|
af9b8b |
# Force LSB behaviour from killproc
|
|
|
af9b8b |
LSB=1 killproc -p ${pidfile} $httpd -HUP
|
|
|
af9b8b |
RETVAL=$?
|
|
|
af9b8b |
if [ $RETVAL -eq 7 ]; then
|
|
|
af9b8b |
failure $"httpd shutdown"
|
|
|
af9b8b |
fi
|
|
|
af9b8b |
fi
|
|
|
af9b8b |
echo
|
|
|
af9b8b |
}
|
|
|
af9b8b |
|
|
|
af9b8b |
# See how we were called.
|
|
|
af9b8b |
case "$1" in
|
|
|
af9b8b |
start)
|
|
|
af9b8b |
start
|
|
|
af9b8b |
;;
|
|
|
af9b8b |
stop)
|
|
|
af9b8b |
stop
|
|
|
af9b8b |
;;
|
|
|
af9b8b |
status)
|
|
|
af9b8b |
status -p ${pidfile} $httpd
|
|
|
af9b8b |
RETVAL=$?
|
|
|
af9b8b |
;;
|
|
|
af9b8b |
restart)
|
|
|
af9b8b |
stop
|
|
|
af9b8b |
start
|
|
|
af9b8b |
;;
|
|
|
af9b8b |
condrestart|try-restart)
|
|
|
af9b8b |
if status -p ${pidfile} $httpd >&/dev/null; then
|
|
|
af9b8b |
stop
|
|
|
af9b8b |
start
|
|
|
af9b8b |
fi
|
|
|
af9b8b |
;;
|
|
|
af9b8b |
force-reload|reload)
|
|
|
af9b8b |
reload
|
|
|
af9b8b |
;;
|
|
|
af9b8b |
graceful|help|configtest|fullstatus)
|
|
|
af9b8b |
$apachectl $@
|
|
|
af9b8b |
RETVAL=$?
|
|
|
af9b8b |
;;
|
|
|
af9b8b |
*)
|
|
|
af9b8b |
echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}"
|
|
|
af9b8b |
RETVAL=2
|
|
|
af9b8b |
esac
|
|
|
af9b8b |
|
|
|
af9b8b |
exit $RETVAL
|