]> git.pld-linux.org Git - packages/apache.git/blob - apache.init
- rename sysconfig to httpd to have same script/service/config names
[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/httpd ] && . /etc/sysconfig/httpd
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 if [ -d "${HTTPD_CONF:-'/etc/httpd/httpd.conf'}" ]; then
37         CFG="-f ${HTTPD_CONF:-'/etc/httpd/httpd.conf'}"
38 elif [ -n "$HTTPD_CONF" ]; then
39         echo "error: HTTPD_CONF='$HTTPD_CONF': not a file, not a directory"
40         exit 1
41 else
42         CFG=""
43 fi
44
45 RETVAL=0
46 # See how we were called.
47 case "$1" in
48   start)
49         # Check if the service is already running?
50         if [ ! -f /var/lock/subsys/httpd ]; then
51                 msg_starting httpd.${HTTPD_MPM}
52                 daemon httpd.${HTTPD_MPM} $CFG $HTTPD_OPTS
53                 RETVAL=$?
54                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/httpd
55         else
56                 msg_already_running httpd.${HTTPD_MPM}
57         fi
58         ;;
59   stop)
60         # Stop daemons.
61         if [ -f /var/lock/subsys/httpd ]; then
62                 msg_stopping httpd.${HTTPD_MPM}
63                 [ -n "$(pidofproc httpd.${HTTPD_MPM})" ] && OPT="--waitforname httpd.${HTTPD_MPM} --waitfortime 60" || OPT=
64                 daemon $OPT httpd.${HTTPD_MPM} $CFG -k stop
65                 # Delete pidfile only when apache was called successfully
66                 if [ $? -eq 0 ]; then
67                         rm -f /var/lock/subsys/httpd /var/run/httpd.pid /var/run/httpd.loc* >/dev/null 2>&1
68                 fi
69         else
70                 msg_not_running httpd.${HTTPD_MPM}
71         fi
72         ;;
73   status)
74         status httpd.${HTTPD_MPM}
75         RETVAL=$?
76         /usr/sbin/httpd.${HTTPD_MPM} $CFG -S
77         ;;
78   restart)
79         $0 stop
80         $0 start
81         ;;
82   reload|force-reload|graceful)
83         if [ -f /var/lock/subsys/httpd ]; then
84                 msg_reloading httpd.${HTTPD_MPM}
85                 httpd.${HTTPD_MPM} $CFG -t > /dev/null 2>&1
86                 RETVAL=$?
87                 if [ $RETVAL -eq 0 ]; then
88                         daemon httpd.${HTTPD_MPM} $CFG -k graceful
89                         RETVAL=$?
90                 else
91                         fail
92                         echo "Configuration file syntax test failed."
93                 fi
94         else
95                 msg_not_running httpd.${HTTPD_MPM} >&2
96                 RETVAL=7
97         fi
98         ;;
99   *)
100         msg_usage "$0 {start|stop|restart|reload|force-reload|graceful|status}"
101         exit 3
102         ;;
103 esac
104
105 exit $RETVAL
This page took 0.039516 seconds and 4 git commands to generate.