|
|
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
|
|
|
f0c688 |
# Provides: httpd24-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 |
# Path to the apachectl script, server binary, and short-form for messages.
|
|
|
af9b8b |
apachectl=$sbindir/apachectl
|
|
|
f0c688 |
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 |
|
|
|
f0c688 |
# We have to re-enable SCL environment, because /sbin/service
|
|
|
f0c688 |
# clears almost all environment variables.
|
|
|
f0c688 |
# Since X_SCLS is cleared as well, we lose information about other
|
|
|
f0c688 |
# collections enabled.
|
|
|
f0c688 |
. /opt/rh/httpd24/service-environment
|
|
|
f0c688 |
for sclname in $HTTPD24_HTTPD_SCLS_ENABLED ; do
|
|
|
f0c688 |
. /opt/rh/$sclname/enable
|
|
|
f0c688 |
export X_SCLS="$X_SCLS $sclname"
|
|
|
f0c688 |
done
|
|
|
f0c688 |
|
|
|
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() {
|
|
|
6670f0 |
status -p ${pidfile} $httpd > /dev/null
|
|
|
6670f0 |
if [[ $? = 0 ]]; then
|
|
|
6670f0 |
echo -n $"Stopping $prog: "
|
|
|
6670f0 |
killproc -p ${pidfile} -d ${STOP_TIMEOUT} $httpd
|
|
|
6670f0 |
else
|
|
|
6670f0 |
echo -n $"Stopping $prog: "
|
|
|
6670f0 |
success
|
|
|
6670f0 |
fi
|
|
|
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)
|
|
|
f0c688 |
# `status' checks lockfile only in /var/lock/subsys by default.
|
|
|
f0c688 |
# To workaround that, move outside that directory first.
|
|
|
f0c688 |
status -p ${pidfile} -l ../../../${lockfile} $httpd
|
|
|
af9b8b |
RETVAL=$?
|
|
|
af9b8b |
;;
|
|
|
af9b8b |
restart)
|
|
|
af9b8b |
stop
|
|
|
af9b8b |
start
|
|
|
af9b8b |
;;
|
|
|
af9b8b |
condrestart|try-restart)
|
|
|
f0c688 |
# `status' checks lockfile only in /var/lock/subsys by default.
|
|
|
f0c688 |
# To workaround that, move outside that directory first.
|
|
|
f0c688 |
if status -p ${pidfile} -l ../../../${lockfile} $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
|