#!/bin/bash # # apache Startup script for the Apache HTTP Server # # chkconfig: - 85 15 # description: Apache is a World Wide Web server. It is used to serve \ # HTML files and CGI. # processname: apache # config: /usr/local/apache/conf/httpd.conf # config: /etc/sysconfig/apache # pidfile: /usr/local/apache/logs/httpd.pid # This script has been tested on Fedora Core 5, see # http://www.mkdoc.org/docs/howto/apache/ # http://rpms.mkdoc.com/#fc5 # This script is called apache so it doesn't conflict with the FC5 # httpd -- on other distros it might need renaming # Path to the apachectl script, server binary, short-form for messages # and mkdoc set env script -- these are the only things you will # probably need to edit. APACHE=/usr/local/apache APACHECTL=$APACHE/bin/apachectl APACHE_MODULE_DIR=$APACHE/libexec APACHE_PID=$APACHE/logs/httpd.pid HTTPD=$APACHE/bin/apache APACHE_LOCK=/var/lock/subsys/apache MKDOC=/usr/local/mkdoc-1-6/mksetenv.sh # Source function library. . /etc/rc.d/init.d/functions if [ -f /etc/sysconfig/apache ]; then . /etc/sysconfig/apache fi # This will prevent initlog from swallowing up a pass-phrase prompt if # mod_ssl needs a pass-phrase from the user. INITLOG_ARGS="" RETVAL=0 # The name of this file PROG=$0 # Find the installed modules and convert their names into arguments httpd # can use. moduleargs() { moduledir=$APACHE_MODULE_DIR moduleargs=` /usr/bin/find ${moduledir} -type f -perm -0100 -name "*.so" | env -i tr '[:lower:]' '[:upper:]' | awk '{\ gsub(/.*\//,"");\ gsub(/^MOD_/,"");\ gsub(/^LIB/,"");\ gsub(/\.SO$/,"");\ print "-DHAVE_" $0}'` echo ${moduleargs} } # 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: " source $MKDOC daemon $HTTPD `moduleargs` $OPTIONS RETVAL=$? echo [ $RETVAL = 0 ] && touch $APACHE_LOCK return $RETVAL } stop() { echo -n $"Stopping $PROG: " #killproc $HTTPD #RETVAL=$? $APACHECTL 'stop' RETVAL=0 echo [ $RETVAL = 0 ] && rm -f $APACHE_LOCK $APACHE_PID } reload() { echo -n $"Reloading $PROG: " killproc $HTTPD -HUP RETVAL=$? echo } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status $HTTPD RETVAL=$? ;; restart) stop start ;; condrestart) if [ -f $APACHE_PID ] ; then stop start fi ;; reload) reload ;; graceful|help|configtest) source $MKDOC $APACHECTL $@ RETVAL=$? ;; *) echo $"Usage: $PROG {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}" exit 1 esac exit $RETVAL