diff options
author | Sergei Golubchik <sergii@pisem.net> | 2012-10-05 14:24:38 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2012-10-05 14:24:38 +0200 |
commit | 3012a5d5ce37f3fee35d24750938f69586d38e13 (patch) | |
tree | 23d810eee7197716a39185ce996aae1e77c7a5da /support-files | |
parent | 9ced8f2a17fd315891190291a2e307e226ed9d6a (diff) | |
download | mariadb-git-3012a5d5ce37f3fee35d24750938f69586d38e13.tar.gz |
MDEV-3796 various RPM problems
cmake/cpack_rpm.cmake:
* mark all cnf files with %config(noreplace)
* add the forgotten postun script
sql/sys_vars.cc:
0 for a string variable means "no default. But datadir has the default value.
support-files/rpm/server-postin.sh:
* use mysqld --help to determine the correct datadir in the presence of my.cnf files
(better than my_print_defaults, because it considers the correct group set).
* Only create users, and chown/chmod if it's a fresh install, not an upgrade.
* only run mysql_install_db if datadir does not exist
Diffstat (limited to 'support-files')
-rw-r--r-- | support-files/rpm/server-postin.sh | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/support-files/rpm/server-postin.sh b/support-files/rpm/server-postin.sh index 88ff059ff22..156865b61ad 100644 --- a/support-files/rpm/server-postin.sh +++ b/support-files/rpm/server-postin.sh @@ -1,37 +1,46 @@ -mysql_datadir=%{mysqldatadir} - -# Create data directory -mkdir -p $mysql_datadir/{mysql,test} # Make MySQL start/shutdown automatically when the machine does it. if [ $1 = 1 ] ; then if [ -x /sbin/chkconfig ] ; then /sbin/chkconfig --add mysql 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 -d $mysql_datadir -s /bin/bash -c "MySQL server" -g %{mysqld_group} %{mysqld_user} 2> /dev/null || true -# The user may already exist, make sure it has the proper group nevertheless (BUG#12823) -usermod -g %{mysqld_group} %{mysqld_user} 2> /dev/null || true + mysql_dirs=(`%{_sbindir}/mysqld --verbose --help 2>/dev/null|sed -ne 's/^\(basedir\|datadir\)[[:space:]]*\(.*\)$/\2/p'`) + basedir="${mysql_dirs[0]}" + datadir="${mysql_dirs[1]}" + # datadir may be relative to a basedir! + if expr $datadir : / > /dev/null; then + mysql_datadir=$datadir + else + mysql_datadir=$basedir/$datadir + 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 -d $mysql_datadir -s /bin/bash -c "MySQL server" -g %{mysqld_group} %{mysqld_user} 2> /dev/null || true + # The user may already exist, make sure it has the proper group nevertheless (BUG#12823) + usermod -g %{mysqld_group} %{mysqld_user} 2> /dev/null || true -# Change permissions so that the user that will run the MySQL daemon -# owns all database files. -chown -R %{mysqld_user}:%{mysqld_group} $mysql_datadir + # Change permissions so that the user that will run the MySQL daemon + # owns all database files. + chown -R %{mysqld_user}:%{mysqld_group} $mysql_datadir -# Initiate databases -%{_bindir}/mysql_install_db --rpm --user=%{mysqld_user} + if [ ! -e $mysql_datadir ]; then + # Create data directory + mkdir -p $mysql_datadir/{mysql,test} -# Upgrade databases if needed would go here - but it cannot be automated yet + # Initiate databases + %{_bindir}/mysql_install_db --rpm --user=%{mysqld_user} + fi -# Change permissions again to fix any new files. -chown -R %{mysqld_user}:%{mysqld_group} $mysql_datadir + # Change permissions again to fix any new files. + chown -R %{mysqld_user}:%{mysqld_group} $mysql_datadir -# Fix permissions for the permission database so that only the user -# can read them. -chmod -R og-rw $mysql_datadir/mysql + # Fix permissions for the permission database so that only the user + # can read them. + chmod -R og-rw $mysql_datadir/mysql +fi # install SELinux files - but don't override existing ones SETARGETDIR=/etc/selinux/targeted/src/policy |