]> git.pld-linux.org Git - packages/apache1.git/blame - apache1.init
rel 15; builds
[packages/apache1.git] / apache1.init
CommitLineData
0f05f0de
JB
1#!/bin/sh
2#
3# apache Apache Web Server
4#
5# chkconfig: 345 85 15
6# description: Apache is a World Wide Web server. It is used to serve \
7# HTML files and CGI.
e983d4c5 8# processname: apache
9# pidfile: /var/run/apache.pid
10# config: /etc/apache/apache.conf
0f05f0de
JB
11
12
13# Source function library
14. /etc/rc.d/init.d/functions
15
16# Get network config
17. /etc/sysconfig/network
18
19# Get service config
da771d4d 20[ -f /etc/sysconfig/apache ] && . /etc/sysconfig/apache
0f05f0de
JB
21
22# Check that networking is up.
2b61eec8 23if is_yes "${NETWORKING}"; then
9a1f5403 24 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
0c343531 25 msg_network_down "Apache 1.3 Web Server"
2b61eec8 26 exit 1
27 fi
28else
29 exit 0
0f05f0de
JB
30fi
31
32if is_no "${IPV6_NETWORKING}"; then
2b61eec8 33 HTTPD_OPTS="$HTTPD_OPTS -4"
0f05f0de
JB
34fi
35
3363abd7 36configtest() {
0862acf3
ER
37 /usr/sbin/apache -t
38}
39
40# wrapper for configtest
41checkconfig() {
42 local details=${1:-0}
43
44 if [ $details = 1 ]; then
45 # run config test and display report (status action)
46 show "Checking %s configuration" "Apache 1.3 Web Server"; busy
47 local out
48 out=`configtest 2>&1`
49 RETVAL=$?
50 if [ $RETVAL = 0 ]; then
51 ok
52 else
53 fail
54 fi
55 [ "$out" ] && echo >&2 "$out"
56 else
57 # run config test and abort with nice message if failed
58 # (for actions checking status before action).
59 configtest >/dev/null 2>&1
60 RETVAL=$?
61 if [ $RETVAL != 0 ]; then
62 show "Checking %s configuration" "Apache 1.3 Web Server"; fail
63 nls 'Configuration test failed. See details with %s "checkconfig"' $0
64 exit $RETVAL
65 fi
66 fi
3363abd7
ER
67}
68
69start() {
0f05f0de 70 # Check if the service is already running?
4adf5ef7
ER
71 if [ -x /usr/lib/apache1/lingerd ]; then
72 if [ ! -f /var/lock/subsys/lingerd ]; then
0c343531 73 msg_starting "Apache Lingerd"
6dbd8d37 74 SERVICE_UMASK=002 daemon --user http /usr/lib/apache1/lingerd
4adf5ef7
ER
75 RETVAL=$?
76 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/lingerd
77 else
0c343531 78 msg_already_running "Apache Lingerd"
4adf5ef7
ER
79 fi
80 fi
0862acf3
ER
81
82 if [ -f /var/lock/subsys/apache ]; then
0c343531 83 msg_already_running "Apache 1.3 Web Server"
0862acf3 84 return
0f05f0de 85 fi
0862acf3
ER
86
87 checkconfig
88 msg_starting "Apache 1.3 Web Server"
89 daemon /usr/sbin/apache $HTTPD_OPTS
90 RETVAL=$?
91 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/apache
3363abd7
ER
92}
93
94stop() {
2b61eec8 95 # Stop daemons.
e983d4c5 96 if [ -f /var/lock/subsys/apache ]; then
0c343531 97 msg_stopping "Apache 1.3 Web Server"
1d30cd27 98 killproc --pidfile /var/run/apache.pid apache
8bf769f8 99 rm -f /var/lock/subsys/apache /var/run/apache.pid /var/run/apache.loc* >/dev/null 2>&1
2b61eec8 100 else
0c343531 101 msg_not_running "Apache 1.3 Web Server"
0f05f0de 102 fi
4adf5ef7
ER
103 if [ -x /usr/lib/apache1/lingerd ]; then
104 if [ -f /var/lock/subsys/lingerd ]; then
0c343531 105 msg_stopping "Apache Lingerd"
4adf5ef7
ER
106 /usr/lib/apache1/lingerd -k && ok || fail
107 rm -f /var/lock/subsys/lingerd >/dev/null 2>&1
108 else
0c343531 109 msg_not_running "Apache Lingerd"
4adf5ef7
ER
110 fi
111 fi
3363abd7
ER
112}
113
929ab18a 114reload() {
5a65f66b
ER
115 local sig=${1:-HUP}
116 local retnr=${2:-7}
0862acf3 117 if [ ! -f /var/lock/subsys/apache ]; then
0c343531 118 msg_not_running "Apache 1.3 Web Server"
929ab18a 119 RETVAL=$retnr
0862acf3 120 return
929ab18a 121 fi
0862acf3
ER
122
123 checkconfig
124 msg_reloading "Apache 1.3 Web Server"
125 killproc --pidfile /var/run/apache.pid apache -$sig
126 RETVAL=$?
127}
128
129condrestart() {
130 if [ ! -f /var/lock/subsys/apache ]; then
131 msg_not_running "Apache 1.3 Web Server"
132 RETVAL=$1
133 return
134 fi
135
136 checkconfig
137 stop
138 start
929ab18a
JB
139}
140
3363abd7
ER
141RETVAL=0
142# See how we were called.
143case "$1" in
144 start)
145 start
146 ;;
147 stop)
148 stop
0f05f0de 149 ;;
63b43328 150 restart)
0862acf3
ER
151 checkconfig
152 stop
153 start
63b43328 154 ;;
929ab18a 155 try-restart)
0862acf3 156 condrestart 0
929ab18a 157 ;;
3040bd5b 158 reload|graceful)
929ab18a 159 reload USR1 7
e8c66f84 160 ;;
0862acf3
ER
161 force-reload)
162 reload HUP 7
163 ;;
9193e83a 164 flush-logs)
18dfc700 165 reload USR1 0
9193e83a 166 ;;
0862acf3
ER
167 checkconfig|configtest)
168 checkconfig 1
3be48316 169 ;;
5a65f66b
ER
170 status)
171 status apache
172 RETVAL=$?
173 /usr/sbin/apache -S
174 ;;
0f05f0de 175 *)
0862acf3 176 msg_usage "$0 {start|stop|restart|try-restart|reload|graceful|force-reload|checkconfig|status}"
dfa42476 177 exit 3
0f05f0de
JB
178 ;;
179esac
180
181exit $RETVAL
This page took 0.069027 seconds and 4 git commands to generate.