]> git.pld-linux.org Git - packages/apache.git/blame - apache.init
- enhance mod_ldap description
[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
edb12654 42start() {
34c86420 43 # Check if the service is already running?
a7f729cf 44 if [ ! -f /var/lock/subsys/httpd ]; then
7728b647 45 msg_starting httpd.${HTTPD_MPM}
77079cb1 46 daemon httpd.${HTTPD_MPM} $CFG $HTTPD_OPTS
a7f729cf 47 RETVAL=$?
48 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/httpd
34c86420 49 else
7728b647 50 msg_already_running httpd.${HTTPD_MPM}
34c86420 51 fi
edb12654
ER
52}
53
54stop() {
a7f729cf 55 # Stop daemons.
a4aad8e2 56 if [ -f /var/lock/subsys/httpd ]; then
7728b647 57 msg_stopping httpd.${HTTPD_MPM}
21f20c3b 58 killproc --pidfile httpd.pid httpd.${HTTPD_MPM}
5980b766 59 rm -f /var/lock/subsys/httpd /var/run/httpd.pid /var/run/httpd.loc* >/dev/null 2>&1
a7f729cf 60 else
7728b647 61 msg_not_running httpd.${HTTPD_MPM}
a4aad8e2 62 fi
edb12654
ER
63}
64
6c46b529
JB
65condrestart() {
66 if [ -f /var/lock/subsys/httpd ]; then
67 stop
68 start
69 else
70 msg_not_running httpd.${HTTPD_MPM}
71 RETVAL=$1
72 fi
73}
74
edb12654
ER
75RETVAL=0
76# See how we were called.
77case "$1" in
78 start)
79 start
80 ;;
81 stop)
82 stop
58f9559b
AF
83 ;;
84 status)
7728b647 85 status httpd.${HTTPD_MPM}
b3d1e4ee 86 RETVAL=$?
812867fe 87 /usr/sbin/httpd.${HTTPD_MPM} $CFG -S
58f9559b 88 ;;
40350f98 89 restart)
edb12654
ER
90 stop
91 start
58f9559b 92 ;;
6c46b529
JB
93 try-restart)
94 condrestart 0
95 ;;
f9712db9 96 reload|force-reload|graceful)
e156d1e7 97 if [ -f /var/lock/subsys/httpd ]; then
1473e92a 98 run_cmd "Checking httpd.${HTTPD_MPM} configuration" httpd.${HTTPD_MPM} $CFG -t
df2f26df
ER
99 RETVAL=$?
100 if [ $RETVAL -eq 0 ]; then
1473e92a 101 msg_reloading httpd.${HTTPD_MPM}
fb55e7c8 102 daemon httpd.${HTTPD_MPM} $CFG -k graceful
47962253 103 RETVAL=$?
1c5fd89c 104 fi
e156d1e7 105 else
0f736bbd 106 msg_not_running httpd.${HTTPD_MPM}
e156d1e7 107 RETVAL=7
108 fi
40350f98 109 ;;
1f79aa47
ER
110 flush-logs)
111 if [ -f /var/lock/subsys/httpd ]; then
112 msg_reloading httpd.${HTTPD_MPM}
113
114 httpd.${HTTPD_MPM} -t >/dev/null 2>&1
115 RETVAL=$?
116 if [ $RETVAL -eq 0 ]; then
117 daemon httpd.${HTTPD_MPM} $CFG -k graceful
118 RETVAL=$?
119 else
120 fail
121 echo >&2 "Configuration file syntax test failed."
122 fi
123 fi
124 ;;
58f9559b 125 *)
6c46b529 126 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|graceful|status}"
e156d1e7 127 exit 3
58f9559b
AF
128 ;;
129esac
130
a4aad8e2 131exit $RETVAL
This page took 0.144572 seconds and 4 git commands to generate.