]> git.pld-linux.org Git - packages/apache.git/blob - apache.init
- added HTTPD_CONF variable
[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 [ -z "$HTTPD_CONF" ] && HTTPD_CONF="/etc/httpd/httpd.conf"
37 if   [ -d "$HTTPD_CONF" ]; then CFG="-d $HTTPD_CONF"
38 elif [ -f "$HTTPD_CONF" ]; then CFG="-f $HTTPD_CONF"
39 else CFG=""; fi
40
41 RETVAL=0
42 # See how we were called.
43 case "$1" in
44   start)
45         # Check if the service is already running?
46         if [ ! -f /var/lock/subsys/httpd ]; then
47                 msg_starting httpd.${HTTPD_MPM}
48                 daemon httpd.${HTTPD_MPM} $CFG $HTTPD_OPTS
49                 RETVAL=$?
50                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/httpd
51         else
52                 msg_already_running httpd.${HTTPD_MPM}
53         fi
54         ;;
55   stop)
56         # Stop daemons.
57         if [ -f /var/lock/subsys/httpd ]; then
58                 msg_stopping httpd.${HTTPD_MPM}
59                 if [ -f /var/run/httpd.pid ]; then
60                         PID=$(filter_chroot `cat /var/run/httpd.pid`)
61                         if [ -z "$PID" ]; then
62                                 PID=0
63                         fi
64                 else
65                         PID=0
66                 fi
67                 daemon httpd.${HTTPD_MPM} -f /etc/httpd/httpd.conf -k stop
68                 RET=$?
69                 # Wait for httpd to really stop
70                 if [ ! $PID -eq 0 -a $RET -eq 0 ]; then
71                         show "Waiting for httpd to stop"
72                         busy
73                         while ps -o command $PID | grep -q ^httpd
74                         do
75                                 sleep 1
76                         done
77                         ok
78                 fi
79                 # Delete pidfile only when apache was called successfully
80                 if [ $RET -eq 0 ]; then
81                         rm -f /var/lock/subsys/httpd /var/run/httpd.pid /var/run/httpd.loc* >/dev/null 2>&1
82                 fi
83         else
84                 msg_not_running httpd.${HTTPD_MPM}
85         fi
86         ;;
87   status)
88         status httpd.${HTTPD_MPM}
89         RETVAL=$?
90         /usr/sbin/httpd.${HTTPD_MPM} -f /etc/httpd/httpd.conf -S
91         ;;
92   restart)
93         $0 stop
94         $0 start
95         ;;
96   reload|force-reload|graceful)
97         if [ -f /var/lock/subsys/httpd ]; then
98                 msg_reloading httpd.${HTTPD_MPM}
99                 daemon httpd.${HTTPD_MPM} -f /etc/httpd/httpd.conf -k graceful
100                 RETVAL=$?
101         else
102                 msg_not_running httpd.${HTTPD_MPM} >&2
103                 RETVAL=7
104         fi
105         ;;
106   *)
107         msg_usage "$0 {start|stop|restart|reload|force-reload|graceful|status}"
108         exit 3
109         ;;
110 esac
111
112 exit $RETVAL
This page took 0.045989 seconds and 4 git commands to generate.