]> git.pld-linux.org Git - packages/apache1.git/blame - apache1.init
- use more functions
[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
e983d4c5 25 msg_network_down apache
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
ER
36configtest() {
37 apache -t > /dev/null 2>&1
929ab18a 38 RETVAL=$?
3363abd7
ER
39}
40
41start() {
0f05f0de 42 # Check if the service is already running?
4adf5ef7
ER
43 if [ -x /usr/lib/apache1/lingerd ]; then
44 if [ ! -f /var/lock/subsys/lingerd ]; then
45 msg_starting lingerd
6dbd8d37 46 SERVICE_UMASK=002 daemon --user http /usr/lib/apache1/lingerd
4adf5ef7
ER
47 RETVAL=$?
48 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/lingerd
49 else
50 msg_already_running lingerd
51 fi
52 fi
e983d4c5 53 if [ ! -f /var/lock/subsys/apache ]; then
54 msg_starting apache
55 daemon apache $HTTPD_OPTS
2b61eec8 56 RETVAL=$?
26e60290 57 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/apache
0f05f0de 58 else
e983d4c5 59 msg_already_running apache
0f05f0de 60 fi
3363abd7
ER
61}
62
63stop() {
2b61eec8 64 # Stop daemons.
e983d4c5 65 if [ -f /var/lock/subsys/apache ]; then
66 msg_stopping apache
67 killproc apache
8bf769f8 68 rm -f /var/lock/subsys/apache /var/run/apache.pid /var/run/apache.loc* >/dev/null 2>&1
2b61eec8 69 else
e983d4c5 70 msg_not_running apache
0f05f0de 71 fi
4adf5ef7
ER
72 if [ -x /usr/lib/apache1/lingerd ]; then
73 if [ -f /var/lock/subsys/lingerd ]; then
74 msg_stopping lingerd
75 /usr/lib/apache1/lingerd -k && ok || fail
76 rm -f /var/lock/subsys/lingerd >/dev/null 2>&1
77 else
78 msg_not_running lingerd
79 fi
80 fi
3363abd7
ER
81}
82
929ab18a
JB
83restart() {
84 configtest
85 if [ $RETVAL -eq 0 ]; then
86 stop
87 start
88 else
89 fail
90 echo >&2 "Configuration file syntax test failed."
91 fi
92}
93
94reload() {
95 sig=${1:-HUP}
96 retnr=${2:-7}
97 if [ -f /var/lock/subsys/apache ]; then
98 msg_reloading apache
99
100 configtest
101 if [ $RETVAL -eq 0 ]; then
102 killproc apache -$sig
103 RETVAL=$?
104 else
105 fail
106 echo >&2 "Configuration file syntax test failed."
107 fi
108 else
109 msg_not_running apache
110 RETVAL=$retnr
111 fi
112}
113
3363abd7
ER
114RETVAL=0
115# See how we were called.
116case "$1" in
117 start)
118 start
119 ;;
120 stop)
121 stop
0f05f0de
JB
122 ;;
123 status)
e983d4c5 124 status apache
dfa42476 125 RETVAL=$?
e983d4c5 126 /usr/sbin/apache -S
0f05f0de 127 ;;
63b43328 128 restart)
929ab18a 129 restart
63b43328 130 ;;
929ab18a 131 try-restart)
e983d4c5 132 if [ -f /var/lock/subsys/apache ]; then
929ab18a 133 restart
d89730fb 134 else
048eb0e6 135 msg_not_running apache
d89730fb
PG
136 fi
137 ;;
929ab18a
JB
138 force-reload)
139 reload HUP 7
140 ;;
3040bd5b 141 reload|graceful)
929ab18a 142 reload USR1 7
e8c66f84 143 ;;
9193e83a 144 flush-logs)
929ab18a 145 reload HUP 0
9193e83a 146 ;;
3be48316
ER
147 configtest)
148 apache -t
149 ;;
0f05f0de 150 *)
929ab18a 151 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|graceful|configtest|status}"
dfa42476 152 exit 3
0f05f0de
JB
153 ;;
154esac
155
156exit $RETVAL
This page took 0.061528 seconds and 4 git commands to generate.