summaryrefslogtreecommitdiffstats
path: root/mysqld-prepare-db-dir
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2012-09-30 20:23:54 +0200
committerRemi Collet <fedora@famillecollet.com>2012-09-30 20:23:54 +0200
commit8fb1a350b6487602b62de069911750421c01c6ef (patch)
tree937ec25fc757b8022f99067c411cc57333639687 /mysqld-prepare-db-dir
parent51fa9dd068780d91622704e3dbdafbaff0c03007 (diff)
MySQL: syncwith rawhide
Diffstat (limited to 'mysqld-prepare-db-dir')
-rw-r--r--mysqld-prepare-db-dir29
1 files changed, 25 insertions, 4 deletions
diff --git a/mysqld-prepare-db-dir b/mysqld-prepare-db-dir
index 78c0bd7..f73bc66 100644
--- a/mysqld-prepare-db-dir
+++ b/mysqld-prepare-db-dir
@@ -22,10 +22,31 @@ datadir="$result"
get_mysql_option mysqld_safe log-error "/var/log/mysqld.log"
errlogfile="$result"
+# Absorb configuration settings from the specified systemd service file,
+# or the default "mysqld" service if not specified
+SERVICE_NAME="$1"
+if [ x"$SERVICE_NAME" = x ]
+then
+ SERVICE_NAME=mysqld.service
+fi
+
+myuser=`systemctl show -p User "${SERVICE_NAME}" |
+ sed 's/^User=//'`
+if [ x"$myuser" = x ]
+then
+ myuser=mysql
+fi
+
+mygroup=`systemctl show -p Group "${SERVICE_NAME}" |
+ sed 's/^Group=//'`
+if [ x"$mygroup" = x ]
+then
+ mygroup=mysql
+fi
# Set up the errlogfile with appropriate permissions
touch "$errlogfile"
-chown mysql:mysql "$errlogfile"
+chown "$myuser:$mygroup" "$errlogfile"
chmod 0640 "$errlogfile"
[ -x /sbin/restorecon ] && /sbin/restorecon "$errlogfile"
@@ -37,13 +58,13 @@ if [ ! -d "$datadir/mysql" ] ; then
then
mkdir -p "$datadir" || exit 1
fi
- chown mysql:mysql "$datadir"
+ chown "$myuser:$mygroup" "$datadir"
chmod 0755 "$datadir"
[ -x /sbin/restorecon ] && /sbin/restorecon "$datadir"
# Now create the database
echo "Initializing MySQL database"
- /usr/bin/mysql_install_db --datadir="$datadir" --user=mysql
+ /usr/bin/mysql_install_db --datadir="$datadir" --user="$myuser"
ret=$?
if [ $ret -ne 0 ] ; then
echo "Initialization of MySQL database failed." >&2
@@ -55,7 +76,7 @@ if [ ! -d "$datadir/mysql" ] ; then
exit $ret
fi
# In case we're running as root, make sure files are owned properly
- chown -R mysql:mysql "$datadir"
+ chown -R "$myuser:$mygroup" "$datadir"
fi
exit 0