mysql: fix start script for /run on separate tmpfs
authorArnout Vandecappelle <arnout@mind.be>
Fri, 11 Dec 2015 21:52:47 +0000 (22:52 +0100)
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Sat, 12 Dec 2015 11:03:55 +0000 (12:03 +0100)
Recently the default skeleton was changed to have /run as a separate
tmpfs instead of a symlink to /tmp. /run is not world-writable, but
mysqld tries to write its PID file as user mysql. Therefore, it fails
to start.

To fix, create /run/mysql and give it to user mysql.

While we're at it, change the paths to /run instead of /var/run.

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
package/mysql/S97mysqld

index dd7f57f13f10bf59f74ea8b557df26e95960ef27..1d87e68d963c89fbf37c69de5467e8a8c0862727 100644 (file)
@@ -7,16 +7,20 @@ case "$1" in
                        mysql_install_db --user=mysql --ldata=/var/mysql
                fi
 
+               # mysqld runs as user mysql, but /run is only writable by root
+               # so create a subdirectory for mysql.
+               install -d -o mysql -g root -m 0700 /run/mysql
+
                # We don't use start-stop-daemon because mysqld has
                # its own wrapper script.
                printf "Starting mysql..."
-               /usr/bin/mysqld_safe --pid-file=/var/run/mysqld.pid &
+               /usr/bin/mysqld_safe --pid-file=/run/mysql/mysqld.pid &
                echo "done."
                ;;
        stop)
                printf "Stopping mysql..."
-               if test -f /var/run/mysqld.pid ; then
-                       kill `cat /var/run/mysqld.pid`
+               if test -f /run/mysql/mysqld.pid ; then
+                       kill `cat /run/mysql/mysqld.pid`
                fi
                echo "done."
                ;;