#!/bin/bash # Install controller base requiered packages set -eux # Templates write the configs into /mnt/state. However, MySQL makes it very # difficult not to use this as the directory for configs. rm -rf /etc/mysql ln -s /mnt/state/etc/mysql /etc/mysql if [ -e /etc/apparmor.d/usr.sbin.mysqld ] ; then sed -i -e 's,/var/lib/mysql/,/mnt/state/var/lib/mysql/,g' /etc/apparmor.d/usr.sbin.mysqld sed -i -e 's,/var/log/mysql/,/mnt/state/var/log/mysql/,g' /etc/apparmor.d/usr.sbin.mysqld sed -i -e 's,/etc/mysql/,/mnt/state/etc/mysql/,g' /etc/apparmor.d/usr.sbin.mysqld fi if [ -e /etc/init/mysql.conf ]; then sed -i -e 's,/var/lib/mysql/,/mnt/state/var/lib/mysql/,g' /etc/init/mysql.conf fi # Fedora/RHEL install /etc/my.cnf but we do not want any unmanaged configs # mariadb elements install using packages, so we don't want to just delete this # file, so symlink it to the config we actually use. ln -f -s /etc/mysql/my.cnf /etc/my.cnf # On openSUSE /var/lib/mysql is not part of the mariadb packages. [ -d /var/lib/mysql ] || install -d -o mysql -g root -m 0700 /var/lib/mysql register-state-path /var/lib/mysql # We need to setup the directory with appropriate permissions and then # the first time we boot a particular state partition we rsync this in. [ -d /var/log/mysql ] || install -d -o root -g mysql -m 0775 /var/log/mysql register-state-path /var/log/mysql # galera lib path is set in mysql config file, creating symlink # /usr/local/mysql/lib/libgalera_smm.so allows us to use same path # for mysql and mariadb and for i386/amd64 [ -e /usr/local/mysql/lib ] || install -m 0755 -o root -g root -d /usr/local/mysql/lib if [ -e /usr/lib64/galera/libgalera_smm.so ];then ln -sf /usr/lib64/galera/libgalera_smm.so /usr/local/mysql/lib/libgalera_smm.so elif [ -e /usr/lib/galera/libgalera_smm.so ];then ln -sf /usr/lib/galera/libgalera_smm.so /usr/local/mysql/lib/libgalera_smm.so fi