Debian Codegraph @

debian/mariadb-common.postinst

raw
1 #!/bin/sh
2
3 set -e
4
5 case "$1" in
6 configure)
7 # Set /etc/mysql/mariadb.cnf as main /etc/mysql/my.cnf alternative if it exists.
8 # As conffile, dpkg does not automatically re-add it if missing on upgrade,
9 # and admins might have intentionally removed it and chose a different my.cnf.
10 if [ ! -f /etc/mysql/mariadb.cnf ]
11 then
12 echo 'Notice: /etc/mysql/mariadb.cnf does not exist, leaving my.cnf untouched'
13 exit 0
14 fi
15
16 # New packaging paradigm for my.cnf handling among MySQL variants
17 # Used in Ubuntu since Dec-2014 and in Debian since Jul-2015
18 #
19 # If the new mysql-common package does not provide
20 # the update-alternatives facility, notify user about manual fall back
21 if [ -f /usr/share/mysql-common/configure-symlinks ]
22 then
23 /usr/share/mysql-common/configure-symlinks install mariadb "/etc/mysql/mariadb.cnf"
24 else
25 # As configure can be called many times, don't re-create the symlink
26 # if it is there already
27 if [ ! -L /etc/mysql/my.cnf ]
28 then
29 echo "Notice: configure-symlinks trigger could not be called."
30 echo "Please manually create symlinks by running: "
31 echo " mv -f /etc/mysql/my.cnf /etc/mysql/my.cnf.old"
32 echo " ln -sf mariadb.cnf /etc/mysql/my.cnf"
33 fi
34 fi
35
36 # Note that MySQL in Debian runs the configure-symlinks from the
37 # mysql-server-x.x.postinst and postrm files, while the MySQL.com (and
38 # Percona.com) packaging triggers update-alternatives directly form the
39 # mysql-common (and percona-x-common) package using priority 200.
40 #
41 # Thus, we need to ensure here that mariadb.cnf indeed became the primary
42 # alternative and override with priority 500 if needed.
43 if ! update-alternatives --query my.cnf | grep --quiet "Value: /etc/mysql/mariadb.cnf"
44 then
45 update-alternatives --install /etc/mysql/my.cnf my.cnf "/etc/mysql/mariadb.cnf" 500
46 fi
47 ;;
48 esac
49
50 #DEBHELPER#