~ubuntu-branches/ubuntu/hardy/openssl/hardy-security

« back to all changes in this revision

Viewing changes to debian/libssl0.9.7.postinst

  • Committer: Bazaar Package Importer
  • Author(s): Kurt Roeckx
  • Date: 2005-12-13 21:37:42 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051213213742-7em5nrw5c7ceegyd
Tags: 0.9.8a-5
Stop ssh from crashing randomly on sparc (Closes: #335912)
Patch from upstream cvs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh -e
2
 
 
3
 
. /usr/share/debconf/confmodule
4
 
 
5
 
package_name()
6
 
{
7
 
    echo $(basename $0 .postinst)
8
 
}
9
 
 
10
 
# element() is a helper function for file-rc:
11
 
element() {
12
 
    local element list IFS
13
 
 
14
 
    element="$1"
15
 
 
16
 
    [ "$2" = "in" ] && shift
17
 
    list="$2"
18
 
    [ "$list" = "-" ] && return 1
19
 
    [ "$list" = "*" ] && return 0
20
 
 
21
 
    IFS=","
22
 
    set -- $list
23
 
    case $element in
24
 
        "$1"|"$2"|"$3"|"$4"|"$5"|"$6"|"$7"|"$8"|"$9")
25
 
            return 0
26
 
    esac
27
 
    return 1
28
 
}
29
 
 
30
 
# filerc (runlevel, service) returns /etc/init.d/service, if service is
31
 
# running in $runlevel:
32
 
filerc() {
33
 
    local runlevel basename
34
 
    runlevel=$1
35
 
    basename=$2
36
 
    while read LINE
37
 
    do
38
 
        case $LINE in
39
 
            \#*|"") continue
40
 
        esac
41
 
 
42
 
        set -- $LINE
43
 
        SORT_NO="$1"; STOP="$2"; START="$3"; CMD="$4"
44
 
        [ "$CMD" = "/etc/init.d/$basename" ] || continue
45
 
 
46
 
        if element "$runlevel" in "$START" || element "S" in "$START"
47
 
        then
48
 
            echo "/etc/init.d/$basename"
49
 
            return 0
50
 
        fi
51
 
    done < /etc/runlevel.conf
52
 
    echo ""
53
 
}
54
 
 
55
 
if [ "$1" = "configure" ]
56
 
then
57
 
    if [ ! -z $2 ]; then
58
 
        if dpkg --compare-versions $2 lt 0.9.7d-1; then
59
 
            echo -n "Checking for services that may need to be restarted..."
60
 
 
61
 
            check="sendmail ssh"
62
 
            check="$check apache2-common ssh-nonfree exim4"
63
 
            check="$check apache-ssl libapache-mod-ssl openvpn spamassassin"
64
 
            check="$check courier-imap-ssl courier-mta-ssl courier-pop-ssl"
65
 
            check="$check postfix-tls cyrus21-imapd cyrus21-pop3d"
66
 
            check="$check postgresql racoon"
67
 
            # Only get the ones that are installed, and configured
68
 
            check=$(dpkg -s $check 2> /dev/null | sed '/^$/{N;/^\n$/D;}' | awk 'BEGIN{RS="\n\n";FS="\n"}{if ( $2 ~ /Status: .* installed$/ ) { print $1 } }' | cut -f 2 -d ' ')
69
 
            # apache2 ships its init script in apache2-common, but the
70
 
            # script is apache2
71
 
            check=$(echo $check | sed 's/apache2-common/apache2/g')
72
 
            # For mod-ssl apache has to be restarted
73
 
            check=$(echo $check | sed 's/libapache-mod-ssl/apache/g')
74
 
            rl=$(runlevel | awk '{print $2}')
75
 
            for service in $check; do
76
 
                if [ -f /usr/share/file-rc/rc -o -f /usr/lib/file-rc/rc ] && [ -f /etc/runlevel.conf ]; then
77
 
                    idl=$(filerc $rl $service)
78
 
                else
79
 
                    idl=$(ls /etc/rc${rl}.d/S??${service} 2> /dev/null | head -n 1)
80
 
                fi
81
 
                if [ -n "$idl" ] && [ -x $idl ]; then
82
 
                    services="$service $services"
83
 
                fi
84
 
            done
85
 
            echo "done."
86
 
            if [ -n "$services" ]; then
87
 
                db_version 2.0
88
 
 
89
 
                db_reset libssl0.9.7/restart-services
90
 
                db_set libssl0.9.7/restart-services "$services"
91
 
                db_input critical libssl0.9.7/restart-services || true
92
 
                db_go || true
93
 
                db_get libssl0.9.7/restart-services
94
 
                # Arghhh, close all the stupid debconf pipes
95
 
                db_stop
96
 
                
97
 
                if [ "x$RET" != "x" ]
98
 
                then
99
 
                    services=$RET
100
 
                    answer=yes
101
 
                else
102
 
                    answer=no
103
 
                fi
104
 
                echo
105
 
                if [ "$answer" = yes ] && [ "$services" != "" ]; then
106
 
                    echo "Restarting services possibly affected by the upgrade:"
107
 
                    failed=""
108
 
                    for service in $services; do
109
 
                        idl=$(ls /etc/rc${rl}.d/S??${service} 2> /dev/null | head -n 1)
110
 
                        echo -n "  $service: stopping..."
111
 
                        $idl stop > /dev/null 2>&1 || true
112
 
                        sleep 1
113
 
                        echo -n "starting..."
114
 
                        if $idl start > /dev/null 2>&1; then
115
 
                            echo "done."
116
 
                        else
117
 
                            echo "FAILED! ($?)"
118
 
                            failed="$service $failed"
119
 
                        fi
120
 
                    done
121
 
                    echo
122
 
                    if [ -n "$failed" ]; then
123
 
                        # Ruh roh, George
124
 
                        echo "The following services failed to start: $failed"
125
 
                        echo
126
 
                        echo "You will need to start these manually by running \`/etc/init.d/<service> start'"
127
 
                        echo "If the service still fails to start, you may need to file a bug on"
128
 
                        echo "$(package_name) or the service involved."
129
 
                    else
130
 
                        echo "Services restarted successfully."
131
 
                    fi
132
 
                    echo
133
 
                fi
134
 
            fi
135
 
        fi # end upgrading and $2 lt 0.9.7c-1
136
 
    fi # Upgrading
137
 
fi
138
 
 
139
 
#DEBHELPER#