cvsdist 3cbd43b
#!/bin/bash
cvsdist 3cbd43b
#
cvsdist 3cbd43b
# Startup script for the Apache Web Server
cvsdist 3cbd43b
#
cvsdist 3cbd43b
# chkconfig: - 85 15
cvsdist 3cbd43b
# description: Apache is a World Wide Web server.  It is used to serve \
cvsdist 3cbd43b
#	       HTML files and CGI.
cvsdist 3cbd43b
# processname: httpd
cvsdist 3cbd43b
# pidfile: /var/run/httpd.pid
cvsdist 3cbd43b
# config: /etc/httpd/conf/httpd.conf
cvsdist 3cbd43b
cvsdist 3cbd43b
# Source function library.
cvsdist 3cbd43b
. /etc/rc.d/init.d/functions
cvsdist 3cbd43b
cvsdist 3cbd43b
if [ -f /etc/sysconfig/httpd ]; then
cvsdist 3cbd43b
        . /etc/sysconfig/httpd
cvsdist 3cbd43b
fi
cvsdist 3cbd43b
cvsdist 3cbd43b
# This will prevent initlog from swallowing up a pass-phrase prompt if
cvsdist 3cbd43b
# mod_ssl needs a pass-phrase from the user.
cvsdist 3cbd43b
INITLOG_ARGS=""
cvsdist 3cbd43b
cvsdist 3cbd43b
# Path to the apachectl script, server binary, and short-form for messages.
cvsdist 3cbd43b
apachectl=/usr/sbin/apachectl
cvsdist 3cbd43b
httpd=/usr/sbin/httpd
cvsdist 3cbd43b
prog=httpd
cvsdist 3cbd43b
RETVAL=0
cvsdist 3cbd43b
cvsdist 3cbd43b
# check for 1.3 configuration
cvsdist 3cbd43b
check13 () {
cvsdist 3cbd43b
	CONFFILE=/etc/httpd/conf/httpd.conf
cvsdist 3cbd43b
	GONE="(ServerType|BindAddress|Port|AddModule|ClearModuleList|"
cvsdist 3cbd43b
	GONE="${GONE}AgentLog|RefererLog|RefererIgnore|FancyIndexing|"
cvsdist 3cbd43b
	GONE="${GONE}AccessConfig|ResourceConfig)"
cvsdist 3cbd43b
	if grep -Eiq "^[[:space:]]*($GONE)" $CONFFILE; then
cvsdist 3cbd43b
		echo
cvsdist 3cbd43b
		echo 1>&2 " apache 1.3 configuration directives found"
cvsdist 3cbd43b
		echo 1>&2 " please read @docdir@/migration.html"
cvsdist 3cbd43b
		failure "apache 1.3 config directives test"
cvsdist 3cbd43b
		echo
cvsdist 3cbd43b
		exit 1
cvsdist 3cbd43b
	fi
cvsdist 3cbd43b
}
cvsdist 3cbd43b
cvsdist 3cbd43b
# The semantics of these two functions differ from the way apachectl does
cvsdist 3cbd43b
# things -- attempting to start while running is a failure, and shutdown
cvsdist 3cbd43b
# when not running is also a failure.  So we just do it the way init scripts
cvsdist 3cbd43b
# are expected to behave here.
cvsdist 3cbd43b
start() {
cvsdist 3cbd43b
        echo -n $"Starting $prog: "
cvsdist 3cbd43b
        check13 || exit 1
cvsdist 3cbd43b
        daemon $httpd $OPTIONS
cvsdist 3cbd43b
        RETVAL=$?
cvsdist 3cbd43b
        echo
cvsdist 3cbd43b
        [ $RETVAL = 0 ] && touch /var/lock/subsys/httpd
cvsdist 3cbd43b
        return $RETVAL
cvsdist 3cbd43b
}
cvsdist 3cbd43b
stop() {
cvsdist 3cbd43b
	echo -n $"Stopping $prog: "
cvsdist 3cbd43b
	killproc $httpd
cvsdist 3cbd43b
	RETVAL=$?
cvsdist 3cbd43b
	echo
cvsdist 3cbd43b
	[ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd /var/run/httpd.pid
cvsdist 3cbd43b
}
cvsdist 3cbd43b
reload() {
cvsdist 3cbd43b
	echo -n $"Reloading $prog: "
cvsdist 3cbd43b
	check13 || exit 1
cvsdist 3cbd43b
	killproc $httpd -HUP
cvsdist 3cbd43b
	RETVAL=$?
cvsdist 3cbd43b
	echo
cvsdist 3cbd43b
}
cvsdist 3cbd43b
cvsdist 3cbd43b
# See how we were called.
cvsdist 3cbd43b
case "$1" in
cvsdist 3cbd43b
  start)
cvsdist 3cbd43b
	start
cvsdist 3cbd43b
	;;
cvsdist 3cbd43b
  stop)
cvsdist 3cbd43b
	stop
cvsdist 3cbd43b
	;;
cvsdist 3cbd43b
  status)
cvsdist 3cbd43b
        status $httpd
cvsdist 3cbd43b
	RETVAL=$?
cvsdist 3cbd43b
	;;
cvsdist 3cbd43b
  restart)
cvsdist 3cbd43b
	stop
cvsdist 3cbd43b
	start
cvsdist 3cbd43b
	;;
cvsdist 3cbd43b
  condrestart)
cvsdist 3cbd43b
	if [ -f /var/run/httpd.pid ] ; then
cvsdist 3cbd43b
		stop
cvsdist 3cbd43b
		start
cvsdist 3cbd43b
	fi
cvsdist 3cbd43b
	;;
cvsdist 3cbd43b
  reload)
cvsdist 3cbd43b
        reload
cvsdist 3cbd43b
	;;
cvsdist 3cbd43b
  graceful|help|configtest|fullstatus)
cvsdist 3cbd43b
	$apachectl $@
cvsdist 3cbd43b
	RETVAL=$?
cvsdist 3cbd43b
	;;
cvsdist 3cbd43b
  *)
cvsdist 3cbd43b
	echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
cvsdist 3cbd43b
	exit 1
cvsdist 3cbd43b
esac
cvsdist 3cbd43b
cvsdist 3cbd43b
exit $RETVAL