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