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

« back to all changes in this revision

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

  • 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
. /usr/share/debconf/confmodule
 
19
 
 
20
take_upstart_job_backup () {
 
21
        if [ -e "/etc/init/mysql.conf" ] && [ -d "/var/lib/mysql" ];
 
22
        then
 
23
                mv /etc/init/mysql.conf /var/lib/mysql/.mysql.conf.backup
 
24
        fi
 
25
}
 
26
 
 
27
case "$1" in
 
28
        configure)
 
29
 
 
30
        if [ -z "$2" ];
 
31
        then
 
32
                set -e
 
33
 
 
34
                MYSQLDATA=/var/lib/mysql
 
35
 
 
36
                if [ ! -d "${MYSQLDATA}/mysql" -a ! -L "${MYSQLDATA}/mysql" ];
 
37
                then
 
38
                        mkdir ${MYSQLDATA}/mysql
 
39
                        chown mysql:mysql ${MYSQLDATA}/mysql
 
40
                        chmod 750 ${MYSQLDATA}/mysql
 
41
                        if [ ! "$(ls -A ${MYSQLDATA}/mysql)" ];
 
42
                        then
 
43
                                mysql_install_db --user=mysql > /dev/null
 
44
                        fi
 
45
                fi
 
46
 
 
47
                db_get mysql-community-server/root-pass && PASSWD=${RET}
 
48
                if [ ! -z "${PASSWD}" ];
 
49
                then
 
50
                        db_set mysql-community-server/root-pass ""
 
51
                        db_set mysql-community-server/re-root-pass ""
 
52
                        PASSWD="UPDATE user SET password=PASSWORD('${PASSWD}') WHERE user='root';"
 
53
                else
 
54
                        PASSWD=""
 
55
                fi
 
56
 
 
57
                SQL=`mktemp`
 
58
                if [ -f "${SQL}" ];
 
59
                then
 
60
                        chmod 700 ${SQL}
 
61
                        cat << EOF > ${SQL}
 
62
USE mysql;
 
63
${PASSWD}
 
64
DELETE FROM user WHERE user='';
 
65
FLUSH PRIVILEGES;
 
66
EOF
 
67
                        mysqld --basedir=/usr --bootstrap --user=mysql --skip-grant-tables < $SQL
 
68
                        PASSWD=""
 
69
                        rm -f ${SQL}
 
70
                fi
 
71
 
 
72
                set +e
 
73
 
 
74
        fi
 
75
 
 
76
        ;;
 
77
 
 
78
        abort-upgrade|abort-remove|abort-configure)
 
79
 
 
80
        ;;
 
81
 
 
82
        *)
 
83
        exit 1
 
84
        ;;
 
85
esac
 
86
 
 
87
db_stop
 
88
 
 
89
take_upstart_job_backup
 
90
 
 
91
#DEBHELPER#
 
92
 
 
93
exit 0