2015-09-28 15:08:09 +04:00
|
|
|
if [ -f /usr/lib/systemd/system/mariadb.service -a -x /usr/bin/systemctl ]; then
|
2015-09-17 22:16:19 +10:00
|
|
|
systemd_conf=/etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf
|
2015-09-28 15:08:09 +04:00
|
|
|
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 || :
|
2015-09-17 22:16:19 +10:00
|
|
|
fi
|
2015-09-28 15:08:09 +04:00
|
|
|
fi
|
2015-09-17 22:16:19 +10:00
|
|
|
|
2015-09-28 15:08:09 +04:00
|
|
|
# Make MySQL start/shutdown automatically when the machine does it.
|
|
|
|
if [ $1 = 1 ] ; then
|
2015-01-14 18:26:29 -05:00
|
|
|
if [ -x /usr/bin/systemctl ] ; then
|
2019-10-30 09:50:52 +01:00
|
|
|
/usr/bin/systemctl daemon-reload >/dev/null 2>&1 || :
|
|
|
|
/usr/bin/systemctl preset mariadb.service >/dev/null 2>&1 || :
|
2019-03-22 01:55:35 +01:00
|
|
|
elif [ -x /sbin/chkconfig ] ; then
|
2012-05-25 21:08:26 +02:00
|
|
|
/sbin/chkconfig --add mysql
|
|
|
|
fi
|
2012-05-22 11:04:32 +02:00
|
|
|
|
2013-03-06 09:32:13 +01:00
|
|
|
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}
|
2012-10-05 14:24:38 +02:00
|
|
|
else
|
2013-03-06 09:32:13 +01:00
|
|
|
# datadir may be relative to a basedir!
|
|
|
|
if ! expr $datadir : / > /dev/null; then
|
|
|
|
datadir=$basedir/$datadir
|
|
|
|
fi
|
2012-10-05 14:24:38 +02:00
|
|
|
fi
|
|
|
|
|
2017-01-23 08:34:59 +11:00
|
|
|
# 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
|
|
|
|
|
2012-10-05 14:24:38 +02:00
|
|
|
# Change permissions so that the user that will run the MySQL daemon
|
|
|
|
# owns all database files.
|
2019-07-05 08:37:44 +02:00
|
|
|
chown -R -f %{mysqld_user}:%{mysqld_group} $datadir
|
2012-05-22 11:04:32 +02:00
|
|
|
|
2013-11-11 09:31:05 +01:00
|
|
|
if [ ! -e $datadir/mysql ]; then
|
2019-05-06 12:12:10 +02:00
|
|
|
# Create data directory
|
|
|
|
mkdir -p $datadir
|
|
|
|
|
2012-10-05 14:24:38 +02:00
|
|
|
# Initiate databases
|
2022-12-14 19:35:19 +11:00
|
|
|
%{_bindir}/mariadb-install-db --rpm --user=%{mysqld_user}
|
2012-10-05 14:24:38 +02:00
|
|
|
fi
|
2012-05-22 11:04:32 +02:00
|
|
|
|
2012-10-05 14:24:38 +02:00
|
|
|
# Change permissions again to fix any new files.
|
2013-03-06 09:32:13 +01:00
|
|
|
chown -R %{mysqld_user}:%{mysqld_group} $datadir
|
2012-05-22 11:04:32 +02:00
|
|
|
|
2012-10-05 14:24:38 +02:00
|
|
|
# Fix permissions for the permission database so that only the user
|
|
|
|
# can read them.
|
2013-03-06 09:32:13 +01:00
|
|
|
chmod -R og-rw $datadir/mysql
|
2012-10-05 14:24:38 +02:00
|
|
|
fi
|
2012-05-22 11:04:32 +02:00
|
|
|
|
|
|
|
# install SELinux files - but don't override existing ones
|
|
|
|
SETARGETDIR=/etc/selinux/targeted/src/policy
|
|
|
|
SEDOMPROG=$SETARGETDIR/domains/program
|
|
|
|
SECONPROG=$SETARGETDIR/file_contexts/program
|
2017-02-23 10:34:51 +01:00
|
|
|
|
|
|
|
if [ -x /usr/sbin/semodule ] ; then
|
2022-12-12 14:20:08 +11:00
|
|
|
/usr/sbin/semodule -i /usr/share/mariadb/policy/selinux/mariadb.pp
|
2012-05-22 11:04:32 +02:00
|
|
|
fi
|
|
|
|
|
2024-06-14 17:23:55 +02:00
|
|
|
if [ -x /sbin/restorecon -a -d /var/lib/mysql ] ; then
|
2021-03-23 12:37:55 +07:00
|
|
|
/sbin/restorecon -R /var/lib/mysql
|
2012-05-22 11:04:32 +02:00
|
|
|
fi
|
|
|
|
|