#! /bin/sh # # %apache2_dname Start/Stop the Apache2 Web Server # # chkconfig: - 85 15 # description: Apache is a World Wide Web server. It is used to serve \ # HTML files and CGI. # processname: %apache2_dname # pidfile: %apache2_pidfile # config: %apache2_conf # ### BEGIN INIT INFO # Provides: %apache2_dname # 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 WITHOUT_RC_COMPAT=1 # Source function library. . /etc/init.d/functions SourceIfExists %apache2_envconf # This will prevent initlog from swallowing up a pass-phrase prompt if # mod_ssl needs a pass-phrase from the user. INITLOG_ARGS="" # Set HTTPD=%apache2_dname.worker in %apache2_envconf 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. name=${HTTPD-%apache2_dname} moduledir=%apache2_moduledir moduleargs= APACHECTL=%apache2_apachectl RETVAL=0 export TMPDIR=%apache2_spooldir/tmp ### Hack for bad hostname configuration thehost=`hostname` hostname -i 1>/dev/null 2>/dev/null|| echo "WARNING: hostname is not set correctly, thus Apache may not run correctly either." # Check vars if ! echo "$WAITSTOP" \ | head -n 1 \ | grep -q '^[[:space:]]*0*[1-9][0-9]*[[:space:]]*$' ; then WAITSTOP=300 fi # Change the major functions into functions. conftest() { %apache2_sslcertsh generate %apache2_sslcertname # TODO: translatable form? action "Checking configuration sanity for $name: " \ "$APACHECTL" configtest RETVAL=$? return $RETVAL } start() { %apache2_sslcertsh generate %apache2_sslcertname action "`msg_starting $name` " \ "$APACHECTL" start RETVAL=$? return $RETVAL } stop_wait() { for (( i=$1; $i>0; i=(($i-1)) )); do "$APACHECTL" stop >/dev/null 2>&1 RETVAL=$? if [ $RETVAL -ne 255 ]; then return $RETVAL fi printf '%5s' "$i" sleep 1 printf "\b\b\b\b\b \b\b\b\b\b" done "$APACHECTL" stop >/dev/null 2>&1 RETVAL=$? return $RETVAL } stop() { msg_stopping $name stop_wait $WAITSTOP RETVAL=$? if [ $RETVAL -eq 0 ]; then echo_success echo else echo_failure echo fi return $RETVAL } reload() { action "`msg_reloading $name` " \ "$APACHECTL" restart RETVAL=$? return $RETVAL } restart() { stop RETVAL=$? if [ $RETVAL -eq 0 ]; then conftest || exit $? start RETVAL=$? fi return $RETVAL } briefstatus() { "$APACHECTL" briefstatus RETVAL=$? return $RETVAL } extendedstatus() { "$APACHECTL" status RETVAL=$? return $RETVAL } # See how we were called. case "$1" in start) start RETVAL=$? ;; stop) stop RETVAL=$? ;; restart) restart RETVAL=$? ;; reload|graceful) if [ -e $moduledir/mod_jserv.so ]; then restart RETVAL=$? else reload RETVAL=$? fi ;; check|configtest) conftest RETVAL=$? ;; condstop) if briefstatus >/dev/null 2>&1; then stop RETVAL=$? else RETVAL=0 fi ;; update|condrestart) if briefstatus >/dev/null 2>&1; then restart RETVAL=$? else RETVAL=0 fi ;; condreload) if briefstatus >/dev/null 2>&1; then reload RETVAL=$? else RETVAL=0 fi ;; extendedstatus) extendedstatus RETVAL=$? ;; status) briefstatus RETVAL=$? ;; *) msg_usage "${0##*/} {start|stop|reload|restart|check|configtest|condstop|condrestart|condreload|status}" RETVAL=1 esac exit $RETVAL