1 # This template installs MariaDB and all dependencies needed for importing from phpBB3.
4 home: /var/www/discourse
22 path: /etc/apt/preferences.d/mariadb
25 Pin: release o=MariaDB
29 path: /etc/mysql/conf.d/import.cnf
32 # disable InnoDB since it is extremly slow in Docker container
33 default-storage-engine=MyISAM
34 default-tmp-storage-engine=MyISAM
36 sql_mode=NO_AUTO_CREATE_USER
38 datadir=/shared/import/mysql/data
45 - mkdir -p /shared/import/mysql/data
46 - apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
47 - add-apt-repository 'deb [arch=amd64,i386] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.1/ubuntu xenial main'
48 - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y nano libmariadbclient-dev mariadb-server
49 - sed -Ei 's/^log/#&/' /etc/mysql/my.cnf
52 path: /etc/service/mysql/run
56 # Make sure the datadir exists, is accessible and contains all system tables
57 mkdir -p /shared/import/mysql/data
58 chown mysql -R /shared/import/mysql/data
59 /usr/bin/mysql_install_db --user=mysql
61 # Shamelessly copied from http://smarden.org/runit1/runscripts.html#mysql
63 exec /usr/sbin/mysqld -u mysql
66 path: /etc/runit/3.d/99-mysql
73 path: /usr/local/bin/import_phpbb3.sh
79 chown discourse /shared/import/settings.yml
80 chown discourse -R /shared/import/data
82 if [ -f "/shared/import/data/phpbb_mysql.sql" ]; then
83 if [ -f "/shared/import/mysql/imported" ] && ! sha256sum --check /shared/import/mysql/imported &>/dev/null ; then
84 echo "Checksum of database dump changed..."
85 rm /shared/import/mysql/imported
88 if [ ! -f "/shared/import/mysql/imported" ]; then
89 echo "Loading database dump into MySQL..."
90 mysql -uroot -e "DROP DATABASE IF EXISTS phpbb"
91 mysql -uroot -e "CREATE DATABASE phpbb"
92 mysql -uroot --default-character-set=utf8 --database=phpbb < /shared/import/data/phpbb_mysql.sql
93 sha256sum /shared/import/data/phpbb_mysql.sql > /shared/import/mysql/imported
100 echo "The phpBB3 import is starting..."
102 su discourse -c 'bundle exec ruby script/import_scripts/phpbb3.rb /shared/import/settings.yml'
107 - mkdir -p /shared/import/data
108 - chown discourse -R /shared/import
109 - cp -n script/import_scripts/phpbb3/settings.yml /shared/import/settings.yml
115 - echo "gem 'mysql2'" >> Gemfile
116 - echo "gem 'ruby-bbcode-to-md', :github => 'nlalonde/ruby-bbcode-to-md'" >> Gemfile
117 - su discourse -c 'bundle install --no-deployment --path vendor/bundle --jobs 4 --without test development'