From 34559d028794bb91ca1bb85afcd4ea73a461b3ac Mon Sep 17 00:00:00 2001 From: Gerhard Schlager Date: Fri, 19 Aug 2016 23:46:18 +0200 Subject: [PATCH] Improve template for phpBB3 importer - Exit immediately if the database import or any other command fails - Store SHA26 checksum of database dump and automatically recreate database if the checksum changed since the last database import --- templates/import/phpbb3.template.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/templates/import/phpbb3.template.yml b/templates/import/phpbb3.template.yml index 29b81bd..35d185d 100644 --- a/templates/import/phpbb3.template.yml +++ b/templates/import/phpbb3.template.yml @@ -74,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 + mysql -uroot --default-character-set=utf8 --database=phpbb < /shared/import/data/phpbb_mysql.sql + sha256sum /shared/import/data/phpbb_mysql.sql > /shared/import/mysql/imported fi else sv stop mysql -- 2.25.1