#!/bin/bash
#
# httpd Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: The Apache HTTP Server is an efficient and extensible \
# server implementing the current HTTP standards.
# processname: httpd
# config: $sysconfdir/httpd/conf/httpd.conf
# config: $sysconfdir/sysconfig/httpd
# pidfile: $localstatedir/run/httpd/httpd.pid
#
### BEGIN INIT INFO
# Provides: httpd24-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
# Source function library.
. /etc/rc.d/init.d/functions
if [ -f $sysconfdir/sysconfig/httpd ]; then
. $sysconfdir/sysconfig/httpd
fi
# Start httpd in the C locale by default.
HTTPD_LANG=${HTTPD_LANG-"C"}
# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""
# Path to the apachectl script, server binary, and short-form for messages.
apachectl=$sbindir/apachectl
httpd=$sbindir/httpd
prog=httpd
pidfile=${PIDFILE-$localstatedir/run/httpd/httpd.pid}
lockfile=${LOCKFILE-$localstatedir/lock/subsys/httpd}
RETVAL=0
STOP_TIMEOUT=${STOP_TIMEOUT-10}
# We have to re-enable SCL environment, because /sbin/service
# clears almost all environment variables.
# Since X_SCLS is cleared as well, we lose information about other
# collections enabled.
. /opt/rh/httpd24/service-environment
for sclname in $HTTPD24_HTTPD_SCLS_ENABLED ; do
. /opt/rh/$sclname/enable
export X_SCLS="$X_SCLS $sclname"
done
# 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: "
mkdir -p `dirname $lockfile`
LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
# When stopping httpd, a delay (of default 10 second) is required
# before SIGKILLing the httpd parent; this gives enough time for the
# httpd parent to SIGKILL any errant children.
stop() {
status -p ${pidfile} $httpd > /dev/null
if [[ $? = 0 ]]; then
echo -n $"Stopping $prog: "
killproc -p ${pidfile} -d ${STOP_TIMEOUT} $httpd
else
echo -n $"Stopping $prog: "
success
fi
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
echo -n $"Reloading $prog: "
if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
RETVAL=6
echo $"not reloading due to configuration syntax error"
failure $"not reloading $httpd due to configuration syntax error"
else
# Force LSB behaviour from killproc
LSB=1 killproc -p ${pidfile} $httpd -HUP
RETVAL=$?
if [ $RETVAL -eq 7 ]; then
failure $"httpd shutdown"
fi
fi
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
# `status' checks lockfile only in /var/lock/subsys by default.
# To workaround that, move outside that directory first.
status -p ${pidfile} -l ../../../${lockfile} $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart|try-restart)
# `status' checks lockfile only in /var/lock/subsys by default.
# To workaround that, move outside that directory first.
if status -p ${pidfile} -l ../../../${lockfile} $httpd >&/dev/null; then
stop
start
fi
;;
force-reload|reload)
reload
;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}"
RETVAL=2
esac
exit $RETVAL