httpd.init revision a2652f3451528565db1f85db6953fc30799d7ead
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff#!/bin/bash
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff#
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff# Copyright 2003-2006 The Apache Software Foundation or its licensors, as
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff# applicable.
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff#
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff# Licensed under the Apache License, Version 2.0 (the "License");
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff# you may not use this file except in compliance with the License.
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff# You may obtain a copy of the License at
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff#
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff# http://www.apache.org/licenses/LICENSE-2.0
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff#
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff# Unless required by applicable law or agreed to in writing, software
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff# distributed under the License is distributed on an "AS IS" BASIS,
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff# See the License for the specific language governing permissions and
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff# limitations under the License.
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff#
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff#
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff# Startup script for the Apache Web Server
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff#
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff# chkconfig: - 85 15
c803787146cadcb2d7e10cbf4491f3be513dfa1aMichael Graff# description: Apache is a World Wide Web server. It is used to serve \
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff# HTML files and CGI.
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff# processname: httpd
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff# pidfile: /var/run/httpd.pid
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff# config: /etc/httpd/conf/httpd.conf
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff# Source function library.
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff. /etc/rc.d/init.d/functions
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graffif [ -f /etc/sysconfig/httpd ]; then
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff . /etc/sysconfig/httpd
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Grafffi
e51511aa3281f8dc384eb1283115c7f8d5c402aeMichael Graff
f181f94ec8da8b1dbcc6353e8be965ea4a5ea282Michael Graff# This will prevent initlog from swallowing up a pass-phrase prompt if
31fab17bcdbe302592a6c0dc5374ef56333ee879Michael Graff# mod_ssl needs a pass-phrase from the user.
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael GraffINITLOG_ARGS=""
3024dbecbac365171bc6de0f3fa04951d6558be3Michael Graff
f181f94ec8da8b1dbcc6353e8be965ea4a5ea282Michael Graff# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
3ac63b472022ff92691d1fe69ac715a729671965Michael Graff# with the thread-based "worker" MPM; BE WARNED that some modules may not
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff# work correctly with a thread-based MPM; notably PHP will refuse to start.
e45d323a2a0f4ca08d4b139546e60a5fa7bd3f0cMichael Graff
29f28fe573d4b3b318b3b026d567c1eb86738015Michael Graff# Path to the apachectl script, server binary, and short-form for messages.
86944a4c8002e80ae9b6eb5a5e29b797879be45fMichael Graffapachectl=/usr/sbin/apachectl
11efdeb076d65fa9f0c5fc067dc040e7c99dfba6Michael Graffhttpd=${HTTPD-/usr/sbin/httpd}
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graffprog=httpd
e51511aa3281f8dc384eb1283115c7f8d5c402aeMichael GraffRETVAL=0
e51511aa3281f8dc384eb1283115c7f8d5c402aeMichael Graff
11efdeb076d65fa9f0c5fc067dc040e7c99dfba6Michael Graff# check for 1.3 configuration
11efdeb076d65fa9f0c5fc067dc040e7c99dfba6Michael Graffcheck13 () {
439c0011e642fb1d26011116144af698125262dbMichael Graff CONFFILE=/etc/httpd/conf/httpd.conf
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff GONE="(ServerType|BindAddress|Port|AddModule|ClearModuleList|"
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff GONE="${GONE}AgentLog|RefererLog|RefererIgnore|FancyIndexing|"
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff GONE="${GONE}AccessConfig|ResourceConfig)"
ff9bb3fc5453bbf310b67c560fbf04a5c0fb60daMichael Graff if grep -Eiq "^[[:space:]]*($GONE)" $CONFFILE; then
1c3bc66ada38236cc81c41b7174a9f0a872c9ab6Michael Graff echo
1c3bc66ada38236cc81c41b7174a9f0a872c9ab6Michael Graff echo 1>&2 " Apache 1.3 configuration directives found"
1c3bc66ada38236cc81c41b7174a9f0a872c9ab6Michael Graff echo 1>&2 " please read @docdir@/migration.html"
1c3bc66ada38236cc81c41b7174a9f0a872c9ab6Michael Graff failure "Apache 1.3 config directives test"
1c3bc66ada38236cc81c41b7174a9f0a872c9ab6Michael Graff echo
31fab17bcdbe302592a6c0dc5374ef56333ee879Michael Graff exit 1
31fab17bcdbe302592a6c0dc5374ef56333ee879Michael Graff fi
31fab17bcdbe302592a6c0dc5374ef56333ee879Michael Graff}
31fab17bcdbe302592a6c0dc5374ef56333ee879Michael Graff
31fab17bcdbe302592a6c0dc5374ef56333ee879Michael Graff# The semantics of these two functions differ from the way apachectl does
31fab17bcdbe302592a6c0dc5374ef56333ee879Michael Graff# things -- attempting to start while running is a failure, and shutdown
31fab17bcdbe302592a6c0dc5374ef56333ee879Michael Graff# when not running is also a failure. So we just do it the way init scripts
31fab17bcdbe302592a6c0dc5374ef56333ee879Michael Graff# are expected to behave here.
31fab17bcdbe302592a6c0dc5374ef56333ee879Michael Graffstart() {
31fab17bcdbe302592a6c0dc5374ef56333ee879Michael Graff echo -n $"Starting $prog: "
ff9bb3fc5453bbf310b67c560fbf04a5c0fb60daMichael Graff check13 || exit 1
bb143613cf26e0f27dfd9caf1a7336065d064b26Michael Graff daemon $httpd $OPTIONS
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff RETVAL=$?
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff echo
ebdd11e84734e28ddd64562e82a7c646a58a04f4Michael Graff [ $RETVAL = 0 ] && touch /var/lock/subsys/httpd
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff return $RETVAL
ebdd11e84734e28ddd64562e82a7c646a58a04f4Michael Graff}
ebdd11e84734e28ddd64562e82a7c646a58a04f4Michael Graffstop() {
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff echo -n $"Stopping $prog: "
3ac63b472022ff92691d1fe69ac715a729671965Michael Graff killproc $httpd
3ac63b472022ff92691d1fe69ac715a729671965Michael Graff RETVAL=$?
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff echo
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff [ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd /var/run/httpd.pid
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff}
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graffreload() {
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff echo -n $"Reloading $prog: "
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff check13 || exit 1
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff killproc $httpd -HUP
ff9bb3fc5453bbf310b67c560fbf04a5c0fb60daMichael Graff RETVAL=$?
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff echo
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff}
bb143613cf26e0f27dfd9caf1a7336065d064b26Michael Graff
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff# See how we were called.
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graffcase "$1" in
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff start)
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff start
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff ;;
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff stop)
439c0011e642fb1d26011116144af698125262dbMichael Graff stop
11efdeb076d65fa9f0c5fc067dc040e7c99dfba6Michael Graff ;;
3ac63b472022ff92691d1fe69ac715a729671965Michael Graff status)
11efdeb076d65fa9f0c5fc067dc040e7c99dfba6Michael Graff status $httpd
3ac63b472022ff92691d1fe69ac715a729671965Michael Graff RETVAL=$?
3ac63b472022ff92691d1fe69ac715a729671965Michael Graff ;;
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff restart)
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff stop
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff start
e51511aa3281f8dc384eb1283115c7f8d5c402aeMichael Graff ;;
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff condrestart)
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff if [ -f /var/run/httpd.pid ] ; then
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff stop
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff start
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff fi
2992344aacdb08e4af936c176d49ef789f5673ddMichael Graff ;;
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff reload)
bb143613cf26e0f27dfd9caf1a7336065d064b26Michael Graff reload
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff ;;
f181f94ec8da8b1dbcc6353e8be965ea4a5ea282Michael Graff graceful|help|configtest|fullstatus)
f181f94ec8da8b1dbcc6353e8be965ea4a5ea282Michael Graff $apachectl $@
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff RETVAL=$?
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff ;;
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff *)
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff exit 1
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graffesac
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graffexit $RETVAL
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff