diff options
Diffstat (limited to 'support-files/rpm')
-rw-r--r-- | support-files/rpm/client.cnf | 13 | ||||
-rw-r--r-- | support-files/rpm/enable_encryption.preset | 20 | ||||
-rw-r--r-- | support-files/rpm/my.cnf | 11 | ||||
-rw-r--r-- | support-files/rpm/mysql-clients.cnf | 23 | ||||
-rw-r--r-- | support-files/rpm/plugin-postin.sh | 3 | ||||
-rw-r--r-- | support-files/rpm/server-postin.sh | 77 | ||||
-rw-r--r-- | support-files/rpm/server-posttrans.sh | 15 | ||||
-rw-r--r-- | support-files/rpm/server-postun.sh | 12 | ||||
-rw-r--r-- | support-files/rpm/server-prein.sh | 72 | ||||
-rw-r--r-- | support-files/rpm/server-preun.sh | 18 | ||||
-rw-r--r-- | support-files/rpm/server.cnf | 46 | ||||
-rw-r--r-- | support-files/rpm/shared-post.sh | 1 |
12 files changed, 311 insertions, 0 deletions
diff --git a/support-files/rpm/client.cnf b/support-files/rpm/client.cnf new file mode 100644 index 00000000..9028505a --- /dev/null +++ b/support-files/rpm/client.cnf @@ -0,0 +1,13 @@ +# +# These two groups are read by the client library +# Use it for options that affect all clients, but not the server +# + + +[client] + +# This group is not read by mysql client library, +# If you use the same .cnf file for MySQL and MariaDB, +# use it for MariaDB-only client options +[client-mariadb] + diff --git a/support-files/rpm/enable_encryption.preset b/support-files/rpm/enable_encryption.preset new file mode 100644 index 00000000..722db7e5 --- /dev/null +++ b/support-files/rpm/enable_encryption.preset @@ -0,0 +1,20 @@ +# +# !include this file into your my.cnf (or any of *.cnf files in /etc/my.cnf.d) +# and it will enable data at rest encryption. This is a simple way to +# ensure that everything that can be encrypted will be and your +# data will not leak unencrypted. +# +# DO NOT EDIT THIS FILE! On MariaDB upgrades it might be replaced with a +# newer version and your edits will be lost. Instead, add your edits +# to the .cnf file after the !include directive. +# +# NOTE that you also need to install an encryption plugin for the encryption +# to work. See https://mariadb.com/kb/en/mariadb/data-at-rest-encryption/#encryption-key-management +# +[mariadb] +aria-encrypt-tables +encrypt-binlog +encrypt-tmp-disk-tables +encrypt-tmp-files +loose-innodb-encrypt-log +loose-innodb-encrypt-tables diff --git a/support-files/rpm/my.cnf b/support-files/rpm/my.cnf new file mode 100644 index 00000000..5cda317d --- /dev/null +++ b/support-files/rpm/my.cnf @@ -0,0 +1,11 @@ +# +# This group is read both by the client and the server +# use it for options that affect everything +# +[client-server] + +# +# include *.cnf from the config directory +# +!includedir /etc/my.cnf.d + diff --git a/support-files/rpm/mysql-clients.cnf b/support-files/rpm/mysql-clients.cnf new file mode 100644 index 00000000..3df9b7b9 --- /dev/null +++ b/support-files/rpm/mysql-clients.cnf @@ -0,0 +1,23 @@ +# +# These groups are read by MariaDB command-line tools +# Use it for options that affect only one utility +# + +[mysql] + +[mysql_upgrade] + +[mysqladmin] + +[mysqlbinlog] + +[mysqlcheck] + +[mysqldump] + +[mysqlimport] + +[mysqlshow] + +[mysqlslap] + diff --git a/support-files/rpm/plugin-postin.sh b/support-files/rpm/plugin-postin.sh new file mode 100644 index 00000000..1844de1b --- /dev/null +++ b/support-files/rpm/plugin-postin.sh @@ -0,0 +1,3 @@ +# request the server restart +mkdir -p %{restart_flag_dir} +echo > %{restart_flag} diff --git a/support-files/rpm/server-postin.sh b/support-files/rpm/server-postin.sh new file mode 100644 index 00000000..525af219 --- /dev/null +++ b/support-files/rpm/server-postin.sh @@ -0,0 +1,77 @@ +if [ -f /usr/lib/systemd/system/mariadb.service -a -x /usr/bin/systemctl ]; then + systemd_conf=/etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf + if [ -x %{_bindir}/mariadb-service-convert -a ! -f "${systemd_conf}" ]; then + # Either fresh install or upgrade non-systemd -> systemd + mkdir -p /etc/systemd/system/mariadb.service.d + %{_bindir}/mariadb-service-convert > "${systemd_conf}" + # Make sure old possibly non-systemd instance is down + if [ $1 = 2 ]; then + SYSTEMCTL_SKIP_REDIRECT=1 %{_sysconfdir}/init.d/mysql stop >/dev/null 2>&1 || : + systemctl start mariadb >/dev/null 2>&1 || : + fi + systemctl enable mariadb.service >/dev/null 2>&1 || : + fi +fi + +# Make MySQL start/shutdown automatically when the machine does it. +if [ $1 = 1 ] ; then + if [ -x /usr/bin/systemctl ] ; then + /usr/bin/systemctl daemon-reload >/dev/null 2>&1 || : + /usr/bin/systemctl preset mariadb.service >/dev/null 2>&1 || : + elif [ -x /sbin/chkconfig ] ; then + /sbin/chkconfig --add mysql + fi + + basedir=`%{_bindir}/my_print_defaults --mysqld|sed -ne 's/^--basedir=//p'|tail -1` + if [ -z "$basedir" ] ; then + basedir=%{mysqlbasedir} + fi + + datadir=`%{_bindir}/my_print_defaults --mysqld|sed -ne 's/^--datadir=//p'|tail -1` + if [ -z "$datadir" ] ; then + datadir=%{mysqldatadir} + else + # datadir may be relative to a basedir! + if ! expr $datadir : / > /dev/null; then + datadir=$basedir/$datadir + fi + fi + + # Temporary Workaround for MDEV-11386 - will be corrected in Advance Toolchain 10.0-3 and 8.0-8 + for ldconfig in /opt/at*/sbin/ldconfig; do + test -x $ldconfig && $ldconfig + done + + # Change permissions so that the user that will run the MySQL daemon + # owns all database files. + chown -R -f %{mysqld_user}:%{mysqld_group} $datadir + + if [ ! -e $datadir/mysql ]; then + # Create data directory + mkdir -p $datadir + + # Initiate databases + %{_bindir}/mariadb-install-db --rpm --user=%{mysqld_user} + fi + + # Change permissions again to fix any new files. + chown -R %{mysqld_user}:%{mysqld_group} $datadir + + # Fix permissions for the permission database so that only the user + # can read them. + chmod -R og-rw $datadir/mysql +fi + +# install SELinux files - but don't override existing ones +SETARGETDIR=/etc/selinux/targeted/src/policy +SEDOMPROG=$SETARGETDIR/domains/program +SECONPROG=$SETARGETDIR/file_contexts/program + +if [ -x /usr/sbin/semodule ] ; then + /usr/sbin/semodule -i /usr/share/mysql/policy/selinux/mariadb.pp +fi + +if [ -x /sbin/restorecon ] ; then + /sbin/restorecon -R /var/lib/mysql +fi + diff --git a/support-files/rpm/server-posttrans.sh b/support-files/rpm/server-posttrans.sh new file mode 100644 index 00000000..d91ff65e --- /dev/null +++ b/support-files/rpm/server-posttrans.sh @@ -0,0 +1,15 @@ +if [ -r %{restart_flag} ] ; then + rm %{restart_flag} + # only restart the server if it was already running + if [ -x /usr/bin/systemctl ] ; then + /usr/bin/systemctl daemon-reload > /dev/null 2>&1 + if /usr/bin/systemctl is-active mysql; then + /usr/bin/systemctl restart mysql > /dev/null 2>&1 + else + /usr/bin/systemctl try-restart mariadb.service > /dev/null 2>&1 + fi + # not a systemd-enabled environment, use SysV startup script + elif %{_sysconfdir}/init.d/mysql status > /dev/null 2>&1; then + %{_sysconfdir}/init.d/mysql restart > /dev/null 2>&1 + fi +fi diff --git a/support-files/rpm/server-postun.sh b/support-files/rpm/server-postun.sh new file mode 100644 index 00000000..27e1125b --- /dev/null +++ b/support-files/rpm/server-postun.sh @@ -0,0 +1,12 @@ +if [ $1 -ge 1 ]; then + # request the server restart + mkdir -p %{restart_flag_dir} + echo > %{restart_flag} +fi + +if [ $1 = 0 ] ; then + if [ -x /usr/bin/systemctl ] ; then + /usr/bin/systemctl daemon-reload > /dev/null 2>&1 + fi +fi + diff --git a/support-files/rpm/server-prein.sh b/support-files/rpm/server-prein.sh new file mode 100644 index 00000000..200d8bf1 --- /dev/null +++ b/support-files/rpm/server-prein.sh @@ -0,0 +1,72 @@ +# Check if we can safely upgrade. An upgrade is only safe if it's from one +# of our RPMs in the same version family. + +installed=`rpm -q --whatprovides mysql-server 2> /dev/null` +if [ $? -eq 0 -a -n "$installed" ]; then + installed=`echo "$installed"|sed -n 1p` + vendor=`rpm -q --queryformat='%''{VENDOR}' "$installed" 2>&1 | sed 's/Monty Program AB/MariaDB Foundation/'` + version=`rpm -q --queryformat='%''{VERSION}' "$installed" 2>&1` + myvendor='%{mysql_vendor}' + myversion='%{mysqlversion}' + + old_family=`echo $version | sed -n -e 's,^\([1-9][0-9]*\.[0-9][0-9]*\)\..*$,\1,p'` + new_family=`echo $myversion | sed -n -e 's,^\([1-9][0-9]*\.[0-9][0-9]*\)\..*$,\1,p'` + + [ -z "$vendor" ] && vendor='<unknown>' + [ -z "$old_family" ] && old_family="<unrecognized version $version>" + [ -z "$new_family" ] && new_family="<bad package specification: version $myversion>" + + error_text= + if [ "$vendor" != "$myvendor" ]; then + error_text="$error_text +The current MariaDB server package is provided by a different +vendor ($vendor) than $myvendor. Some files may be installed +to different locations, including log files and the service +startup script in %{_sysconfdir}/init.d/. +" + fi + + if [ "$old_family" != "$new_family" ]; then + error_text="$error_text +Upgrading directly from MySQL $old_family to MariaDB $new_family may not +be safe in all cases. A manual dump and restore using mysqldump is +recommended. It is important to review the MariaDB manual's Upgrading +section for version-specific incompatibilities. +" + fi + + if [ -n "$error_text" ]; then + cat <<HERE >&2 + +****************************************************************** +A MySQL or MariaDB server package ($installed) is installed. +$error_text +A manual upgrade is required. + +- Ensure that you have a complete, working backup of your data and my.cnf + files +- Shut down the MySQL server cleanly +- Remove the existing MySQL packages. Usually this command will + list the packages you should remove: + rpm -qa | grep -i '^mysql-' + + You may choose to use 'rpm --nodeps -ev <package-name>' to remove + the package which contains the mysqlclient shared library. The + library will be reinstalled by the MariaDB-shared package. +- Install the new MariaDB packages supplied by $myvendor +- Ensure that the MariaDB server is started +- Run the 'mysql_upgrade' program + +This is a brief description of the upgrade process. Important details +can be found in the MariaDB manual, in the Upgrading section. +****************************************************************** +HERE + exit 1 + fi +fi + +# Create a MySQL user and group. Do not report any problems if it already exists. +groupadd -r %{mysqld_group} 2> /dev/null || true +useradd -M -r --home %{mysqldatadir} --shell /sbin/nologin --comment "MySQL server" --gid %{mysqld_group} %{mysqld_user} 2> /dev/null || true +# The user may already exist, make sure it has the proper group nevertheless (BUG#12823) +usermod --gid %{mysqld_group} %{mysqld_user} 2> /dev/null || true diff --git a/support-files/rpm/server-preun.sh b/support-files/rpm/server-preun.sh new file mode 100644 index 00000000..34a35cbc --- /dev/null +++ b/support-files/rpm/server-preun.sh @@ -0,0 +1,18 @@ +if [ $1 = 0 ] ; then + # Stop MySQL before uninstalling it + # Don't start it automatically anymore + if [ -x /usr/bin/systemctl ] ; then + /usr/bin/systemctl stop mariadb.service > /dev/null 2>&1 + /usr/bin/systemctl disable mariadb.service > /dev/null 2>&1 + fi + if [ -x %{_sysconfdir}/init.d/mysql ] ; then + %{_sysconfdir}/init.d/mysql stop > /dev/null + if [ -x /sbin/chkconfig ] ; then + /sbin/chkconfig --del mysql > /dev/null 2>&1 || : + fi + fi +fi + +# We do not remove the mysql user since it may still own a lot of +# database files. + diff --git a/support-files/rpm/server.cnf b/support-files/rpm/server.cnf new file mode 100644 index 00000000..1db6cd18 --- /dev/null +++ b/support-files/rpm/server.cnf @@ -0,0 +1,46 @@ +# +# These groups are read by MariaDB server. +# Use it for options that only the server (but not clients) should see +# +# See the examples of server my.cnf files in /usr/share/mysql/ +# + +# this is read by the standalone daemon and embedded servers +[server] + +# this is only for the mysqld standalone daemon +[mysqld] + +# +# * Galera-related settings +# +[galera] +# Mandatory settings +#wsrep_on=ON +#wsrep_provider= +#wsrep_cluster_address= +#binlog_format=row +#default_storage_engine=InnoDB +#innodb_autoinc_lock_mode=2 +# +# Allow server to accept connections on all interfaces. +# +#bind-address=0.0.0.0 +# +# Optional setting +#wsrep_slave_threads=1 +#innodb_flush_log_at_trx_commit=0 + +# this is only for embedded server +[embedded] + +# This group is only read by MariaDB servers, not by MySQL. +# If you use the same .cnf file for MySQL and MariaDB, +# you can put MariaDB-only options here +[mariadb] + +# This group is only read by MariaDB-10.11 servers. +# If you use the same .cnf file for MariaDB of different versions, +# use this group for options that older servers don't understand +[mariadb-10.11] + diff --git a/support-files/rpm/shared-post.sh b/support-files/rpm/shared-post.sh new file mode 100644 index 00000000..8b0c8224 --- /dev/null +++ b/support-files/rpm/shared-post.sh @@ -0,0 +1 @@ +/sbin/ldconfig |