From ac6930c9790f3277906c47e7e70c65837b60358b Mon Sep 17 00:00:00 2001
From: Gerhard Schlager <mail@gerhard-schlager.at>
Date: Tue, 1 Oct 2019 10:59:22 -0400
Subject: [PATCH] Update MySQL privileges when starting phpBB3 import

MySQL isn't running in the init script yet, so updating the privileges doesn't work. Duh!

Follow-up to 3df237a6
---
 templates/import/phpbb3.template.yml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/templates/import/phpbb3.template.yml b/templates/import/phpbb3.template.yml
index 1997587..946aa88 100644
--- a/templates/import/phpbb3.template.yml
+++ b/templates/import/phpbb3.template.yml
@@ -52,10 +52,6 @@ hooks:
           chown mysql -R /shared/import/mysql/data
           /usr/bin/mysql_install_db --user=mysql
 
-          # Allow connection as root user without password
-          mysql -uroot -e "UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE user = 'root' AND plugin = 'unix_socket'"
-          mysql -uroot -e "FLUSH PRIVILEGES"
-
           # Shamelessly copied from http://smarden.org/runit1/runscripts.html#mysql
           MYSQLADMIN='/usr/bin/mysqladmin --defaults-extra-file=/etc/mysql/debian.cnf'
           trap "$MYSQLADMIN shutdown" 0
@@ -79,6 +75,10 @@ hooks:
           chown discourse /shared/import/settings.yml
           chown discourse -R /shared/import/data
 
+          # Allow connection as root user without password
+          mysql -uroot -e "UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE user = 'root' AND plugin = 'unix_socket'"
+          mysql -uroot -e "FLUSH PRIVILEGES"
+
           if [ -f "/shared/import/data/phpbb_mysql.sql" ]; then
             if [ -f "/shared/import/mysql/imported" ] && ! sha256sum --check /shared/import/mysql/imported &>/dev/null ; then
               echo "Checksum of database dump changed..."
-- 
2.25.1