]> git.pld-linux.org Git - packages/apache.git/blob - apache.init
- add flush-logs target
[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 httpd
25                 exit 1
26         fi
27 else
28         exit 0
29 fi
30
31 [ -z "$HTTPD_MPM" ] && HTTPD_MPM="prefork"
32
33 if [ -n "${HTTPD_CONF}" ]; then
34         if [ -d "${HTTPD_CONF}" ] || [ -f "${HTTPD_CONF}" ]; then
35                 CFG="-f ${HTTPD_CONF}"
36         else
37                 echo "error: HTTPD_CONF='$HTTPD_CONF': not a file, not a directory"
38                 exit 1
39         fi
40 fi
41
42 RETVAL=0
43 # See how we were called.
44 case "$1" in
45   start)
46         # Check if the service is already running?
47         if [ ! -f /var/lock/subsys/httpd ]; then
48                 msg_starting httpd.${HTTPD_MPM}
49                 daemon httpd.${HTTPD_MPM} $CFG $HTTPD_OPTS
50                 RETVAL=$?
51                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/httpd
52         else
53                 msg_already_running httpd.${HTTPD_MPM}
54         fi
55         ;;
56   stop)
57         # Stop daemons.
58         if [ -f /var/lock/subsys/httpd ]; then
59                 msg_stopping httpd.${HTTPD_MPM}
60                 killproc --pidfile httpd.pid httpd.${HTTPD_MPM}
61                 rm -f /var/lock/subsys/httpd /var/run/httpd.pid /var/run/httpd.loc* >/dev/null 2>&1
62         else
63                 msg_not_running httpd.${HTTPD_MPM}
64         fi
65         ;;
66   status)
67         status httpd.${HTTPD_MPM}
68         RETVAL=$?
69         /usr/sbin/httpd.${HTTPD_MPM} $CFG -S
70         ;;
71   restart)
72         $0 stop
73         $0 start
74         ;;
75   reload|force-reload|graceful)
76         if [ -f /var/lock/subsys/httpd ]; then
77                 run_cmd "Checking httpd.${HTTPD_MPM} configuration" httpd.${HTTPD_MPM} $CFG -t
78                 RETVAL=$?
79                 if [ $RETVAL -eq 0 ]; then
80                         msg_reloading httpd.${HTTPD_MPM}
81                         daemon httpd.${HTTPD_MPM} $CFG -k graceful
82                         RETVAL=$?
83                 fi
84         else
85                 msg_not_running httpd.${HTTPD_MPM}
86                 RETVAL=7
87         fi
88         ;;
89   flush-logs)
90         if [ -f /var/lock/subsys/httpd ]; then
91                 msg_reloading httpd.${HTTPD_MPM}
92
93                 httpd.${HTTPD_MPM} -t >/dev/null 2>&1
94                 RETVAL=$?
95                 if [ $RETVAL -eq 0 ]; then
96                         daemon httpd.${HTTPD_MPM} $CFG -k graceful
97                         RETVAL=$?
98                 else
99                         fail
100                         echo >&2 "Configuration file syntax test failed."
101                 fi
102         fi
103         ;;
104   force-reload)
105         if [ -f /var/lock/subsys/httpd ]; then
106                 run_cmd "Checking httpd.${HTTPD_MPM} configuration" httpd.${HTTPD_MPM} $CFG -t
107                 RETVAL=$?
108                 if [ $RETVAL -eq 0 ]; then
109                         msg_reloading httpd.${HTTPD_MPM}
110                         # forced reload
111                         daemon httpd.${HTTPD_MPM} $CFG -k restart
112                         RETVAL=$?
113                 fi
114         else
115                 msg_not_running httpd.${HTTPD_MPM}
116                 RETVAL=7
117         fi
118         ;;
119
120   *)
121         msg_usage "$0 {start|stop|restart|reload|force-reload|graceful|status}"
122         exit 3
123         ;;
124 esac
125
126 exit $RETVAL
This page took 0.051854 seconds and 4 git commands to generate.