]>
Commit | Line | Data |
---|---|---|
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 | 25 | if 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 | |
31 | else | |
32 | exit 0 | |
036261c0 | 33 | fi |
1f86fa83 | 34 | |
7728b647 | 35 | [ -z "$HTTPD_MPM" ] && HTTPD_MPM="prefork" |
e5db1e51 | 36 | if [ -d "${HTTPD_CONF:-'/etc/httpd/httpd.conf'}" ]; then |
37 | CFG="-d ${HTTPD_CONF:-'/etc/httpd/httpd.conf'}" | |
38 | elif [ -f "${HTTPD_CONF:-'/etc/httpd/httpd.conf'}" ]; then | |
39 | CFG="-f ${HTTPD_CONF:-'/etc/httpd/httpd.conf'}" | |
40 | elif [ -n "$HTTPD_CONF" ]; then | |
41 | echo "error: HTTPD_CONF='$HTTPD_CONF': not a file, not a directory" | |
42 | exit 1 | |
77079cb1 | 43 | else CFG=""; fi |
7728b647 | 44 | |
e156d1e7 | 45 | RETVAL=0 |
58f9559b AF |
46 | # See how we were called. |
47 | case "$1" in | |
48 | start) | |
34c86420 | 49 | # Check if the service is already running? |
a7f729cf | 50 | if [ ! -f /var/lock/subsys/httpd ]; then |
7728b647 | 51 | msg_starting httpd.${HTTPD_MPM} |
77079cb1 | 52 | daemon httpd.${HTTPD_MPM} $CFG $HTTPD_OPTS |
a7f729cf | 53 | RETVAL=$? |
54 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/httpd | |
34c86420 | 55 | else |
7728b647 | 56 | msg_already_running httpd.${HTTPD_MPM} |
34c86420 | 57 | fi |
58f9559b AF |
58 | ;; |
59 | stop) | |
a7f729cf | 60 | # Stop daemons. |
a4aad8e2 | 61 | if [ -f /var/lock/subsys/httpd ]; then |
7728b647 | 62 | msg_stopping httpd.${HTTPD_MPM} |
33719b4e | 63 | if [ -f /var/run/httpd.pid ]; then |
744321de | 64 | PID=$(filter_chroot `cat /var/run/httpd.pid`) |
5d03c77a | 65 | if [ -z "$PID" ]; then |
744321de | 66 | PID=0 |
67 | fi | |
33719b4e | 68 | else |
69 | PID=0 | |
70 | fi | |
5bd16c4e | 71 | daemon httpd.${HTTPD_MPM} -f /etc/httpd/httpd.conf -k stop |
af95835e | 72 | RET=$? |
33719b4e | 73 | # Wait for httpd to really stop |
af95835e | 74 | if [ ! $PID -eq 0 -a $RET -eq 0 ]; then |
33719b4e | 75 | show "Waiting for httpd to stop" |
76 | busy | |
bbc7ea85 | 77 | while ps -o command $PID | grep -q ^httpd |
33719b4e | 78 | do |
79 | sleep 1 | |
80 | done | |
81 | ok | |
82 | fi | |
af95835e | 83 | # Delete pidfile only when apache was called successfully |
84 | if [ $RET -eq 0 ]; then | |
85 | rm -f /var/lock/subsys/httpd /var/run/httpd.pid /var/run/httpd.loc* >/dev/null 2>&1 | |
86 | fi | |
a7f729cf | 87 | else |
7728b647 | 88 | msg_not_running httpd.${HTTPD_MPM} |
a4aad8e2 | 89 | fi |
58f9559b AF |
90 | ;; |
91 | status) | |
7728b647 | 92 | status httpd.${HTTPD_MPM} |
b3d1e4ee | 93 | RETVAL=$? |
5bd16c4e | 94 | /usr/sbin/httpd.${HTTPD_MPM} -f /etc/httpd/httpd.conf -S |
58f9559b | 95 | ;; |
40350f98 | 96 | restart) |
f9712db9 | 97 | $0 stop |
58f9559b AF |
98 | $0 start |
99 | ;; | |
f9712db9 | 100 | reload|force-reload|graceful) |
e156d1e7 | 101 | if [ -f /var/lock/subsys/httpd ]; then |
7728b647 | 102 | msg_reloading httpd.${HTTPD_MPM} |
5bd16c4e | 103 | daemon httpd.${HTTPD_MPM} -f /etc/httpd/httpd.conf -k graceful |
e156d1e7 | 104 | RETVAL=$? |
105 | else | |
7728b647 | 106 | msg_not_running httpd.${HTTPD_MPM} >&2 |
e156d1e7 | 107 | RETVAL=7 |
108 | fi | |
40350f98 | 109 | ;; |
58f9559b | 110 | *) |
62c5d063 | 111 | msg_usage "$0 {start|stop|restart|reload|force-reload|graceful|status}" |
e156d1e7 | 112 | exit 3 |
58f9559b AF |
113 | ;; |
114 | esac | |
115 | ||
a4aad8e2 | 116 | exit $RETVAL |