]> git.pld-linux.org Git - packages/apache.git/blame - apache.init
- rel 4; use currently available (unofficial) fix for latest 'Range' vuln.
[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
861999ba 43# configtest itself
fa160d07 44configtest() {
861999ba
ER
45 /usr/sbin/httpd.${HTTPD_MPM} -t $CFG $HTTPD_OPTS 2>&1
46 return $?
fa160d07
ER
47}
48
861999ba
ER
49# wrapper for configtest:
50checkconfig() {
51 local details=${1:-0}
52
b59d522e 53 if [ $details -eq 1 ]; then
861999ba
ER
54 # run config test and display report (status action)
55 show "Checking %s configuration" "$SVC_NAME"; busy
56 local out
57 out=`configtest 2>&1`
a7f729cf 58 RETVAL=$?
b59d522e 59 [ $RETVAL -eq 0 ] && ok || fail
861999ba 60 [ "$out" ] && echo >&2 "$out"
34c86420 61 else
861999ba
ER
62 # run config test and abort with nice message if failed
63 # (for actions checking status before action).
b59d522e 64 show "Checking %s configuration" "$SVC_NAME"; busy
861999ba
ER
65 configtest >/dev/null 2>&1
66 RETVAL=$?
b59d522e
TP
67 if [ $RETVAL -eq 0 ]; then
68 ok
69 else
70 fail
861999ba
ER
71 nls 'Configuration test failed. See details with %s "checkconfig"' $0
72 exit $RETVAL
73 fi
74 fi
75}
76
77start() {
78 # Check if the service is already running?
79 if [ -f /var/lock/subsys/httpd ]; then
9841efdf 80 msg_already_running "$SVC_NAME"
861999ba 81 return
34c86420 82 fi
861999ba 83
1479d26a 84 [ "$1" -eq 0 ] || checkconfig
861999ba 85 msg_starting "$SVC_NAME"
065ec3ad
AG
86 # remove ssl_scache on startup, otherwise httpd may go into
87 # infinite loop if there are db transaction logs laying around
88 rm -f /var/cache/httpd/*ssl_scache*
861999ba
ER
89 daemon --pidfile /var/run/httpd.pid /usr/sbin/httpd.${HTTPD_MPM} $CFG $HTTPD_OPTS
90 RETVAL=$?
91 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/httpd
edb12654
ER
92}
93
94stop() {
a7f729cf 95 # Stop daemons.
861999ba 96 if [ ! -f /var/lock/subsys/httpd ]; then
9841efdf 97 msg_not_running "$SVC_NAME"
861999ba 98 return
a4aad8e2 99 fi
861999ba
ER
100
101 msg_stopping "$SVC_NAME"
102 killproc --pidfile /var/run/httpd.pid httpd.${HTTPD_MPM}
103 rm -f /var/lock/subsys/httpd /var/run/httpd.pid /var/run/httpd.loc* >/dev/null 2>&1
104}
105
106
107reload() {
108 if [ ! -f /var/lock/subsys/httpd ]; then
109 msg_not_running "$SVC_NAME"
110 RETVAL=7
111 return
112 fi
113
114 checkconfig
115 msg_reloading "$SVC_NAME"
116 busy
117 /usr/sbin/httpd.${HTTPD_MPM} $CFG $HTTPD_OPTS -k graceful
118 RETVAL=$?
119 [ $RETVAL -eq 0 ] && ok || fail
edb12654
ER
120}
121
6c46b529 122condrestart() {
861999ba 123 if [ ! -f /var/lock/subsys/httpd ]; then
9841efdf 124 msg_not_running "$SVC_NAME"
6c46b529 125 RETVAL=$1
861999ba 126 return
6c46b529 127 fi
861999ba
ER
128
129 checkconfig
130 stop
131 start
6c46b529
JB
132}
133
edb12654
ER
134RETVAL=0
135# See how we were called.
136case "$1" in
137 start)
4676a5d0 138 start
edb12654
ER
139 ;;
140 stop)
4676a5d0 141 stop
58f9559b 142 ;;
40350f98 143 restart)
ea166728 144 checkconfig
edb12654 145 stop
1479d26a 146 start 0
58f9559b 147 ;;
6c46b529
JB
148 try-restart)
149 condrestart 0
150 ;;
deb97ce3 151 reload|force-reload|graceful|flush-logs)
b59d522e 152 reload
861999ba
ER
153 ;;
154 checkconfig|configtest)
155 checkconfig 1
1f79aa47 156 ;;
861999ba
ER
157 status)
158 status httpd.${HTTPD_MPM}
159 RETVAL=$?
160 /usr/sbin/httpd.${HTTPD_MPM} $CFG $HTTPD_OPTS -S
fa160d07 161 ;;
58f9559b 162 *)
fa160d07 163 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|graceful|configtest|status}"
e156d1e7 164 exit 3
58f9559b
AF
165 ;;
166esac
167
a4aad8e2 168exit $RETVAL
This page took 0.129677 seconds and 4 git commands to generate.