]> git.pld-linux.org Git - packages/apache.git/blame - apache.init
- hopefully safe enough start point (changes suggested by blues)
[packages/apache.git] / apache.init
CommitLineData
8faab90e 1#!/bin/sh
58f9559b 2#
34c86420 3# apache Apache Web Server
58f9559b 4#
34c86420 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
5980b766 10# config: /etc/httpd/apache.conf
34c86420 11
12# Source function library
58f9559b
AF
13. /etc/rc.d/init.d/functions
14
34c86420 15# Get network config
16. /etc/sysconfig/network
17
18# Get service config
9dd5ff04 19[ -f /etc/sysconfig/httpd ] && . /etc/sysconfig/httpd
34c86420 20
58f9559b 21# Check that networking is up.
a7f729cf 22if is_yes "${NETWORKING}"; then
bc107690 23 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
a7f729cf 24 msg_network_down httpd
25 exit 1
26 fi
27else
28 exit 0
036261c0 29fi
1f86fa83 30
7728b647 31[ -z "$HTTPD_MPM" ] && HTTPD_MPM="prefork"
83998870
ER
32
33if [ -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
812867fe 40fi
7728b647 41
fa160d07
ER
42configtest() {
43 /usr/sbin/httpd.${HTTPD_MPM} -t $CFG $HTTPD_OPTS >/dev/null 2>&1
8c053aec 44 RETVAL=$?
fa160d07
ER
45}
46
edb12654 47start() {
34c86420 48 # Check if the service is already running?
a7f729cf 49 if [ ! -f /var/lock/subsys/httpd ]; then
7728b647 50 msg_starting httpd.${HTTPD_MPM}
bd795887 51 daemon /usr/sbin/httpd.${HTTPD_MPM} $CFG $HTTPD_OPTS
a7f729cf 52 RETVAL=$?
53 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/httpd
34c86420 54 else
7728b647 55 msg_already_running httpd.${HTTPD_MPM}
34c86420 56 fi
edb12654
ER
57}
58
59stop() {
a7f729cf 60 # Stop daemons.
a4aad8e2 61 if [ -f /var/lock/subsys/httpd ]; then
7728b647 62 msg_stopping httpd.${HTTPD_MPM}
21f20c3b 63 killproc --pidfile httpd.pid httpd.${HTTPD_MPM}
5980b766 64 rm -f /var/lock/subsys/httpd /var/run/httpd.pid /var/run/httpd.loc* >/dev/null 2>&1
a7f729cf 65 else
7728b647 66 msg_not_running httpd.${HTTPD_MPM}
a4aad8e2 67 fi
edb12654
ER
68}
69
6c46b529
JB
70condrestart() {
71 if [ -f /var/lock/subsys/httpd ]; then
72 stop
73 start
74 else
75 msg_not_running httpd.${HTTPD_MPM}
76 RETVAL=$1
77 fi
78}
79
edb12654
ER
80RETVAL=0
81# See how we were called.
82case "$1" in
83 start)
84 start
85 ;;
86 stop)
87 stop
58f9559b
AF
88 ;;
89 status)
7728b647 90 status httpd.${HTTPD_MPM}
b3d1e4ee 91 RETVAL=$?
fa160d07 92 /usr/sbin/httpd.${HTTPD_MPM} $CFG $HTTPD_OPTS -S
58f9559b 93 ;;
40350f98 94 restart)
edb12654
ER
95 stop
96 start
58f9559b 97 ;;
6c46b529
JB
98 try-restart)
99 condrestart 0
100 ;;
f9712db9 101 reload|force-reload|graceful)
e156d1e7 102 if [ -f /var/lock/subsys/httpd ]; then
fa160d07 103 configtest
df2f26df 104 if [ $RETVAL -eq 0 ]; then
1473e92a 105 msg_reloading httpd.${HTTPD_MPM}
e54cf0e3 106 busy
fa160d07 107 /usr/sbin/httpd.${HTTPD_MPM} $CFG $HTTPD_OPTS -k graceful
47962253 108 RETVAL=$?
e54cf0e3 109 [ $RETVAL -eq 0 ] && ok || fail
1c5fd89c 110 fi
e156d1e7 111 else
0f736bbd 112 msg_not_running httpd.${HTTPD_MPM}
e156d1e7 113 RETVAL=7
114 fi
40350f98 115 ;;
1f79aa47
ER
116 flush-logs)
117 if [ -f /var/lock/subsys/httpd ]; then
118 msg_reloading httpd.${HTTPD_MPM}
119
fa160d07 120 configtest
1f79aa47 121 if [ $RETVAL -eq 0 ]; then
bd795887 122 /usr/sbin/httpd.${HTTPD_MPM} $CFG -k graceful
1f79aa47 123 RETVAL=$?
bd795887 124 [ $RETVAL -eq 0 ] && ok || fail
1f79aa47
ER
125 else
126 fail
8c053aec 127 echo >&2 "Configuration file syntax test failed. Run $0 configtest to see errors."
1f79aa47
ER
128 fi
129 fi
130 ;;
fa160d07
ER
131 configtest)
132 /usr/sbin/httpd.${HTTPD_MPM} -t $CFG $HTTPD_OPTS
133 ;;
58f9559b 134 *)
fa160d07 135 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|graceful|configtest|status}"
e156d1e7 136 exit 3
58f9559b
AF
137 ;;
138esac
139
a4aad8e2 140exit $RETVAL
This page took 0.101491 seconds and 4 git commands to generate.