~ubuntu-branches/ubuntu/saucy/apache2/saucy

« back to all changes in this revision

Viewing changes to debian/init-script

  • Committer: Bazaar Package Importer
  • Author(s): Thom May
  • Date: 2004-10-13 19:46:10 UTC
  • Revision ID: james.westby@ubuntu.com-20041013194610-ccvqcz8vflh5zqrm
Tags: 2.0.50-12ubuntu4
Security Release. Patch from upstream for the following:
CAN-2004-0885SSLCypherSuite can be bypassed during renegotiation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh -e
 
2
#
 
3
# apache2               This init.d script is used to start apache2.
 
4
#                       It basically just calls apache2ctl.
 
5
 
 
6
ENV="env -i LANG=C PATH=/usr/local/bin:/usr/bin:/bin"
 
7
 
 
8
#[ `ls -1 /etc/apache2/sites-enabled/ | wc -l | sed -e 's/ *//;'` -eq 0 ] && \
 
9
#echo "You haven't enabled any sites yet, so I'm not starting apache2." && \
 
10
#echo "To add and enable a host, use addhost and enhost." && exit 0
 
11
 
 
12
#edit /etc/default/apache2 to change this.
 
13
NO_START=0
 
14
 
 
15
set -e
 
16
if [ -x /usr/sbin/apache2 ] ; then
 
17
        HAVE_APACHE2=1
 
18
else
 
19
        exit 0
 
20
fi
 
21
 
 
22
. /lib/lsb/init-functions
 
23
 
 
24
test -f /etc/default/rcS && . /etc/default/rcS
 
25
test -f /etc/default/apache2 && . /etc/default/apache2
 
26
if [ "$NO_START" != "0" ]; then 
 
27
        [ "$VERBOSE" != no ] && log_warning_msg "Not starting apache2 - edit /etc/default/apache2 and change NO_START to be 0.";
 
28
        exit 0;
 
29
fi
 
30
 
 
31
APACHE2="$ENV /usr/sbin/apache2"
 
32
APACHE2CTL="$ENV /usr/sbin/apache2ctl"
 
33
 
 
34
apache_stop() {
 
35
        if `apache2 -t > /dev/null 2>&1`; then
 
36
                # if the config is ok than we just stop normaly
 
37
                $APACHE2 -k stop
 
38
        else
 
39
                # if we are here something is broken and we need to try
 
40
                # to exit as nice and clean as possible
 
41
 
 
42
                # if pidof is null for some reasons the script exits automagically
 
43
                # classified as good/unknown feature
 
44
                PIDS=`pidof apache2`
 
45
 
 
46
                PID=""
 
47
 
 
48
                # let's try to find the pid file
 
49
                # apache2 allows more than PidFile entry in the config but only
 
50
                # the last found in the config is used
 
51
                for PFILE in `grep ^PidFile /etc/apache2/* -r | awk '{print $2}'`; do
 
52
                        if [ -e $PFILE ]; then
 
53
                                PID=`cat $PFILE`
 
54
                        fi
 
55
                done
 
56
                REALPID=0
 
57
                # if there is a pid we need to verify that belongs to apache2
 
58
                # for real
 
59
                for i in $PIDS; do
 
60
                        if [ "$i" = "$PID" ]; then
 
61
                                # in this case the pid stored in the
 
62
                                # pidfile matches one of the pidof apache
 
63
                                # so a simple kill will make it
 
64
                                REALPID=1
 
65
                        fi
 
66
                done
 
67
 
 
68
                if [ $REALPID = 1 ]; then
 
69
                        # in this case it is everything nice and dandy
 
70
                        # and we kill apache2
 
71
                        kill $PID
 
72
                else
 
73
                        # this is the worst situation... just kill all of them
 
74
                        for i in $PIDS; do
 
75
                                kill $i
 
76
                        done
 
77
                fi
 
78
        fi
 
79
}
 
80
 
 
81
# Stupid hack to keep lintian happy. (Warrk! Stupidhack!).
 
82
case $1 in
 
83
        start)
 
84
                [ -f /etc/apache2/httpd.conf ] || touch /etc/apache2/httpd.conf
 
85
                #ssl_scache shouldn't be here if we're just starting up.
 
86
                [ -f /var/run/apache2/ssl_scache ] && rm /var/run/apache2/ssl_scache
 
87
                log_begin_msg "Starting web server (Apache2)..."
 
88
                if $APACHE2 -k start -DSSL; then
 
89
                        log_end_msg 0
 
90
                else
 
91
                        log_end_msg 1
 
92
                fi
 
93
        ;;
 
94
        stop)
 
95
                log_begin_msg "Stopping web server (Apache2)..."
 
96
                if apache_stop; then
 
97
                        log_end_msg 0
 
98
                else
 
99
                        log_end_msg 1
 
100
                fi
 
101
        ;;
 
102
        reload)
 
103
                log_begin_msg "Reloading web server config..."
 
104
                if $APACHE2CTL graceful $2 ; then
 
105
                        log_end_msg 0
 
106
                else
 
107
                        log_end_msg 1
 
108
                fi
 
109
        ;;
 
110
        restart)
 
111
                log_begin_msg "Restarting web server (Apache2)..."
 
112
                if $APACHE2CTL restart; then
 
113
                        log_end_msg 0
 
114
                else
 
115
                        log_end_msg 1
 
116
                fi
 
117
        ;;
 
118
        force-reload)
 
119
                log_begin_msg "Forcing reload of web server (Apache2)..."
 
120
                if ! apache_stop; then
 
121
                        log_end_msg 1
 
122
                fi
 
123
                sleep 10
 
124
                if $APACHE2CTL start; then
 
125
                        log_end_msg 0
 
126
                else
 
127
                        log_end_msg 1
 
128
                fi
 
129
        ;;
 
130
        *)
 
131
                log_success_msg "Usage: /etc/init.d/apache2 start|stop|restart|reload|force-reload"
 
132
        ;;
 
133
esac