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