removed whitespace
[strongswan.git] / testing / hosts / winnetou / etc / init.d / apache2
1 #!/sbin/runscript
2 # Copyright 1999-2007 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
5 opts="configtest fullstatus graceful gracefulstop modules reload"
6
7 depend() {
8         need net
9         use mysql dns logger netmount postgresql
10         after sshd
11 }
12
13 configtest() {
14         ebegin "Checking Apache Configuration"
15         checkconfig
16         eend $?
17 }
18
19 checkconfig() {
20         SERVERROOT="${SERVERROOT:-/usr/lib/apache2}"
21         if [ ! -d ${SERVERROOT} ]; then
22                 eerror "SERVERROOT does not exist: ${SERVERROOT}"
23                 return 1
24         fi
25
26         CONFIGFILE="${CONFIGFILE:-/etc/apache2/httpd.conf}"
27         [ "${CONFIGFILE#/}" = "${CONFIGFILE}" ] && CONFIGFILE="${SERVERROOT}/${CONFIGFILE}"
28         if [ ! -r "${CONFIGFILE}" ]; then
29                 eerror "Unable to read configuration file: ${CONFIGFILE}"
30                 return 1
31         fi
32
33         APACHE2_OPTS="${APACHE2_OPTS} -d ${SERVERROOT}"
34         APACHE2_OPTS="${APACHE2_OPTS} -f ${CONFIGFILE}"
35         [ -n "${STARTUPERRORLOG}" ] && APACHE2_OPTS="${APACHE2_OPTS} -E ${STARTUPERRORLOG}"
36
37         APACHE2="/usr/sbin/apache2"
38
39         ${APACHE2} ${APACHE2_OPTS} -t 1>/dev/null 2>&1
40         ret=$?
41         if [ $ret -ne 0 ]; then
42                 eerror "Apache2 has detected a syntax error in your configuration files:"
43                 ${APACHE2} ${APACHE2_OPTS} -t
44         fi
45
46         return $ret
47 }
48
49 start() {
50         checkconfig || return 1
51         ebegin "Starting apache2"
52         [ -f /var/log/apache2/ssl_scache ] && rm /var/log/apache2/ssl_scache
53
54         start-stop-daemon --start --exec ${APACHE2} -- ${APACHE2_OPTS} -k start
55         eend $?
56 }
57
58 stop() {
59         checkconfig || return 1
60         ebegin "Stopping apache2"
61         start-stop-daemon --stop --retry -TERM/5/-KILL/5 --exec ${APACHE2} --pidfile /var/run/apache2.pid
62         eend $?
63 }
64
65 reload() {
66         RELOAD_TYPE="${RELOAD_TYPE:-graceful}"
67
68         checkconfig || return 1
69         if [ "${RELOAD_TYPE}" = "restart" ]; then
70                 ebegin "Restarting apache2"
71                 start-stop-daemon --stop --oknodo --signal HUP --exec ${APACHE2} --pidfile /var/run/apache2.pid
72                 eend $?
73         elif [ "${RELOAD_TYPE}" = "graceful" ]; then
74                 ebegin "Gracefully restarting apache2"
75                 start-stop-daemon --stop --oknodo --signal USR1 --exec ${APACHE2} --pidfile /var/run/apache2.pid
76                 eend $?
77         else
78                 eerror "${RELOAD_TYPE} is not a valid RELOAD_TYPE. Please edit /etc/conf.d/apache2"
79         fi
80 }
81
82 graceful() {
83         checkconfig || return 1
84         ebegin "Gracefully restarting apache2"
85         start-stop-daemon --stop --signal USR1 --exec ${APACHE2} --pidfile /var/run/apache2.pid
86         eend $?
87 }
88
89 gracefulstop() {
90         checkconfig || return 1
91         
92         # zap!
93         if service_started "${myservice}"; then
94                 mark_service_stopped "${myservice}"
95         fi
96
97         ebegin "Gracefully stopping apache2"
98         # 28 is SIGWINCH
99         start-stop-daemon --stop --signal 28 --exec ${APACHE2} --pidfile /var/run/apache2.pid
100         eend $?
101 }
102
103 modules() {
104         checkconfig || return 1
105
106         ${APACHE2} ${APACHE2_OPTS} -M 2>&1
107 }
108
109 status() {
110         LYNX="${LYNX:-lynx -dump}"
111         STATUSURL="${STATUSURL:-http://localhost/server-status}"
112         
113         ${LYNX} ${STATUSURL} | awk ' /process$/ { print; exit } { print } '
114 }
115
116 fullstatus() {
117         LYNX="${LYNX:-lynx -dump}"
118         STATUSURL="${STATUSURL:-http://localhost/server-status}"
119         
120         ${LYNX} ${STATUSURL}
121 }