~ubuntu-branches/debian/squeeze/sympa/squeeze

« back to all changes in this revision

Viewing changes to debian/postrm

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Hornburg (Racke)
  • Date: 2004-04-29 01:04:22 UTC
  • Revision ID: james.westby@ubuntu.com-20040429010422-mz4bdfe39p4edznv
Tags: 3.4.4.3-6
* create system group for sympa instead of a regular one 
  (Closes: #246416, thanks to Martin Theiss <mtheiss@neo.wh-stuttgart.de>)
* updated Brazilian Portuguese debconf template translation
  (Closes: #228249, thanks to Andre Luis Lopes <andrelop@debian.org>)
* added Catalan debconf template translation (Closes: #236647, thanks to
  Aleix Badia i Bosch <abadia@ica.es>)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
set -e
 
4
 
 
5
. /usr/share/debconf/confmodule
 
6
 
 
7
case "$1" in
 
8
    "remove")
 
9
        # Don't fail here, the package might not be configured yet
 
10
        db_get sympa/use_wwsympa || true
 
11
        use_wwsympa="$RET"
 
12
 
 
13
    # Check whether the syslog configuration file is present
 
14
    # in case another system log daemon is used instead of syslog
 
15
        if [ -x /usr/sbin/syslog-facility ]; then
 
16
            if [ -e /etc/syslog.conf ]; then
 
17
                if [ -f /etc/sympa/facility ]; then
 
18
                    syslog-facility remove "`cat /etc/sympa/facility`"
 
19
                
 
20
                    if [ -x /etc/init.d/sysklogd ]; then
 
21
                        /etc/init.d/sysklogd reload
 
22
                    fi
 
23
                    rm -f /etc/sympa/facility
 
24
                fi
 
25
            fi
 
26
        fi
 
27
 
 
28
        if [ "$use_wwsympa" = "true" ]; then
 
29
            ## Remove Web server configuration
 
30
            db_get wwsympa/webserver_type
 
31
            webserver="$RET"
 
32
            
 
33
            case $webserver in
 
34
                "Apache")
 
35
                    webserver="apache"
 
36
                    ;;
 
37
                "Apache-SSL")
 
38
                    webserver="apache-ssl"
 
39
                    ;;
 
40
                *)
 
41
                    webserver="none"
 
42
                    ;;
 
43
            esac
 
44
 
 
45
            if [ $webserver != "none" ]; then
 
46
                # Check wether the configuration has been modifiyed
 
47
                db_get wwsympa/webserver_modifconf
 
48
                modifconf="$RET"
 
49
                
 
50
                if [ "$modifconf" = "true" ]; then    
 
51
                    # Remove configuration from httpd.conf
 
52
                    if [ -f /etc/$webserver/httpd.conf ]; then
 
53
                        sed -e '/#-- WWSYMPA begin/,/#-- WWSYMPA end/d' \
 
54
                            /etc/$webserver/httpd.conf > /etc/$webserver/httpd.conf.new
 
55
                        mv -f /etc/$webserver/httpd.conf.new /etc/$webserver/httpd.conf
 
56
                    fi
 
57
 
 
58
                    # Restarting web server if it was requested at configuration time.
 
59
                    db_get wwsympa/webserver_restart
 
60
                    restart="$RET"
 
61
                    
 
62
                    if [ "$restart" = "true" ]; then
 
63
                        /etc/init.d/$webserver restart
 
64
 
 
65
                        # End up with debconf
 
66
                        db_stop
 
67
                    fi
 
68
                fi
 
69
            fi
 
70
        fi
 
71
        ;;
 
72
    
 
73
    "purge")
 
74
        db_get sympa/use_wwsympa
 
75
        use_wwsympa="$RET"
 
76
 
 
77
        if [ "$use_wwsympa" = "true" ]; then
 
78
            db_get wwsympa/remove_spool
 
79
            remove_archives="$RET"
 
80
    
 
81
            if [ "$remove_archives" = "true" ]; then
 
82
                echo ""
 
83
                echo "Removing archives and spool subdirectories as requested ..."
 
84
                rm -rf /var/lib/sympa/wwsarchive 2>/dev/null || true
 
85
                rm -rf /var/spool/sympa/wws*  2>/dev/null || true
 
86
            fi
 
87
        fi
 
88
 
 
89
        # Delete the log files if purging
 
90
        # Remove aliases too.
 
91
        rm -f /var/log/sympa.log*
 
92
 
 
93
        if [ -f /etc/aliases ]; then
 
94
            sed -e '/#-- SYMPA begin/,/#-- SYMPA end/d' \
 
95
                /etc/aliases >/etc/aliases.new
 
96
            mv -f /etc/aliases.new /etc/aliases
 
97
            newaliases
 
98
        fi
 
99
 
 
100
        rm -f /etc/sympa/cookie   2>/dev/null || true
 
101
        rm -f /etc/sympa/cookies.history
 
102
 
 
103
        # Remove configuration files
 
104
        rm -f /etc/sympa/sympa.conf
 
105
        rm -f /etc/sympa/wwsympa.conf
 
106
 
 
107
        # Try to remove if empty
 
108
        rmdir /etc/sympa          2>/dev/null || true
 
109
 
 
110
        db_get sympa/remove_spool
 
111
        remove_spool="$RET"
 
112
 
 
113
        if [ "$remove_spool" = "true" ]; then
 
114
            echo ""
 
115
            echo "Removing lists data and spool directory as requested ..."
 
116
            rm -rf /var/lib/sympa 2>/dev/null || true
 
117
            rm -rf /var/spool/sympa 2>/dev/null || true
 
118
        fi
 
119
 
 
120
        # Remove the database if asked for
 
121
        db_get sympa/use_db
 
122
        use_db="$RET"
 
123
 
 
124
        if [ "$use_db" = "true" ]; then 
 
125
            
 
126
            # Check whether it was configured
 
127
            db_get sympa/db_configured
 
128
            db_configured="$RET"
 
129
            
 
130
            db_get sympa/db_removeonpurge
 
131
            db_removeonpurge="$RET"
 
132
            
 
133
            if [ "$db_configured" = "true" -a "$db_removeonpurge" = "true" ]
 
134
            then
 
135
                # Get the database info
 
136
                db_get sympa/db_type
 
137
                db_type="$RET"
 
138
                
 
139
                db_get sympa/db_hostname
 
140
                db_host="$RET"
 
141
            
 
142
                db_get sympa/db_name
 
143
                db_name="$RET"
 
144
                
 
145
                db_fset sympa/db_adminpasswd seen false
 
146
                db_input critical sympa/db_adminpasswd || true
 
147
                db_go
 
148
                
 
149
                db_get sympa/db_adminpasswd
 
150
                adminpass="$RET"
 
151
                db_reset sympa/db_adminpasswd
 
152
                
 
153
                set +e
 
154
                
 
155
                case $db_type in
 
156
                    "PostgreSQL")
 
157
                        echo -n "Trying to remove your PostgreSQL database ..."
 
158
                        perl -e "
 
159
                            use DBI;
 
160
 
 
161
                            my \$dsn = \"DBI:Pg:dbname=template1\";
 
162
 
 
163
                            if ($db_host ne 'localhost') {
 
164
                                \$dsn .= \";host=$db_host\";
 
165
                            }
 
166
 
 
167
                            # Connect to PostgreSQL
 
168
                            my \$dbh = DBI->connect(\$dsn, \"postgres\", \"$adminpass\",
 
169
                                                    {\"RaiseError\" => 1});
 
170
 
 
171
                            # Remove database
 
172
                            eval {\$dbh->do(\"DROP DATABASE $db_name\")};
 
173
                        
 
174
                            # Remove user sympa
 
175
                            \$dbh->do(\"DELETE FROM pg_shadow WHERE usename='sympa'\");
 
176
 
 
177
                            \$dbh->disconnect();" >/dev/null 2>&1
 
178
                        ;;
 
179
 
 
180
                    "MySQL")
 
181
                        echo -n "Trying to remove your MySQL database ..."
 
182
                        perl -e "
 
183
                            use DBI;
 
184
 
 
185
                            my \$dsn = \"DBI:mysql:database=mysql\";
 
186
 
 
187
                            if ($db_host ne 'localhost') {
 
188
                                \$dsn .= \";host=$db_host\";
 
189
                            }
 
190
                        
 
191
                            # Connect to mysql
 
192
                            my \$dbh = DBI->connect(\$dsn, \"root\", \"$adminpass\",
 
193
                                                    {\"RaiseError\" => 1});
 
194
 
 
195
                            # Remove the database
 
196
                            eval {\$dbh->do(\"DROP DATABASE $db_name\")};
 
197
 
 
198
                            # Remove user sympa
 
199
                            \$dbh->do(\"DELETE FROM user WHERE user='sympa'\");
 
200
                            \$dbh->do(\"DELETE FROM db WHERE user='sympa'\");
 
201
                            \$dbh->do(\"FLUSH PRIVILEGES\");
 
202
                        
 
203
                            \$dbh->disconnect();" >/dev/null 2>&1
 
204
                        ;;
 
205
                esac
 
206
 
 
207
                if [ "$?" != "0" ]; then
 
208
                    /bin/echo -e "Failed\n\n"
 
209
                    echo "I was not able to connect to the database server."
 
210
                    echo "You will have to remove the sympa database yourself."
 
211
                else
 
212
                    echo " OK"
 
213
                    db_set "sympa/db_configured" "false"
 
214
                fi
 
215
                
 
216
                set -e
 
217
            fi
 
218
        fi
 
219
        ;;
 
220
esac
 
221
 
 
222
 
 
223
# Other jobs
 
224
#DEBHELPER#
 
225