Skip to contentSkip to conversation

mysql: Make S97mysqld source a default file

PATCH New Eloi BAIL 3 participants 3 messages Oct 13, 2016 – Oct 15, 2016

lore
Share & tools
lore

Eloi BAIL

author
#0 lore raw

PATCH 1/1 mysql: Make S97mysqld source a default file

Hardcoded parameters are used for mysql installation. Make S97mysqld source a /etc/default/mysql file where these parameters can be overridden.

---
 package/mysql/S97mysqld | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
package/mysql/S97mysqld +6 -2
index 5a660e9..638790f 100644
@@ -1,10 +1,14 @@
 #!/bin/sh
 
+MYSQL_DIR="/var/mysql"
+MYSQL_USER="mysql"
+[ -r /etc/default/mysql ] && . /etc/default/mysql
+
 case "$1" in
 	start)
-		if [ ! -d /var/mysql/mysql ] ; then
+		if [ ! -d $MYSQL_DIR/mysql ] ; then
 			echo "Creating MySQL system tables..."
-			mysql_install_db --user=mysql --ldata=/var/mysql
+			mysql_install_db --user=$MYSQL_USER --ldata=$MYSQL_DIR
 		fi
 
 		# mysqld runs as user mysql, but /run is only writable by root
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 mysql: Make S97mysqld source a default file

Hello Eloi,

Quoted 5 lines · Eloi BAIL

Hardcoded parameters are used for mysql installation. Make S97mysqld source a /etc/default/mysql file where these parameters can be overridden.

I've done a run test on qemu creating different /etc/default/mysql files. Everything worked as expected, so...

However I'm not sure if this approach is correct as someone may expect a different content in the default file. For instance a content compatible to be used with the --defaults-file and --defaults-extra-file options:

[mysql_install_db]
user = mysql
datadir = /var/mysql

Why don't we call mysql_install_db with those options passing that kind of default file, instead of sourcing it as you do in your patch? There are two options to do that. The first one is doing it manually (not in the init script). The second one is to do it in the init script, as is done right now, but we would need to grab the value of "datadir" with something like "grep datadir /etc/default/mysql | cut -d= -f2".

Let's see what the others devs think about it.

Regards,

Vincent.

Quoted 26 lines
---
 package/mysql/S97mysqld | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
package/mysql/S97mysqld +6 -2
index 5a660e9..638790f 100644
@@ -1,10 +1,14 @@
 #!/bin/sh
 
+MYSQL_DIR="/var/mysql"
+MYSQL_USER="mysql"
+[ -r /etc/default/mysql ] && . /etc/default/mysql
+
 case "$1" in
 	start)
-		if [ ! -d /var/mysql/mysql ] ; then
+		if [ ! -d $MYSQL_DIR/mysql ] ; then
 			echo "Creating MySQL system tables..."
-			mysql_install_db --user=mysql --ldata=/var/mysql
+			mysql_install_db --user=$MYSQL_USER --ldata=$MYSQL_DIR
 		fi
 
 		# mysqld runs as user mysql, but /run is only writable by root
#2 lore raw

PATCH 1/1 mysql: Make S97mysqld source a default file

In reply to Eloi BAIL
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Eloi" == Eloi BAIL <[email protected]> writes:

Hardcoded parameters are used for mysql installation. Make S97mysqld source a /etc/default/mysql file where these parameters can be overridden.

Committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard