Switch to mariadb on openSUSE

The mysql-community-server is a compat provide, openSUSE uses
mariadb for quite some time. Make it futureproof in case
the compat provide goes away in the future. Cleanup
mysql service name to MYSQL_SERVICE_NAME and consistently
use it.

Change-Id: I2df7b8d8b798dfa7ceade90e0c127e0609524a8b
This commit is contained in:
Dirk Mueller 2017-09-23 14:45:42 +02:00
parent 2c9343e5db
commit 1d968d7a54
1 changed files with 11 additions and 17 deletions

View File

@ -15,10 +15,9 @@ MYSQL_DRIVER=${MYSQL_DRIVER:-PyMySQL}
register_database mysql register_database mysql
# Linux distros, thank you for being incredibly consistent MYSQL_SERVICE_NAME=mysql
MYSQL=mysql
if is_fedora && ! is_oraclelinux; then if is_fedora && ! is_oraclelinux; then
MYSQL=mariadb MYSQL_SERVICE_NAME=mariadb
fi fi
# Functions # Functions
@ -34,17 +33,17 @@ function get_database_type_mysql {
# Get rid of everything enough to cleanly change database backends # Get rid of everything enough to cleanly change database backends
function cleanup_database_mysql { function cleanup_database_mysql {
stop_service $MYSQL stop_service $MYSQL_SERVICE_NAME
if is_ubuntu; then if is_ubuntu; then
# Get ruthless with mysql # Get ruthless with mysql
apt_get purge -y mysql* mariadb* apt_get purge -y mysql* mariadb*
sudo rm -rf /var/lib/mysql sudo rm -rf /var/lib/mysql
sudo rm -rf /etc/mysql sudo rm -rf /etc/mysql
return return
elif is_suse || is_oraclelinux; then elif is_oraclelinux; then
uninstall_package mysql-community-server uninstall_package mysql-community-server
sudo rm -rf /var/lib/mysql sudo rm -rf /var/lib/mysql
elif is_fedora; then elif is_suse || is_fedora; then
uninstall_package mariadb-server uninstall_package mariadb-server
sudo rm -rf /var/lib/mysql sudo rm -rf /var/lib/mysql
else else
@ -64,12 +63,9 @@ function configure_database_mysql {
if is_ubuntu; then if is_ubuntu; then
my_conf=/etc/mysql/my.cnf my_conf=/etc/mysql/my.cnf
mysql=mysql
elif is_suse || is_oraclelinux; then elif is_suse || is_oraclelinux; then
my_conf=/etc/my.cnf my_conf=/etc/my.cnf
mysql=mysql
elif is_fedora; then elif is_fedora; then
mysql=mariadb
my_conf=/etc/my.cnf my_conf=/etc/my.cnf
local cracklib_conf=/etc/my.cnf.d/cracklib_password_check.cnf local cracklib_conf=/etc/my.cnf.d/cracklib_password_check.cnf
if [ -f "$cracklib_conf" ]; then if [ -f "$cracklib_conf" ]; then
@ -82,7 +78,7 @@ function configure_database_mysql {
# Start mysql-server # Start mysql-server
if is_fedora || is_suse; then if is_fedora || is_suse; then
# service is not started by default # service is not started by default
start_service $mysql start_service $MYSQL_SERVICE_NAME
fi fi
# Set the root password - only works the first time. For Ubuntu, we already # Set the root password - only works the first time. For Ubuntu, we already
@ -124,7 +120,7 @@ function configure_database_mysql {
iniset -sudo $my_conf mysqld log-queries-not-using-indexes 1 iniset -sudo $my_conf mysqld log-queries-not-using-indexes 1
fi fi
restart_service $mysql restart_service $MYSQL_SERVICE_NAME
} }
function install_database_mysql { function install_database_mysql {
@ -151,13 +147,11 @@ EOF
chmod 0600 $HOME/.my.cnf chmod 0600 $HOME/.my.cnf
fi fi
# Install mysql-server # Install mysql-server
if is_suse || is_oraclelinux; then if is_oraclelinux; then
if ! is_package_installed mariadb; then install_package mysql-community-server
install_package mysql-community-server elif is_fedora || is_suse; then
fi
elif is_fedora; then
install_package mariadb-server install_package mariadb-server
sudo systemctl enable mariadb sudo systemctl enable $MYSQL_SERVICE_NAME
elif is_ubuntu; then elif is_ubuntu; then
install_package mysql-server install_package mysql-server
else else