]> git.pld-linux.org Git - packages/apache.git/blame - apache.init
- use /sbin/service
[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
e156d1e7 42RETVAL=0
58f9559b
AF
43# See how we were called.
44case "$1" in
45 start)
34c86420 46 # Check if the service is already running?
a7f729cf 47 if [ ! -f /var/lock/subsys/httpd ]; then
7728b647 48 msg_starting httpd.${HTTPD_MPM}
77079cb1 49 daemon httpd.${HTTPD_MPM} $CFG $HTTPD_OPTS
a7f729cf 50 RETVAL=$?
51 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/httpd
34c86420 52 else
7728b647 53 msg_already_running httpd.${HTTPD_MPM}
34c86420 54 fi
58f9559b
AF
55 ;;
56 stop)
a7f729cf 57 # Stop daemons.
a4aad8e2 58 if [ -f /var/lock/subsys/httpd ]; then
7728b647 59 msg_stopping httpd.${HTTPD_MPM}
21f20c3b 60 killproc --pidfile httpd.pid httpd.${HTTPD_MPM}
5980b766 61 rm -f /var/lock/subsys/httpd /var/run/httpd.pid /var/run/httpd.loc* >/dev/null 2>&1
a7f729cf 62 else
7728b647 63 msg_not_running httpd.${HTTPD_MPM}
a4aad8e2 64 fi
58f9559b
AF
65 ;;
66 status)
7728b647 67 status httpd.${HTTPD_MPM}
b3d1e4ee 68 RETVAL=$?
812867fe 69 /usr/sbin/httpd.${HTTPD_MPM} $CFG -S
58f9559b 70 ;;
40350f98 71 restart)
cc59379f 72 $0 stop
58f9559b
AF
73 $0 start
74 ;;
f9712db9 75 reload|force-reload|graceful)
e156d1e7 76 if [ -f /var/lock/subsys/httpd ]; then
1473e92a 77 run_cmd "Checking httpd.${HTTPD_MPM} configuration" httpd.${HTTPD_MPM} $CFG -t
df2f26df
ER
78 RETVAL=$?
79 if [ $RETVAL -eq 0 ]; then
1473e92a 80 msg_reloading httpd.${HTTPD_MPM}
fb55e7c8 81 daemon httpd.${HTTPD_MPM} $CFG -k graceful
47962253 82 RETVAL=$?
1c5fd89c 83 fi
e156d1e7 84 else
0f736bbd 85 msg_not_running httpd.${HTTPD_MPM}
e156d1e7 86 RETVAL=7
87 fi
40350f98 88 ;;
1f79aa47
ER
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 ;;
8197f08f
AM
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
0f736bbd 115 msg_not_running httpd.${HTTPD_MPM}
8197f08f
AM
116 RETVAL=7
117 fi
118 ;;
119
58f9559b 120 *)
62c5d063 121 msg_usage "$0 {start|stop|restart|reload|force-reload|graceful|status}"
e156d1e7 122 exit 3
58f9559b
AF
123 ;;
124esac
125
a4aad8e2 126exit $RETVAL
This page took 0.071634 seconds and 4 git commands to generate.