]> git.pld-linux.org Git - packages/apache.git/blob - apache.init
- chroot handling
[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/conf/access.conf
11 # config:       /etc/httpd/conf/httpd.conf
12 # config:       /etc/httpd/conf/srm.conf
13
14
15 # Source function library
16 . /etc/rc.d/init.d/functions
17
18 # Get network config
19 . /etc/sysconfig/network
20
21 # Get service config
22 [ -f /etc/sysconfig/apache ] && . /etc/sysconfig/apache
23
24 # Check that networking is up.
25 if is_yes "${NETWORKING}"; then
26         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
27                 # nls "ERROR: Networking is down. %s can't be run." <service>
28                 msg_network_down httpd
29                 exit 1
30         fi
31 else
32         exit 0
33 fi
34
35 [ -z "$HTTPD_MPM" ] && HTTPD_MPM="prefork"
36
37 RETVAL=0
38 # See how we were called.
39 case "$1" in
40   start)
41         # Check if the service is already running?
42         if [ ! -f /var/lock/subsys/httpd ]; then
43                 msg_starting httpd.${HTTPD_MPM}
44                 daemon httpd.${HTTPD_MPM} -f /etc/httpd/httpd.conf $HTTPD_OPTS
45                 RETVAL=$?
46                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/httpd
47         else
48                 msg_already_running httpd.${HTTPD_MPM}
49         fi
50         ;;
51   stop)
52         # Stop daemons.
53         if [ -f /var/lock/subsys/httpd ]; then
54                 msg_stopping httpd.${HTTPD_MPM}
55                 if [ -f /var/run/httpd.pid ]; then
56                         PID=$(filter_chroot `cat /var/run/httpd.pid`)
57                         if [ ! $PID ]; then
58                                 PID=0
59                         fi
60                 else
61                         PID=0
62                 fi
63                 daemon httpd.${HTTPD_MPM} -f /etc/httpd/httpd.conf -k stop
64                 # Wait for httpd to really stop
65                 if [ ! $PID -eq 0 ]; then
66                         show "Waiting for httpd to stop"
67                         busy
68                         while ps -o command $PID | grep -q ^httpd
69                         do
70                                 sleep 1
71                         done
72                         ok
73                 fi
74                 rm -f /var/lock/subsys/httpd /var/run/httpd.pid /var/run/httpd.loc* >/dev/null 2>&1
75         else
76                 msg_not_running httpd.${HTTPD_MPM}
77         fi
78         ;;
79   status)
80         status httpd.${HTTPD_MPM}
81         RETVAL=$?
82         /usr/sbin/httpd.${HTTPD_MPM} -f /etc/httpd/httpd.conf -S
83         ;;
84   restart)
85         $0 stop
86         $0 start
87         ;;
88   reload|force-reload|graceful)
89         if [ -f /var/lock/subsys/httpd ]; then
90                 msg_reloading httpd.${HTTPD_MPM}
91                 daemon httpd.${HTTPD_MPM} -f /etc/httpd/httpd.conf -k graceful
92                 RETVAL=$?
93         else
94                 msg_not_running httpd.${HTTPD_MPM} >&2
95                 RETVAL=7
96         fi
97         ;;
98   *)
99         msg_usage "$0 {start|stop|restart|reload|force-reload|graceful|status}"
100         exit 3
101         ;;
102 esac
103
104 exit $RETVAL
This page took 0.223426 seconds and 4 git commands to generate.