Make phpBB3 import template work with latest image (#449)
[discourse_docker.git] / templates / import / phpbb3.template.yml
index 1cd745442ab06388ae2c8320c161da722fa9ba48..19975879a3f241b3fda7e587006b17509be032c9 100644 (file)
@@ -18,21 +18,6 @@ hooks:
           - rm 01-nginx
           - rm 02-unicorn
 
-    - file:
-        path: /etc/apt/sources.list.d/mariadb.list
-        contents: |
-          # MariaDB 10.1 repository list
-          # http://mariadb.org/mariadb/repositories/
-          deb [arch=amd64,i386] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.1/ubuntu trusty main
-          deb-src http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.1/ubuntu trusty main
-
-    - file:
-        path: /etc/apt/preferences.d/mariadb
-        contents: |
-          Package: *
-          Pin: release o=MariaDB
-          Pin-Priority: 1000
-
     - file:
         path: /etc/mysql/conf.d/import.cnf
         contents: |
@@ -41,6 +26,7 @@ hooks:
           default-storage-engine=MyISAM
           default-tmp-storage-engine=MyISAM
           innodb=OFF
+          sql_mode=NO_AUTO_CREATE_USER
 
           datadir=/shared/import/mysql/data
 
@@ -50,7 +36,6 @@ hooks:
     - exec:
         cmd:
           - mkdir -p /shared/import/mysql/data
-          - apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
           - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y nano libmariadbclient-dev mariadb-server
           - sed -Ei 's/^log/#&/' /etc/mysql/my.cnf
 
@@ -59,14 +44,23 @@ hooks:
         chmod: "+x"
         contents: |
           #!/bin/bash
+          cd /
+          umask 077
+
           # Make sure the datadir exists, is accessible and contains all system tables
           mkdir -p /shared/import/mysql/data
           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
-          exec 2>&1
-          exec /usr/sbin/mysqld -u mysql
+          MYSQLADMIN='/usr/bin/mysqladmin --defaults-extra-file=/etc/mysql/debian.cnf'
+          trap "$MYSQLADMIN shutdown" 0
+          trap 'exit 2' 1 2 3 15
+          /usr/bin/mysqld_safe & wait
 
     - file:
         path: /etc/runit/3.d/99-mysql
@@ -80,16 +74,23 @@ hooks:
         chmod: "+x"
         contents: |
           #!/bin/bash
+          set -e
+
           chown discourse /shared/import/settings.yml
           chown discourse -R /shared/import/data
 
           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..."
+              rm /shared/import/mysql/imported
+            fi
+
             if [ ! -f "/shared/import/mysql/imported" ]; then
               echo "Loading database dump into MySQL..."
               mysql -uroot -e "DROP DATABASE IF EXISTS phpbb"
               mysql -uroot -e "CREATE DATABASE phpbb"
               mysql -uroot --default-character-set=utf8 --database=phpbb < /shared/import/data/phpbb_mysql.sql
-              touch /shared/import/mysql/imported
+              sha256sum /shared/import/data/phpbb_mysql.sql > /shared/import/mysql/imported
             fi
           else
             sv stop mysql
@@ -113,4 +114,4 @@ hooks:
         cmd:
           - echo "gem 'mysql2'" >> Gemfile
           - echo "gem 'ruby-bbcode-to-md', :github => 'nlalonde/ruby-bbcode-to-md'" >> Gemfile
-          - su discourse -c 'bundle install --no-deployment --without test --without development --path vendor/bundle'
+          - su discourse -c 'bundle install --no-deployment --path vendor/bundle --jobs 4 --without test development'