2015-06-25 15:57:47 +02:00
|
|
|
#!/bin/bash
|
|
|
|
die() {
|
|
|
|
echo "$1"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Read options from config file
|
|
|
|
read_config() {
|
|
|
|
# Initial settings
|
|
|
|
MYSQLVER="$(echo @MYSQLVER@ | sed 's|\.[0-9]\+$||')"
|
|
|
|
mysql_daemon_user=mysql
|
|
|
|
mysql_daemon_group=mysql
|
2020-02-04 15:05:21 +01:00
|
|
|
# status information directory (e.g. info about a necessity of upgrade, current version etc)
|
|
|
|
mariadb_status_dir="/var/lib/misc"
|
|
|
|
|
Accepting request 437454 from home:kstreitova:branches:server:database
- update to 10.1.18
* Release notes:
https://mariadb.com/kb/en/mariadb/mariadb-10118-release-notes/
https://mariadb.com/kb/en/mariadb/mariadb-10117-release-notes/
https://mariadb.com/kb/en/mariadb/mariadb-10116-release-notes/
https://mariadb.com/kb/en/mariadb/mariadb-10115-release-notes/
* Changelog:
https://mariadb.com/kb/en/mariadb/mariadb-10118-changelog/
https://mariadb.com/kb/en/mariadb/mariadb-10117-changelog/
https://mariadb.com/kb/en/mariadb/mariadb-10116-changelog/
https://mariadb.com/kb/en/mariadb/mariadb-10115-changelog/
* fixed CVE's:
CVE-2016-8283, CVE-2016-6663, CVE-2016-5629, CVE-2016-5626,
CVE-2016-5624, CVE-2016-5616, CVE-2016-3492, CVE-2016-6662,
CVE-2016-5440, CVE-2016-3615, CVE-2016-3521, CVE-2016-3477
* fix:
[bsc#1005582], [bsc#1001367], [bsc#1005569], [bsc#1005566],
[bsc#1005564], [bsc#1005562], [bsc#1005555], [bnc#998309],
[bsc#989926], [bsc#989922], [bsc#989919], [bsc#989913]
* refresh mariadb-10.1.4-group.patch
* refresh mariadb-10.1.12-fortify-and-O.patch
- requires devel packages for aio and lzo2
- remove mariadb-10.0.21-mysql-test_main_bootstrap.patch that is no
longer needed [bnc#984858]
- append "--ignore-db-dir=lost+found" to the mysqld options in
"mysql-systemd-helper" script if "lost+found" directory is found
in $datadir [bnc#986251]
- remove syslog.target from *.service files [bsc#983938]
- add BuildRequires: systemd-devel
- make some dependecies switchable
OBS-URL: https://build.opensuse.org/request/show/437454
OBS-URL: https://build.opensuse.org/package/show/server:database/mariadb?expand=0&rev=184
2016-10-27 10:56:24 +02:00
|
|
|
if [[ -z "$INSTANCE" ]]; then
|
2015-06-25 15:57:47 +02:00
|
|
|
datadir=/var/lib/mysql
|
2017-05-30 16:00:01 +02:00
|
|
|
socket="/run/mysql/mysql.sock"
|
2015-06-25 15:57:47 +02:00
|
|
|
else
|
|
|
|
datadir="/var/lib/mysql-$INSTANCE"
|
2017-05-30 16:00:01 +02:00
|
|
|
socket="/run/mysql/mysql.${INSTANCE}.sock"
|
2015-06-25 15:57:47 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Read options - important for multi setup
|
Accepting request 437454 from home:kstreitova:branches:server:database
- update to 10.1.18
* Release notes:
https://mariadb.com/kb/en/mariadb/mariadb-10118-release-notes/
https://mariadb.com/kb/en/mariadb/mariadb-10117-release-notes/
https://mariadb.com/kb/en/mariadb/mariadb-10116-release-notes/
https://mariadb.com/kb/en/mariadb/mariadb-10115-release-notes/
* Changelog:
https://mariadb.com/kb/en/mariadb/mariadb-10118-changelog/
https://mariadb.com/kb/en/mariadb/mariadb-10117-changelog/
https://mariadb.com/kb/en/mariadb/mariadb-10116-changelog/
https://mariadb.com/kb/en/mariadb/mariadb-10115-changelog/
* fixed CVE's:
CVE-2016-8283, CVE-2016-6663, CVE-2016-5629, CVE-2016-5626,
CVE-2016-5624, CVE-2016-5616, CVE-2016-3492, CVE-2016-6662,
CVE-2016-5440, CVE-2016-3615, CVE-2016-3521, CVE-2016-3477
* fix:
[bsc#1005582], [bsc#1001367], [bsc#1005569], [bsc#1005566],
[bsc#1005564], [bsc#1005562], [bsc#1005555], [bnc#998309],
[bsc#989926], [bsc#989922], [bsc#989919], [bsc#989913]
* refresh mariadb-10.1.4-group.patch
* refresh mariadb-10.1.12-fortify-and-O.patch
- requires devel packages for aio and lzo2
- remove mariadb-10.0.21-mysql-test_main_bootstrap.patch that is no
longer needed [bnc#984858]
- append "--ignore-db-dir=lost+found" to the mysqld options in
"mysql-systemd-helper" script if "lost+found" directory is found
in $datadir [bnc#986251]
- remove syslog.target from *.service files [bsc#983938]
- add BuildRequires: systemd-devel
- make some dependecies switchable
OBS-URL: https://build.opensuse.org/request/show/437454
OBS-URL: https://build.opensuse.org/package/show/server:database/mariadb?expand=0&rev=184
2016-10-27 10:56:24 +02:00
|
|
|
if [[ -n "$INSTANCE" ]]; then
|
2019-07-19 19:38:09 +02:00
|
|
|
opts="$(/usr/bin/my_print_defaults mysqld mysqld_multi "$INSTANCE" --defaults-extra-file=/etc/my${INSTANCE}.cnf)"
|
2015-06-25 15:57:47 +02:00
|
|
|
tmp_opts="$opts"
|
2016-02-03 12:44:34 +01:00
|
|
|
config="/etc/my${INSTANCE}.cnf"
|
2015-06-25 15:57:47 +02:00
|
|
|
else
|
2015-08-31 14:35:22 +02:00
|
|
|
opts="$(/usr/bin/my_print_defaults mysqld)"
|
2015-06-25 15:57:47 +02:00
|
|
|
tmp_opts="$opts"
|
2016-02-03 12:44:34 +01:00
|
|
|
config="/etc/my.cnf"
|
2015-06-25 15:57:47 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Update local variables according to the settings from config
|
|
|
|
for arg in $tmp_opts; do
|
|
|
|
case "$arg" in
|
|
|
|
--basedir=*) basedir="$(echo "$arg" | sed -e 's/^[^=]*=//')" ;;
|
|
|
|
--socket=*) socket="$(echo "$arg" | sed -e 's/^[^=]*=//')" ;;
|
|
|
|
--datadir=*) datadir="$(echo "$arg" | sed -e 's/^[^=]*=//')" ;;
|
|
|
|
--user=*) mysql_daemon_user="$(echo "$arg" | sed -e 's/^[^=]*=//')" ;;
|
|
|
|
esac
|
|
|
|
done
|
Accepting request 437454 from home:kstreitova:branches:server:database
- update to 10.1.18
* Release notes:
https://mariadb.com/kb/en/mariadb/mariadb-10118-release-notes/
https://mariadb.com/kb/en/mariadb/mariadb-10117-release-notes/
https://mariadb.com/kb/en/mariadb/mariadb-10116-release-notes/
https://mariadb.com/kb/en/mariadb/mariadb-10115-release-notes/
* Changelog:
https://mariadb.com/kb/en/mariadb/mariadb-10118-changelog/
https://mariadb.com/kb/en/mariadb/mariadb-10117-changelog/
https://mariadb.com/kb/en/mariadb/mariadb-10116-changelog/
https://mariadb.com/kb/en/mariadb/mariadb-10115-changelog/
* fixed CVE's:
CVE-2016-8283, CVE-2016-6663, CVE-2016-5629, CVE-2016-5626,
CVE-2016-5624, CVE-2016-5616, CVE-2016-3492, CVE-2016-6662,
CVE-2016-5440, CVE-2016-3615, CVE-2016-3521, CVE-2016-3477
* fix:
[bsc#1005582], [bsc#1001367], [bsc#1005569], [bsc#1005566],
[bsc#1005564], [bsc#1005562], [bsc#1005555], [bnc#998309],
[bsc#989926], [bsc#989922], [bsc#989919], [bsc#989913]
* refresh mariadb-10.1.4-group.patch
* refresh mariadb-10.1.12-fortify-and-O.patch
- requires devel packages for aio and lzo2
- remove mariadb-10.0.21-mysql-test_main_bootstrap.patch that is no
longer needed [bnc#984858]
- append "--ignore-db-dir=lost+found" to the mysqld options in
"mysql-systemd-helper" script if "lost+found" directory is found
in $datadir [bnc#986251]
- remove syslog.target from *.service files [bsc#983938]
- add BuildRequires: systemd-devel
- make some dependecies switchable
OBS-URL: https://build.opensuse.org/request/show/437454
OBS-URL: https://build.opensuse.org/package/show/server:database/mariadb?expand=0&rev=184
2016-10-27 10:56:24 +02:00
|
|
|
|
|
|
|
# work-around for lost+found directory in $datadir (bug #986251)
|
|
|
|
if [ -d "$datadir/lost+found" ]
|
|
|
|
then
|
|
|
|
ignore_db_dir="--ignore-db-dir=lost+found"
|
|
|
|
else
|
|
|
|
ignore_db_dir=""
|
|
|
|
fi
|
2015-06-25 15:57:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Create new empty database if needed
|
|
|
|
mysql_install() {
|
|
|
|
if [[ ! -d "$datadir/mysql" ]]; then
|
|
|
|
echo "Creating MySQL privilege database... "
|
2019-07-19 19:38:09 +02:00
|
|
|
mysql_install_db --rpm --user="$mysql_daemon_user" --datadir="$datadir" || \
|
|
|
|
die "Creation of MySQL database in $datadir failed"
|
2020-02-04 15:05:21 +01:00
|
|
|
echo -n "$MYSQLVER" > "$mariadb_status_dir"/mariadb_upgrade_info
|
2015-06-25 15:57:47 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Upgrade database if needed
|
|
|
|
mysql_upgrade() {
|
|
|
|
# Run mysql_upgrade on every package install/upgrade. Not always
|
|
|
|
# necessary, but doesn't do any harm.
|
2020-02-04 15:05:21 +01:00
|
|
|
if [[ -f "$mariadb_status_dir/.mariadb_run_upgrade" ]]; then
|
2015-06-25 15:57:47 +02:00
|
|
|
echo "Checking MySQL configuration for obsolete options..."
|
|
|
|
sed -i -e 's|^\([[:blank:]]*\)skip-locking|\1skip-external-locking|' \
|
|
|
|
-e 's|^\([[:blank:]]*skip-federated\)|#\1|' /etc/my.cnf
|
|
|
|
|
|
|
|
# instead of running mysqld --bootstrap, which wouldn't allow
|
|
|
|
# us to run mysql_upgrade, we start a full-featured server with
|
|
|
|
# --skip-grant-tables and restict access to it by unix
|
|
|
|
# permissions of the named socket
|
|
|
|
|
|
|
|
echo "Trying to run upgrade of MySQL databases..."
|
|
|
|
|
|
|
|
# Check whether upgrade process is not already running
|
2017-05-30 16:00:01 +02:00
|
|
|
protected="$(cat "/run/mysql/protecteddir.$INSTANCE" 2> /dev/null)"
|
2015-06-25 15:57:47 +02:00
|
|
|
if [[ -n "$protected" && -d "$protected" ]]; then
|
|
|
|
pid="$(cat "$protected/mysqld.pid" 2> /dev/null)"
|
|
|
|
if [[ "$pid" && -d "/proc/$pid" ]] &&
|
|
|
|
[[ $(readlink "/proc/$pid/exe" | grep -q "mysql") ]]; then
|
|
|
|
die "Another upgrade in already in progress!"
|
|
|
|
else
|
|
|
|
echo "Stale files from previous upgrade detected, cleaned them up"
|
|
|
|
rm -rf "$protected"
|
2017-05-30 16:00:01 +02:00
|
|
|
rm -f "/run/mysql/protecteddir.$INSTANCE"
|
2015-06-25 15:57:47 +02:00
|
|
|
fi
|
|
|
|
fi
|
2017-05-30 16:00:01 +02:00
|
|
|
protected="$(mktemp -d -p /var/tmp mysql-protected.XXXXXX | tee "/run/mysql/protecteddir.$INSTANCE")"
|
2015-06-25 15:57:47 +02:00
|
|
|
[ -n "$protected" ] || die "Can't create a tmp dir '$protected'"
|
|
|
|
|
|
|
|
# Create a secure tmp dir
|
|
|
|
chown --no-dereference "$mysql_daemon_user:$mysql_daemon_group" "$protected" || die "Failed to set group/user to '$protected'"
|
|
|
|
chmod 0700 "$protected" || die "Failed to set permissions to '$protected'"
|
|
|
|
|
|
|
|
# Run protected MySQL accessible only though socket in our directory
|
|
|
|
echo "Running protected MySQL... "
|
|
|
|
/usr/sbin/mysqld \
|
2016-02-03 12:44:34 +01:00
|
|
|
--defaults-file="$config" \
|
2015-08-31 14:35:22 +02:00
|
|
|
--user="$mysql_daemon_user" \
|
2015-06-25 15:57:47 +02:00
|
|
|
--skip-networking \
|
|
|
|
--skip-grant-tables \
|
Accepting request 437454 from home:kstreitova:branches:server:database
- update to 10.1.18
* Release notes:
https://mariadb.com/kb/en/mariadb/mariadb-10118-release-notes/
https://mariadb.com/kb/en/mariadb/mariadb-10117-release-notes/
https://mariadb.com/kb/en/mariadb/mariadb-10116-release-notes/
https://mariadb.com/kb/en/mariadb/mariadb-10115-release-notes/
* Changelog:
https://mariadb.com/kb/en/mariadb/mariadb-10118-changelog/
https://mariadb.com/kb/en/mariadb/mariadb-10117-changelog/
https://mariadb.com/kb/en/mariadb/mariadb-10116-changelog/
https://mariadb.com/kb/en/mariadb/mariadb-10115-changelog/
* fixed CVE's:
CVE-2016-8283, CVE-2016-6663, CVE-2016-5629, CVE-2016-5626,
CVE-2016-5624, CVE-2016-5616, CVE-2016-3492, CVE-2016-6662,
CVE-2016-5440, CVE-2016-3615, CVE-2016-3521, CVE-2016-3477
* fix:
[bsc#1005582], [bsc#1001367], [bsc#1005569], [bsc#1005566],
[bsc#1005564], [bsc#1005562], [bsc#1005555], [bnc#998309],
[bsc#989926], [bsc#989922], [bsc#989919], [bsc#989913]
* refresh mariadb-10.1.4-group.patch
* refresh mariadb-10.1.12-fortify-and-O.patch
- requires devel packages for aio and lzo2
- remove mariadb-10.0.21-mysql-test_main_bootstrap.patch that is no
longer needed [bnc#984858]
- append "--ignore-db-dir=lost+found" to the mysqld options in
"mysql-systemd-helper" script if "lost+found" directory is found
in $datadir [bnc#986251]
- remove syslog.target from *.service files [bsc#983938]
- add BuildRequires: systemd-devel
- make some dependecies switchable
OBS-URL: https://build.opensuse.org/request/show/437454
OBS-URL: https://build.opensuse.org/package/show/server:database/mariadb?expand=0&rev=184
2016-10-27 10:56:24 +02:00
|
|
|
$ignore_db_dir \
|
2015-06-25 15:57:47 +02:00
|
|
|
--log-error="$protected/log_upgrade_run" \
|
|
|
|
--socket="$protected/mysql.sock" \
|
|
|
|
--pid-file="$protected/mysqld.pid" &
|
|
|
|
|
|
|
|
mysql_wait "$protected/mysql.sock" || die "MySQL didn't start, can't continue"
|
|
|
|
|
|
|
|
# Run upgrade itself
|
|
|
|
echo "Running upgrade itself..."
|
|
|
|
echo "It will do some chek first and report all errors and tries to correct them"
|
|
|
|
echo
|
|
|
|
if /usr/bin/mysql_upgrade --no-defaults --force --socket="$protected/mysql.sock"; then
|
|
|
|
echo "Everything upgraded successfully"
|
|
|
|
up_ok=""
|
2020-02-04 15:05:21 +01:00
|
|
|
rm -f "$mariadb_status_dir/.mariadb_run_upgrade"
|
|
|
|
[[ $(grep -q "^$MYSQLVER" "$mariadb_status_dir/mariadb_upgrade_info" 2> /dev/null) ]] || \
|
|
|
|
echo -n "$MYSQLVER" > "$mariadb_status_dir/mariadb_upgrade_info"
|
2015-06-25 15:57:47 +02:00
|
|
|
else
|
|
|
|
echo "Upgrade failed"
|
|
|
|
up_ok="false"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Shut down MySQL
|
2019-08-08 16:14:01 +02:00
|
|
|
echo "Shutting down protected MySQL"
|
|
|
|
protected_pid=$(cat "$protected/mysqld.pid")
|
|
|
|
kill $protected_pid
|
2015-06-25 15:57:47 +02:00
|
|
|
for i in {1..30}; do
|
2019-08-08 16:14:01 +02:00
|
|
|
/usr/bin/mysqladmin --socket="$protected/mysql.sock" ping > /dev/null 2>&1
|
|
|
|
# Check both ping response and the pid in a process list as it can take some time till the process is terminated.
|
|
|
|
# Otherwise it can lead to "found left-over process" situation when regular mariadb is started.
|
|
|
|
if [[ $? -eq 1 ]] && ! ps -p $protected_pid > /dev/null 2>&1; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
sleep 1
|
2015-06-25 15:57:47 +02:00
|
|
|
done
|
2019-08-08 16:14:01 +02:00
|
|
|
/usr/bin/mysqladmin --socket="$protected/mysql.sock" ping > /dev/null 2>&1 && kill -9 $protected_pid
|
2015-06-25 15:57:47 +02:00
|
|
|
|
|
|
|
# Cleanup
|
|
|
|
echo "Final cleanup"
|
2016-06-14 18:15:45 +02:00
|
|
|
if [[ -z "$up_ok" ]]; then
|
2017-05-30 16:00:01 +02:00
|
|
|
rm -rf "$protected" "/run/mysql/protecteddir.$INSTANCE"
|
2016-06-14 18:15:45 +02:00
|
|
|
else
|
|
|
|
die "Something failed during upgrade, please check logs"
|
|
|
|
fi
|
2015-06-25 15:57:47 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
mysql_wait() {
|
|
|
|
[[ -z "$1" ]] || socket="$1"
|
|
|
|
echo "Waiting for MySQL to start"
|
|
|
|
for i in {1..60}; do
|
|
|
|
/usr/bin/mysqladmin --socket="$socket" ping > /dev/null 2>&1 && break
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
if /usr/bin/mysqladmin --socket="$socket" ping > /dev/null 2>&1; then
|
|
|
|
echo "MySQL is alive"
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
echo "MySQL is still dead"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
mysql_start() {
|
2016-02-03 12:44:34 +01:00
|
|
|
exec /usr/sbin/mysqld \
|
|
|
|
--defaults-file="$config" \
|
Accepting request 437454 from home:kstreitova:branches:server:database
- update to 10.1.18
* Release notes:
https://mariadb.com/kb/en/mariadb/mariadb-10118-release-notes/
https://mariadb.com/kb/en/mariadb/mariadb-10117-release-notes/
https://mariadb.com/kb/en/mariadb/mariadb-10116-release-notes/
https://mariadb.com/kb/en/mariadb/mariadb-10115-release-notes/
* Changelog:
https://mariadb.com/kb/en/mariadb/mariadb-10118-changelog/
https://mariadb.com/kb/en/mariadb/mariadb-10117-changelog/
https://mariadb.com/kb/en/mariadb/mariadb-10116-changelog/
https://mariadb.com/kb/en/mariadb/mariadb-10115-changelog/
* fixed CVE's:
CVE-2016-8283, CVE-2016-6663, CVE-2016-5629, CVE-2016-5626,
CVE-2016-5624, CVE-2016-5616, CVE-2016-3492, CVE-2016-6662,
CVE-2016-5440, CVE-2016-3615, CVE-2016-3521, CVE-2016-3477
* fix:
[bsc#1005582], [bsc#1001367], [bsc#1005569], [bsc#1005566],
[bsc#1005564], [bsc#1005562], [bsc#1005555], [bnc#998309],
[bsc#989926], [bsc#989922], [bsc#989919], [bsc#989913]
* refresh mariadb-10.1.4-group.patch
* refresh mariadb-10.1.12-fortify-and-O.patch
- requires devel packages for aio and lzo2
- remove mariadb-10.0.21-mysql-test_main_bootstrap.patch that is no
longer needed [bnc#984858]
- append "--ignore-db-dir=lost+found" to the mysqld options in
"mysql-systemd-helper" script if "lost+found" directory is found
in $datadir [bnc#986251]
- remove syslog.target from *.service files [bsc#983938]
- add BuildRequires: systemd-devel
- make some dependecies switchable
OBS-URL: https://build.opensuse.org/request/show/437454
OBS-URL: https://build.opensuse.org/package/show/server:database/mariadb?expand=0&rev=184
2016-10-27 10:56:24 +02:00
|
|
|
$ignore_db_dir \
|
2016-02-03 12:44:34 +01:00
|
|
|
--user="$mysql_daemon_user"
|
2015-06-25 15:57:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# We rely on output in english at some points
|
|
|
|
LC_ALL=C
|
|
|
|
|
|
|
|
INSTANCE="$2"
|
|
|
|
read_config
|
2020-02-04 15:05:21 +01:00
|
|
|
# Make sure that /run/mysql is created and has correct permissions (bsc#1038740)
|
|
|
|
systemd-tmpfiles --create /usr/lib/tmpfiles.d/mariadb.conf
|
2015-06-25 15:57:47 +02:00
|
|
|
case "$1" in
|
|
|
|
install)
|
|
|
|
mysql_install ;;
|
|
|
|
upgrade)
|
|
|
|
mysql_upgrade ;;
|
|
|
|
start)
|
|
|
|
mysql_start ;;
|
|
|
|
wait)
|
|
|
|
mysql_wait ;;
|
|
|
|
*)
|
|
|
|
echo "Supported commands are:"
|
|
|
|
echo " install - creates empty database if needed"
|
|
|
|
echo " upgrade - tries to migrate data to newer version if needed"
|
|
|
|
echo " start - tries to start instance"
|
|
|
|
echo " wait - waits till instance is pingable"
|
|
|
|
echo "All commands can take extra argument which is group from 'mysqld_multi' you want to work with"
|
|
|
|
;;
|
|
|
|
esac
|