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