Make phpBB3 import template work with latest image (#449)
[discourse_docker.git] / templates / import / phpbb3.template.yml
CommitLineData
bd4495f6
GS
1# This template installs MariaDB and all dependencies needed for importing from phpBB3.
2
3params:
4 home: /var/www/discourse
5
6hooks:
7 after_web_config:
8 - exec:
9 cd: /etc/service
10 cmd:
11 - rm -R unicorn
12 - rm -R nginx
13 - rm -R cron
14
15 - exec:
16 cd: /etc/runit/3.d
17 cmd:
18 - rm 01-nginx
19 - rm 02-unicorn
20
bd4495f6
GS
21 - file:
22 path: /etc/mysql/conf.d/import.cnf
23 contents: |
24 [mysqld]
25 # disable InnoDB since it is extremly slow in Docker container
26 default-storage-engine=MyISAM
27 default-tmp-storage-engine=MyISAM
28 innodb=OFF
9a3e1b6c 29 sql_mode=NO_AUTO_CREATE_USER
bd4495f6
GS
30
31 datadir=/shared/import/mysql/data
32
33 skip-host-cache
34 skip-name-resolve
35
36 - exec:
37 cmd:
38 - mkdir -p /shared/import/mysql/data
bd4495f6
GS
39 - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y nano libmariadbclient-dev mariadb-server
40 - sed -Ei 's/^log/#&/' /etc/mysql/my.cnf
41
42 - file:
43 path: /etc/service/mysql/run
44 chmod: "+x"
45 contents: |
46 #!/bin/bash
3df237a6
GS
47 cd /
48 umask 077
49
bd4495f6
GS
50 # Make sure the datadir exists, is accessible and contains all system tables
51 mkdir -p /shared/import/mysql/data
52 chown mysql -R /shared/import/mysql/data
53 /usr/bin/mysql_install_db --user=mysql
54
3df237a6
GS
55 # Allow connection as root user without password
56 mysql -uroot -e "UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE user = 'root' AND plugin = 'unix_socket'"
57 mysql -uroot -e "FLUSH PRIVILEGES"
58
bd4495f6 59 # Shamelessly copied from http://smarden.org/runit1/runscripts.html#mysql
3df237a6
GS
60 MYSQLADMIN='/usr/bin/mysqladmin --defaults-extra-file=/etc/mysql/debian.cnf'
61 trap "$MYSQLADMIN shutdown" 0
62 trap 'exit 2' 1 2 3 15
63 /usr/bin/mysqld_safe & wait
bd4495f6
GS
64
65 - file:
66 path: /etc/runit/3.d/99-mysql
67 chmod: "+x"
68 contents: |
69 #!/bin/bash
70 sv stop mysql
71
72 - file:
73 path: /usr/local/bin/import_phpbb3.sh
74 chmod: "+x"
75 contents: |
76 #!/bin/bash
34559d02
GS
77 set -e
78
bd4495f6
GS
79 chown discourse /shared/import/settings.yml
80 chown discourse -R /shared/import/data
81
82 if [ -f "/shared/import/data/phpbb_mysql.sql" ]; then
34559d02
GS
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
86 fi
87
bd4495f6
GS
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"
34559d02
GS
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
bd4495f6
GS
94 fi
95 else
96 sv stop mysql
97 fi
98
99 cd $home
100 echo "The phpBB3 import is starting..."
101 echo
102 su discourse -c 'bundle exec ruby script/import_scripts/phpbb3.rb /shared/import/settings.yml'
103
104 - exec:
105 cd: $home
106 cmd:
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
110
111 after_bundle_exec:
112 - exec:
113 cd: $home
114 cmd:
115 - echo "gem 'mysql2'" >> Gemfile
116 - echo "gem 'ruby-bbcode-to-md', :github => 'nlalonde/ruby-bbcode-to-md'" >> Gemfile
b8866fb9 117 - su discourse -c 'bundle install --no-deployment --path vendor/bundle --jobs 4 --without test development'