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