]> git.pld-linux.org Git - packages/apache.git/blame - apache.init
- added HTTPD_CONF variable
[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
40350f98
MM
10# config: /etc/httpd/conf/access.conf
11# config: /etc/httpd/conf/httpd.conf
12# config: /etc/httpd/conf/srm.conf
34c86420 13
14
15# Source function library
58f9559b
AF
16. /etc/rc.d/init.d/functions
17
34c86420 18# Get network config
19. /etc/sysconfig/network
20
21# Get service config
22[ -f /etc/sysconfig/apache ] && . /etc/sysconfig/apache
23
58f9559b 24# Check that networking is up.
a7f729cf 25if is_yes "${NETWORKING}"; then
bc107690 26 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
a7f729cf 27 # nls "ERROR: Networking is down. %s can't be run." <service>
28 msg_network_down httpd
29 exit 1
30 fi
31else
32 exit 0
036261c0 33fi
1f86fa83 34
7728b647 35[ -z "$HTTPD_MPM" ] && HTTPD_MPM="prefork"
77079cb1 36[ -z "$HTTPD_CONF" ] && HTTPD_CONF="/etc/httpd/httpd.conf"
37if [ -d "$HTTPD_CONF" ]; then CFG="-d $HTTPD_CONF"
38elif [ -f "$HTTPD_CONF" ]; then CFG="-f $HTTPD_CONF"
39else CFG=""; fi
7728b647 40
e156d1e7 41RETVAL=0
58f9559b
AF
42# See how we were called.
43case "$1" in
44 start)
34c86420 45 # Check if the service is already running?
a7f729cf 46 if [ ! -f /var/lock/subsys/httpd ]; then
7728b647 47 msg_starting httpd.${HTTPD_MPM}
77079cb1 48 daemon httpd.${HTTPD_MPM} $CFG $HTTPD_OPTS
a7f729cf 49 RETVAL=$?
50 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/httpd
34c86420 51 else
7728b647 52 msg_already_running httpd.${HTTPD_MPM}
34c86420 53 fi
58f9559b
AF
54 ;;
55 stop)
a7f729cf 56 # Stop daemons.
a4aad8e2 57 if [ -f /var/lock/subsys/httpd ]; then
7728b647 58 msg_stopping httpd.${HTTPD_MPM}
33719b4e 59 if [ -f /var/run/httpd.pid ]; then
744321de 60 PID=$(filter_chroot `cat /var/run/httpd.pid`)
5d03c77a 61 if [ -z "$PID" ]; then
744321de 62 PID=0
63 fi
33719b4e 64 else
65 PID=0
66 fi
5bd16c4e 67 daemon httpd.${HTTPD_MPM} -f /etc/httpd/httpd.conf -k stop
af95835e 68 RET=$?
33719b4e 69 # Wait for httpd to really stop
af95835e 70 if [ ! $PID -eq 0 -a $RET -eq 0 ]; then
33719b4e 71 show "Waiting for httpd to stop"
72 busy
bbc7ea85 73 while ps -o command $PID | grep -q ^httpd
33719b4e 74 do
75 sleep 1
76 done
77 ok
78 fi
af95835e 79 # Delete pidfile only when apache was called successfully
80 if [ $RET -eq 0 ]; then
81 rm -f /var/lock/subsys/httpd /var/run/httpd.pid /var/run/httpd.loc* >/dev/null 2>&1
82 fi
a7f729cf 83 else
7728b647 84 msg_not_running httpd.${HTTPD_MPM}
a4aad8e2 85 fi
58f9559b
AF
86 ;;
87 status)
7728b647 88 status httpd.${HTTPD_MPM}
b3d1e4ee 89 RETVAL=$?
5bd16c4e 90 /usr/sbin/httpd.${HTTPD_MPM} -f /etc/httpd/httpd.conf -S
58f9559b 91 ;;
40350f98 92 restart)
f9712db9 93 $0 stop
58f9559b
AF
94 $0 start
95 ;;
f9712db9 96 reload|force-reload|graceful)
e156d1e7 97 if [ -f /var/lock/subsys/httpd ]; then
7728b647 98 msg_reloading httpd.${HTTPD_MPM}
5bd16c4e 99 daemon httpd.${HTTPD_MPM} -f /etc/httpd/httpd.conf -k graceful
e156d1e7 100 RETVAL=$?
101 else
7728b647 102 msg_not_running httpd.${HTTPD_MPM} >&2
e156d1e7 103 RETVAL=7
104 fi
40350f98 105 ;;
58f9559b 106 *)
62c5d063 107 msg_usage "$0 {start|stop|restart|reload|force-reload|graceful|status}"
e156d1e7 108 exit 3
58f9559b
AF
109 ;;
110esac
111
a4aad8e2 112exit $RETVAL
This page took 0.092652 seconds and 4 git commands to generate.