]> git.pld-linux.org Git - packages/apache.git/blame - apache.init
- release 6
[packages/apache.git] / apache.init
CommitLineData
8faab90e 1#!/bin/sh
58f9559b 2#
34c86420 3# apache Apache Web Server
58f9559b 4#
34c86420 5# chkconfig: 345 85 15
6# description: Apache is a World Wide Web server. It is used to serve \
7# HTML files and CGI.
8# processname: httpd
9# pidfile: /var/run/httpd.pid
5980b766 10# config: /etc/httpd/apache.conf
34c86420 11
12# Source function library
58f9559b
AF
13. /etc/rc.d/init.d/functions
14
34c86420 15# Get network config
16. /etc/sysconfig/network
17
18# Get service config
9dd5ff04 19[ -f /etc/sysconfig/httpd ] && . /etc/sysconfig/httpd
34c86420 20
58f9559b 21# Check that networking is up.
a7f729cf 22if is_yes "${NETWORKING}"; then
bc107690 23 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
9841efdf 24 msg_network_down "Apache 2.2 Web Server"
a7f729cf 25 exit 1
26 fi
27else
28 exit 0
036261c0 29fi
1f86fa83 30
7728b647 31[ -z "$HTTPD_MPM" ] && HTTPD_MPM="prefork"
9841efdf 32SVC_NAME="Apache 2.2 Web Server ($HTTPD_MPM)"
83998870
ER
33
34if [ -n "${HTTPD_CONF}" ]; then
35 if [ -d "${HTTPD_CONF}" ] || [ -f "${HTTPD_CONF}" ]; then
36 CFG="-f ${HTTPD_CONF}"
37 else
38 echo "error: HTTPD_CONF='$HTTPD_CONF': not a file, not a directory"
39 exit 1
40 fi
812867fe 41fi
7728b647 42
fa160d07
ER
43configtest() {
44 /usr/sbin/httpd.${HTTPD_MPM} -t $CFG $HTTPD_OPTS >/dev/null 2>&1
8c053aec 45 RETVAL=$?
fa160d07
ER
46}
47
edb12654 48start() {
34c86420 49 # Check if the service is already running?
a7f729cf 50 if [ ! -f /var/lock/subsys/httpd ]; then
9841efdf 51 msg_starting "$SVC_NAME"
4676a5d0 52 daemon --pidfile /var/run/httpd.pid /usr/sbin/httpd.${HTTPD_MPM} $CFG $HTTPD_OPTS
a7f729cf 53 RETVAL=$?
54 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/httpd
34c86420 55 else
9841efdf 56 msg_already_running "$SVC_NAME"
34c86420 57 fi
edb12654
ER
58}
59
60stop() {
a7f729cf 61 # Stop daemons.
a4aad8e2 62 if [ -f /var/lock/subsys/httpd ]; then
9841efdf 63 msg_stopping "$SVC_NAME"
4676a5d0 64 killproc --pidfile /var/run/httpd.pid httpd.${HTTPD_MPM}
5980b766 65 rm -f /var/lock/subsys/httpd /var/run/httpd.pid /var/run/httpd.loc* >/dev/null 2>&1
a7f729cf 66 else
9841efdf 67 msg_not_running "$SVC_NAME"
a4aad8e2 68 fi
edb12654
ER
69}
70
6c46b529
JB
71condrestart() {
72 if [ -f /var/lock/subsys/httpd ]; then
73 stop
74 start
75 else
9841efdf 76 msg_not_running "$SVC_NAME"
6c46b529
JB
77 RETVAL=$1
78 fi
79}
80
edb12654
ER
81RETVAL=0
82# See how we were called.
83case "$1" in
84 start)
4676a5d0 85 start
edb12654
ER
86 ;;
87 stop)
4676a5d0 88 stop
58f9559b
AF
89 ;;
90 status)
7728b647 91 status httpd.${HTTPD_MPM}
b3d1e4ee 92 RETVAL=$?
fa160d07 93 /usr/sbin/httpd.${HTTPD_MPM} $CFG $HTTPD_OPTS -S
58f9559b 94 ;;
40350f98 95 restart)
edb12654
ER
96 stop
97 start
58f9559b 98 ;;
6c46b529
JB
99 try-restart)
100 condrestart 0
101 ;;
f9712db9 102 reload|force-reload|graceful)
e156d1e7 103 if [ -f /var/lock/subsys/httpd ]; then
fa160d07 104 configtest
df2f26df 105 if [ $RETVAL -eq 0 ]; then
9841efdf 106 msg_reloading "$SVC_NAME"
e54cf0e3 107 busy
fa160d07 108 /usr/sbin/httpd.${HTTPD_MPM} $CFG $HTTPD_OPTS -k graceful
47962253 109 RETVAL=$?
e54cf0e3 110 [ $RETVAL -eq 0 ] && ok || fail
1c5fd89c 111 fi
e156d1e7 112 else
9841efdf 113 msg_not_running "$SVC_NAME"
e156d1e7 114 RETVAL=7
115 fi
40350f98 116 ;;
1f79aa47
ER
117 flush-logs)
118 if [ -f /var/lock/subsys/httpd ]; then
9841efdf 119 msg_reloading "$SVC_NAME"
1f79aa47 120
fa160d07 121 configtest
1f79aa47 122 if [ $RETVAL -eq 0 ]; then
bd795887 123 /usr/sbin/httpd.${HTTPD_MPM} $CFG -k graceful
1f79aa47 124 RETVAL=$?
bd795887 125 [ $RETVAL -eq 0 ] && ok || fail
1f79aa47
ER
126 else
127 fail
8c053aec 128 echo >&2 "Configuration file syntax test failed. Run $0 configtest to see errors."
1f79aa47
ER
129 fi
130 fi
131 ;;
fa160d07
ER
132 configtest)
133 /usr/sbin/httpd.${HTTPD_MPM} -t $CFG $HTTPD_OPTS
134 ;;
58f9559b 135 *)
fa160d07 136 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|graceful|configtest|status}"
e156d1e7 137 exit 3
58f9559b
AF
138 ;;
139esac
140
a4aad8e2 141exit $RETVAL
This page took 0.127091 seconds and 4 git commands to generate.