From: Gerhard Schlager Date: Fri, 19 Aug 2016 21:46:18 +0000 (+0200) Subject: Improve template for phpBB3 importer X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=34559d028794bb91ca1bb85afcd4ea73a461b3ac;p=discourse_docker.git 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 --- 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