]> git.pld-linux.org Git - packages/apache.git/blob - apache.init
drop webserver(reqtimeout)
[packages/apache.git] / apache.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:  httpd
9 # pidfile:      /var/run/httpd.pid
10 # config:       /etc/httpd/apache.conf
11
12 # Source function library
13 . /etc/rc.d/init.d/functions
14
15 # Get network config
16 . /etc/sysconfig/network
17
18 # Get service config
19 [ -f /etc/sysconfig/httpd ] && . /etc/sysconfig/httpd
20
21 # Check that networking is up.
22 if is_yes "${NETWORKING}"; then
23         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
24                 msg_network_down "Apache 2.2 Web Server"
25                 exit 1
26         fi
27 else
28         exit 0
29 fi
30
31 [ -z "$HTTPD_MPM" ] && HTTPD_MPM="prefork"
32 SVC_NAME="Apache 2.2 Web Server ($HTTPD_MPM)"
33
34 if [ -n "${HTTPD_CONF}" ]; then
35         if [ -d "${HTTPD_CONF}" ] || [ -f "${HTTPD_CONF}" ]; then
36                 CFG="-f ${HTTPD_CONF}"
37         else
38                 echo "error: HTTPD_CONF='$HTTPD_CONF': not a file, not a directory"
39                 exit 1
40         fi
41 fi
42
43 # configtest itself
44 configtest() {
45         /usr/sbin/httpd.${HTTPD_MPM} -t $CFG $HTTPD_OPTS 2>&1
46         return $?
47 }
48
49 # wrapper for configtest:
50 checkconfig() {
51         local details=${1:-0}
52
53         if [ $details -eq 1 ]; then
54                 # run config test and display report (status action)
55                 show "Checking %s configuration" "$SVC_NAME"; busy
56                 local out
57                 out=`configtest 2>&1`
58                 RETVAL=$?
59                 [ $RETVAL -eq 0 ] && ok || fail
60                 [ "$out" ] && echo >&2 "$out"
61         else
62                 # run config test and abort with nice message if failed
63                 # (for actions checking status before action).
64                 show "Checking %s configuration" "$SVC_NAME"; busy
65                 configtest >/dev/null 2>&1
66                 RETVAL=$?
67                 if [ $RETVAL -eq 0 ]; then
68                         ok
69                 else
70                         fail
71                         nls 'Configuration test failed. See details with %s "checkconfig"' $0
72                         exit $RETVAL
73                 fi
74         fi
75 }
76
77 start() {
78         # Check if the service is already running?
79         if [ -f /var/lock/subsys/httpd ]; then
80                 msg_already_running "$SVC_NAME"
81                 return
82         fi
83
84         [ "$1" -eq 0 ] || checkconfig
85         msg_starting "$SVC_NAME"
86         # remove ssl_scache on startup, otherwise httpd may go into
87         # infinite loop if there are db transaction logs laying around
88         rm -f /var/cache/httpd/*ssl_scache*
89         daemon --pidfile /var/run/httpd.pid /usr/sbin/httpd.${HTTPD_MPM} $CFG $HTTPD_OPTS
90         RETVAL=$?
91         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/httpd
92 }
93
94 stop() {
95         # Stop daemons.
96         if [ ! -f /var/lock/subsys/httpd ]; then
97                 msg_not_running "$SVC_NAME"
98                 return
99         fi
100
101         msg_stopping "$SVC_NAME"
102         killproc --pidfile /var/run/httpd.pid httpd.${HTTPD_MPM}
103         rm -f /var/lock/subsys/httpd /var/run/httpd.pid /var/run/httpd.loc* >/dev/null 2>&1
104 }
105
106
107 reload() {
108         if [ ! -f /var/lock/subsys/httpd ]; then
109                 msg_not_running "$SVC_NAME"
110                 RETVAL=7
111                 return
112         fi
113
114         checkconfig
115         msg_reloading "$SVC_NAME"
116         busy
117         /usr/sbin/httpd.${HTTPD_MPM} $CFG $HTTPD_OPTS -k graceful
118         RETVAL=$?
119         [ $RETVAL -eq 0 ] && ok || fail
120 }
121
122 condrestart() {
123         if [ ! -f /var/lock/subsys/httpd ]; then
124                 msg_not_running "$SVC_NAME"
125                 RETVAL=$1
126                 return
127         fi
128
129         checkconfig
130         stop
131         [ "$RESTART_DELAY" ] && usleep $RESTART_DELAY
132         start
133 }
134
135 RETVAL=0
136 # See how we were called.
137 case "$1" in
138   start)
139         start
140         ;;
141   stop)
142         stop
143         ;;
144   restart)
145         checkconfig
146         stop
147         [ "$RESTART_DELAY" ] && usleep $RESTART_DELAY
148         start 0
149         ;;
150   try-restart)
151         condrestart 0
152         ;;
153   reload|force-reload|graceful|flush-logs)
154         reload
155         ;;
156   checkconfig|configtest)
157         checkconfig 1
158         ;;
159   status)
160         status httpd.${HTTPD_MPM}
161         RETVAL=$?
162         /usr/sbin/httpd.${HTTPD_MPM} $CFG $HTTPD_OPTS -S
163         ;;
164   *)
165         msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|graceful|configtest|status}"
166         exit 3
167         ;;
168 esac
169
170 exit $RETVAL
This page took 1.078267 seconds and 3 git commands to generate.