File: mysql-common.postinst

package info (click to toggle)
mysql-defaults 1.0.2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 80 kB
  • ctags: 1
  • sloc: sh: 60; makefile: 6
file content (40 lines) | stat: -rw-r--r-- 1,987 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/sh
set -e

#DEBHELPER#

# This code needs to go after the debhelper snippets so that it runs after
# dpkg-maintscript-helper rm_conffile on /etc/mysql/my.cnf. As a one off, if
# my.cnf.dpkg-bak exists after this stage then we rename it to
# /etc/mysql/my.cnf.migrated, add an explanatory note to the top and add it is
# a high priority alternative so it gets used in favour of any other my.cnf
# shipped by variants. The /etc/mysql/my.cnf.migrated file will not be owned by
# any package (just like /etc/mysql/my.cnf.dpkg-bak would have been) but we
# rename it since it will be in active use, the user may not expect a .dpkg-bak
# file to be in use and we do not want to surprise the user.

if [ "$1" = "configure" ] && [ -f /etc/mysql/my.cnf.fallback ]; then
    # Low priority fallback for client use when no server is installed.
    update-alternatives --install /etc/mysql/my.cnf my.cnf /etc/mysql/my.cnf.fallback 100
fi

if [ "$1" = "configure" -a -f /etc/mysql/my.cnf.dpkg-bak ] && dpkg --compare-versions "$2" le "5.6.19-1~exp1ubuntu2~"; then
    echo "Moving /etc/mysql/my.cnf.dpkg-bak to /etc/mysql/my.cnf.migrated"
    cat - /etc/mysql/my.cnf.dpkg-bak <<EOT > /etc/mysql/my.cnf.migrated
# This file has been automatically moved from your previous
# /etc/mysql/my.cnf, with just this comment added at the top, to maintain MySQL
# operation using your previously customised configuration.

# To switch to the new packaging configuration for automated management of
# /etc/mysql/my.cnf across multiple variants:
#
# 1. Move your customisations from this file to /etc/mysql/conf.d/ and
#    to /etc/mysql/<variant>.conf.d/ as appropriate.
# 2. Run "update-alternatives --remove my.cnf /etc/mysql/my.cnf.migrated"
# 3. Remove the file /etc/mysql/my.cnf.migrated

EOT
    rm /etc/mysql/my.cnf.dpkg-bak
    echo "Using your previous configuration through /etc/mysql/my.cnf.migrated"
    update-alternatives --install /etc/mysql/my.cnf my.cnf /etc/mysql/my.cnf.migrated 300
fi