]> git.pld-linux.org Git - packages/apache.git/blame - apache1.init
- HTTP group
[packages/apache.git] / apache1.init
CommitLineData
9526ac14
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.
18c595d4 8# processname: apache
9# pidfile: /var/run/apache.pid
10# config: /etc/apache/apache.conf
9526ac14
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
6e1d8754 20[ -f /etc/sysconfig/apache ] && . /etc/sysconfig/apache
9526ac14
JB
21
22# Check that networking is up.
a7f729cf 23if is_yes "${NETWORKING}"; then
bc107690 24 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
18c595d4 25 msg_network_down apache
a7f729cf 26 exit 1
27 fi
28else
29 exit 0
9526ac14
JB
30fi
31
32if is_no "${IPV6_NETWORKING}"; then
a7f729cf 33 HTTPD_OPTS="$HTTPD_OPTS -4"
9526ac14
JB
34fi
35
2ceff324 36configtest() {
60aa7909 37 /usr/sbin/apache -t > /dev/null 2>&1
f5225ccb 38 RETVAL=$?
2ceff324
ER
39}
40
41start() {
9526ac14 42 # Check if the service is already running?
5fce25e3
ER
43 if [ -x /usr/lib/apache1/lingerd ]; then
44 if [ ! -f /var/lock/subsys/lingerd ]; then
45 msg_starting lingerd
e0132b64 46 SERVICE_UMASK=002 daemon --user http /usr/lib/apache1/lingerd
5fce25e3
ER
47 RETVAL=$?
48 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/lingerd
49 else
50 msg_already_running lingerd
51 fi
52 fi
18c595d4 53 if [ ! -f /var/lock/subsys/apache ]; then
54 msg_starting apache
60aa7909 55 daemon /usr/sbin/apache $HTTPD_OPTS
a7f729cf 56 RETVAL=$?
fb55e7c8 57 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/apache
9526ac14 58 else
18c595d4 59 msg_already_running apache
9526ac14 60 fi
2ceff324
ER
61}
62
63stop() {
a7f729cf 64 # Stop daemons.
18c595d4 65 if [ -f /var/lock/subsys/apache ]; then
66 msg_stopping apache
60aa7909 67 killproc --pidfile /var/run/apache.pid apache
40e01d77 68 rm -f /var/lock/subsys/apache /var/run/apache.pid /var/run/apache.loc* >/dev/null 2>&1
a7f729cf 69 else
18c595d4 70 msg_not_running apache
9526ac14 71 fi
5fce25e3
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
2ceff324
ER
81}
82
f5225ccb
JB
83restart() {
84 configtest
85 if [ $RETVAL -eq 0 ]; then
86 stop
87 start
88 else
89 fail
8c053aec 90 echo >&2 "Configuration file syntax test failed. Run $0 configtest to see errors."
f5225ccb
JB
91 fi
92}
93
94reload() {
8c053aec
ER
95 local sig=${1:-HUP}
96 local retnr=${2:-7}
f5225ccb
JB
97 if [ -f /var/lock/subsys/apache ]; then
98 msg_reloading apache
99
100 configtest
101 if [ $RETVAL -eq 0 ]; then
60aa7909 102 killproc --pidfile /var/run/apache.pid apache -$sig
f5225ccb
JB
103 RETVAL=$?
104 else
105 fail
8c053aec 106 echo >&2 "Configuration file syntax test failed. Run $0 configtest to see errors."
f5225ccb
JB
107 fi
108 else
109 msg_not_running apache
110 RETVAL=$retnr
111 fi
112}
113
2ceff324
ER
114RETVAL=0
115# See how we were called.
116case "$1" in
117 start)
118 start
119 ;;
120 stop)
121 stop
9526ac14 122 ;;
69f1e12d 123 restart)
f5225ccb 124 restart
69f1e12d 125 ;;
f5225ccb 126 try-restart)
18c595d4 127 if [ -f /var/lock/subsys/apache ]; then
f5225ccb 128 restart
c24212e8 129 else
0f736bbd 130 msg_not_running apache
c24212e8
PG
131 fi
132 ;;
f5225ccb
JB
133 force-reload)
134 reload HUP 7
135 ;;
ee52565b 136 reload|graceful)
f5225ccb 137 reload USR1 7
897dc8cb 138 ;;
fde28b41 139 flush-logs)
449c6c45 140 reload USR1 0
fde28b41 141 ;;
b88a3679 142 configtest)
60aa7909 143 /usr/sbin/apache -t
b88a3679 144 ;;
8c053aec
ER
145 status)
146 status apache
147 RETVAL=$?
148 /usr/sbin/apache -S
149 ;;
9526ac14 150 *)
f5225ccb 151 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|graceful|configtest|status}"
e156d1e7 152 exit 3
9526ac14
JB
153 ;;
154esac
155
156exit $RETVAL
This page took 0.086592 seconds and 4 git commands to generate.