diff options
author | Sergei Golubchik <sergii@pisem.net> | 2012-11-03 12:28:51 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2012-11-03 12:28:51 +0100 |
commit | 40e94a3734b1daa254810c4be64e17b84dbbc2a2 (patch) | |
tree | 5e14dfc106276445caf85dc76c8034c8b0df11b4 /support-files/rpm/server-postin.sh | |
parent | 247e654fa7e04dd0c5181c2241470f56749d2a99 (diff) | |
parent | 4ffc9c3b01459a2904a7154a6c750d128864fc7b (diff) | |
download | mariadb-git-40e94a3734b1daa254810c4be64e17b84dbbc2a2.tar.gz |
merge with 5.5
Diffstat (limited to 'support-files/rpm/server-postin.sh')
-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 |