Permalink
Browse files

Switch to new /etc/mysql/my.cnf management scheme

Make /etc/mysql/my.cnf a symlink, managed by update-alternatives. Ship
/etc/mysql/my.cnf.fallback instead, and make it a low priority
alternative. If the user had a customised /etc/mysql/my.cnf, rename it
to /etc/mysql/my.cnf.migration, make it a higher priority alternative,
and leave a comment explaining how to manage it.

Finally, supply /usr/share/mysql-common/configure-symlinks as a
wrapper for server packages to keep mysql-common informed about what
variant configurations exist. The wrapper will then call
update-alternatives on /etc/mysql/my.cnf accordingly.
  • Loading branch information...
1 parent 27ec4e8 commit 61e2b53ddede9a951f9910a027e68edd2a74903a Robie Basak committed Dec 11, 2014
@@ -0,0 +1,15 @@
+#!/bin/sh
+set -e
+
+case "$1" in
+ install)
+ variant="$2"
+ my_cnf_path="$3"
+ update-alternatives --install /etc/mysql/my.cnf my.cnf "$my_cnf_path" 200
+ ;;
+ remove)
+ variant="$2"
+ my_cnf_path="$3"
+ update-alternatives --remove my.cnf "$my_cnf_path"
+ ;;
+esac
View
@@ -1,127 +0,0 @@
-#
-# The MySQL database server configuration file.
-#
-# You can copy this to one of:
-# - "/etc/mysql/my.cnf" to set global options,
-# - "~/.my.cnf" to set user-specific options.
-#
-# One can use all long options that the program supports.
-# Run program with --help to get a list of available options and with
-# --print-defaults to see which it would actually understand and use.
-#
-# For explanations see
-# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
-
-# This will be passed to all mysql clients
-# It has been reported that passwords should be enclosed with ticks/quotes
-# escpecially if they contain "#" chars...
-# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
-[client]
-port = 3306
-socket = /var/run/mysqld/mysqld.sock
-
-# Here is entries for some specific programs
-# The following values assume you have at least 32M ram
-
-# This was formally known as [safe_mysqld]. Both versions are currently parsed.
-[mysqld_safe]
-socket = /var/run/mysqld/mysqld.sock
-nice = 0
-
-[mysqld]
-#
-# * Basic Settings
-#
-user = mysql
-pid-file = /var/run/mysqld/mysqld.pid
-socket = /var/run/mysqld/mysqld.sock
-port = 3306
-basedir = /usr
-datadir = /var/lib/mysql
-tmpdir = /tmp
-lc-messages-dir = /usr/share/mysql
-skip-external-locking
-#
-# Instead of skip-networking the default is now to listen only on
-# localhost which is more compatible and is not less secure.
-bind-address = 127.0.0.1
-#
-# * Fine Tuning
-#
-key_buffer = 16M
-max_allowed_packet = 16M
-thread_stack = 192K
-thread_cache_size = 8
-# This replaces the startup script and checks MyISAM tables if needed
-# the first time they are touched
-myisam-recover = BACKUP
-#max_connections = 100
-#table_cache = 64
-#thread_concurrency = 10
-#
-# * Query Cache Configuration
-#
-query_cache_limit = 1M
-query_cache_size = 16M
-#
-# * Logging and Replication
-#
-# Both location gets rotated by the cronjob.
-# Be aware that this log type is a performance killer.
-# As of 5.1 you can enable the log at runtime!
-#general_log_file = /var/log/mysql/mysql.log
-#general_log = 1
-#
-# Error log - should be very few entries.
-#
-log_error = /var/log/mysql/error.log
-#
-# Here you can see queries with especially long duration
-#log_slow_queries = /var/log/mysql/mysql-slow.log
-#long_query_time = 2
-#log-queries-not-using-indexes
-#
-# The following can be used as easy to replay backup logs or for replication.
-# note: if you are setting up a replication slave, see README.Debian about
-# other settings you may need to change.
-#server-id = 1
-#log_bin = /var/log/mysql/mysql-bin.log
-expire_logs_days = 10
-max_binlog_size = 100M
-#binlog_do_db = include_database_name
-#binlog_ignore_db = include_database_name
-#
-# * InnoDB
-#
-# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
-# Read the manual for more InnoDB related options. There are many!
-#
-# * Security Features
-#
-# Read the manual, too, if you want chroot!
-# chroot = /var/lib/mysql/
-#
-# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
-#
-# ssl-ca=/etc/mysql/cacert.pem
-# ssl-cert=/etc/mysql/server-cert.pem
-# ssl-key=/etc/mysql/server-key.pem
-
-
-
-[mysqldump]
-quick
-quote-names
-max_allowed_packet = 16M
-
-[mysql]
-#no-auto-rehash # faster start of mysql but no tab completition
-
-[isamchk]
-key_buffer = 16M
-
-#
-# * IMPORTANT: Additional settings that can override those from this file!
-# The files must end with '.cnf', otherwise they'll be ignored.
-#
-!includedir /etc/mysql/conf.d/
@@ -0,0 +1,35 @@
+#
+# The MySQL database server configuration file.
+#
+# You can copy this to one of:
+# - "/etc/mysql/my.cnf" to set global options,
+# - "~/.my.cnf" to set user-specific options.
+#
+# One can use all long options that the program supports.
+# Run program with --help to get a list of available options and with
+# --print-defaults to see which it would actually understand and use.
+#
+# For explanations see
+# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
+
+# This will be passed to all mysql clients
+# It has been reported that passwords should be enclosed with ticks/quotes
+# escpecially if they contain "#" chars...
+# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
+
+# Here is entries for some specific programs
+# The following values assume you have at least 32M ram
+
+[mysqldump]
+quick
+quote-names
+max_allowed_packet = 16M
+
+[mysql]
+#no-auto-rehash # faster start of mysql but no tab completition
+
+#
+# * IMPORTANT: Additional settings that can override those from this file!
+# The files must end with '.cnf', otherwise they'll be ignored.
+#
+!includedir /etc/mysql/conf.d/
@@ -1 +1,2 @@
-debian/additions/my.cnf etc/mysql/
+debian/additions/configure-symlinks usr/share/mysql-common/
+debian/additions/my.cnf.fallback etc/mysql/
@@ -1 +1,2 @@
rm_conffile /etc/mysql/conf.d/.keepme 5.6.22-1~ mysql-common
+rm_conffile /etc/mysql/my.cnf 5.6.22-1~ mysql-common
@@ -0,0 +1,40 @@
+#!/bin/sh
+set -e
+
+if [ "$1" = "configure" ]; 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
+
+#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" -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
@@ -4,6 +4,7 @@ set -e
if [ "$1" = "purge" ]; then
rmdir /etc/mysql 2>/dev/null || true
+ update-alternatives --remove-all my.cnf
fi
#DEBHELPER#

0 comments on commit 61e2b53

Please sign in to comment.