~ubuntu-branches/ubuntu/wily/mysql-5.6/wily

« back to all changes in this revision

Viewing changes to packaging/deb-utopic/mysql-community-server.postrm

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2015-04-16 20:07:10 UTC
  • mto: (1.3.9 vivid-proposed)
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: package-import@ubuntu.com-20150416200710-pcrsa022082zj46k
Tags: upstream-5.6.24
ImportĀ upstreamĀ versionĀ 5.6.24

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
 
 
3
# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
 
4
#
 
5
# This program is free software; you can redistribute it and/or modify
 
6
# it under the terms of the GNU General Public License as published by
 
7
# the Free Software Foundation; version 2 of the License.
 
8
#
 
9
# This program is distributed in the hope that it will be useful,
 
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
# GNU General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU General Public License
 
15
# along with this program; if not, write to the Free Software
 
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
17
 
 
18
if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ];
 
19
then
 
20
. /usr/share/debconf/confmodule
 
21
fi
 
22
 
 
23
place_upstart_job_back () {
 
24
        if [ -e "/var/lib/mysql/.mysql.conf.backup" ];
 
25
        then
 
26
                mv /var/lib/mysql/.mysql.conf.backup /etc/init/mysql.conf
 
27
        fi
 
28
}
 
29
 
 
30
get_pcount () {
 
31
        PSCOUNT=$(ps -ef | grep "/usr/sbin/mysqld" | wc -l)
 
32
        echo "${PSCOUNT}"
 
33
}
 
34
 
 
35
server_stop () {
 
36
        PSCOUNT=$(get_pcount)
 
37
        COUNT=0
 
38
        while :; do
 
39
                COUNT=$(( COUNT+1 ))
 
40
                echo -n .
 
41
                if [ "${PSCOUNT}" -eq 1 ];
 
42
                then
 
43
                        echo
 
44
                        break
 
45
                fi
 
46
                if [ "${COUNT}" -gt 15 ];
 
47
                then
 
48
                        echo
 
49
                        return 1
 
50
                fi
 
51
                PSCOUNT=$(get_pcount)
 
52
                sleep 1
 
53
        done
 
54
        return 0
 
55
}
 
56
 
 
57
case "$1" in
 
58
        remove)
 
59
 
 
60
        set -e
 
61
 
 
62
        place_upstart_job_back
 
63
 
 
64
        set +e
 
65
 
 
66
        ;;
 
67
 
 
68
        purge)
 
69
 
 
70
        set -e
 
71
 
 
72
        place_upstart_job_back
 
73
 
 
74
        MYSQLDATA=/var/lib/mysql
 
75
        MYSQLLOG=/var/log/mysql
 
76
        MYSQLRUN=/var/run/mysqld
 
77
 
 
78
        server_stop
 
79
 
 
80
        db_input high mysql-community-server/remove-data-dir || true
 
81
        db_go
 
82
        db_get mysql-community-server/remove-data-dir && RMDATADIR=${RET}
 
83
        if [ "${RMDATADIR}" = "true" ];
 
84
        then
 
85
                if [ -d ${MYSQLRUN} ] || [ -L ${MYSQLRUN} ];
 
86
                then
 
87
                        rm -rf ${MYSQLRUN}
 
88
                fi
 
89
 
 
90
                if [ -d ${MYSQLLOG} ] || [ -L ${MYSQLLOG} ];
 
91
                then
 
92
                        rm -rf ${MYSQLLOG}
 
93
                fi
 
94
 
 
95
                if [ -d ${MYSQLDATA} ] || [ -L ${MYSQLDATA} ];
 
96
                then
 
97
                        rm -rf ${MYSQLDATA}
 
98
                fi
 
99
 
 
100
                if getent passwd mysql >/dev/null;
 
101
                then
 
102
                        userdel mysql
 
103
                fi
 
104
        fi
 
105
 
 
106
        set +e
 
107
        ;;
 
108
 
 
109
        abort-install)
 
110
 
 
111
        set -e
 
112
 
 
113
        place_upstart_job_back
 
114
 
 
115
        if [ -x "/etc/init.d/mysql" ];
 
116
        then
 
117
                invoke-rc.d mysql start || exit $?
 
118
        else
 
119
                if [ -d ${MYSQLRUN} ] || [ -L ${MYSQLRUN} ];
 
120
                then
 
121
                        rm -rf ${MYSQLRUN}
 
122
                fi
 
123
 
 
124
                if [ -d ${MYSQLLOG} ] || [ -L ${MYSQLLOG} ];
 
125
                then
 
126
                        rm -rf ${MYSQLLOG}
 
127
                fi
 
128
 
 
129
                if [ -d ${MYSQLDATA} ] || [ -L ${MYSQLDATA} ];
 
130
                then
 
131
                        rm -rf ${MYSQLDATA}
 
132
                fi
 
133
 
 
134
                if getent passwd mysql >/dev/null;
 
135
                then
 
136
                        userdel mysql
 
137
                fi
 
138
        fi
 
139
 
 
140
        set +e
 
141
        ;;
 
142
 
 
143
        upgrade|abort-upgrade)
 
144
 
 
145
        ;;
 
146
 
 
147
        *)
 
148
        exit 1
 
149
        ;;
 
150
esac
 
151
 
 
152
#DEBHELPER#
 
153
 
 
154
exit 0