#! /bin/sh # # @name@ 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: @name@ # pidfile: @pidfile@ # config: @conffile@ WITHOUT_RC_COMPAT=1 # Source function library. . /etc/init.d/functions SourceIfExists /etc/sysconfig/@name@ # 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=@name@.worker in /etc/sysconfig/@name@ 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-@name@} BINARY=/usr/sbin/$name moduledir=@modules@ moduleargs= PIDFILE=@pidfile@ PIDFILE_A1=/var/run/httpd.pid PIDFILE_A1_PERL=/var/run/httpd-perl.pid LOCKFILE=/var/lock/subsys/@name@ RETVAL=0 export TMPDIR=@a_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." ### Hack for Status LYNX="lynx -dump" STATUSURL="http://localhost/server-status" ### Hacks for the apache1 + proxified apache2 if [ -e "$PIDFILE_A1" -o -e "$PIDFILE_A1_PERL" ]; then DEFINE="-DA1PROXIED" fi # Change the major functions into functions. moduleargs() { for module in ${moduledir}/*.so ; do if [ -x ${module} ] ; then module=`echo ${module} | sed -e 's/.*\///g; s/^mod_//g; s/^lib//g; s/\.so//g;'| tr '[:lower:]' '[:upper:]'` moduleargs="${moduleargs} -DHAVE_$module" fi done echo ${moduleargs} } conftest() { # TODO: translatable form? action "Checking configuration sanity for $name: " \ "$BINARY" -t `moduleargs` $OPTIONS $DEFINE RETVAL=$? return $RETVAL } start() { start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" \ --expect-user root --name $name -- $BINARY $OPTIONS $DEFINE RETVAL=$? return $RETVAL } stop() { stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" \ --expect-user root --name $name -- $BINARY RETVAL=$? return $RETVAL } reload() { msg_reloading $name stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" \ --expect-user root --name $name -HUP -- $BINARY RETVAL=$? return $RETVAL } restart() { stop sleep 1 conftest || exit $? start } briefstatus() { status --pidfile "$PIDFILE" --expect-user root \ --expect-user root --name $name -- $BINARY RETVAL=$? return $RETVAL } extendedstatus() { if briefstatus >/dev/null; then RETVAL=$? $LYNX $STATUSURL | awk ' /process$/ { print; exit } { print } ' else RETVAL=$? msg_not_running "$name" echo fi return $RETVAL } # See how we were called. case "$1" in start) start ;; stop) stop ;; restart) restart ;; reload|graceful) if [ -e $moduledir/mod_jserv.so ]; then restart else reload fi ;; check|configtest) conftest exit $? ;; condstop) if [ -e "$LOCKFILE" ]; then stop fi ;; update|condrestart) if [ -e "$LOCKFILE" ]; then restart fi ;; condreload) if [ -e "$LOCKFILE" ]; then reload fi ;; extendedstatus) extendedstatus ;; status) briefstatus ;; *) msg_usage "${0##*/} {start|stop|reload|restart|check|configtest|condstop|condrestart|condreload|status}" RETVAL=1 esac exit $RETVAL