Merge pull request #275 from lbergnehr/lbergnehr-patch-1
[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/apt/preferences.d/mariadb
23 contents: |
24 Package: *
25 Pin: release o=MariaDB
26 Pin-Priority: 1000
27
28 - file:
29 path: /etc/mysql/conf.d/import.cnf
30 contents: |
31 [mysqld]
32 # disable InnoDB since it is extremly slow in Docker container
33 default-storage-engine=MyISAM
34 default-tmp-storage-engine=MyISAM
35 innodb=OFF
9a3e1b6c 36 sql_mode=NO_AUTO_CREATE_USER
bd4495f6
GS
37
38 datadir=/shared/import/mysql/data
39
40 skip-host-cache
41 skip-name-resolve
42
43 - exec:
44 cmd:
45 - mkdir -p /shared/import/mysql/data
19dc53d5
GS
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'
bd4495f6
GS
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
50
51 - file:
52 path: /etc/service/mysql/run
53 chmod: "+x"
54 contents: |
55 #!/bin/bash
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
60
61 # Shamelessly copied from http://smarden.org/runit1/runscripts.html#mysql
62 exec 2>&1
63 exec /usr/sbin/mysqld -u mysql
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
77 chown discourse /shared/import/settings.yml
78 chown discourse -R /shared/import/data
79
80 if [ -f "/shared/import/data/phpbb_mysql.sql" ]; then
81 if [ ! -f "/shared/import/mysql/imported" ]; then
82 echo "Loading database dump into MySQL..."
83 mysql -uroot -e "DROP DATABASE IF EXISTS phpbb"
84 mysql -uroot -e "CREATE DATABASE phpbb"
9a3e1b6c 85 mysql -uroot --default-character-set=utf8 --database=phpbb < /shared/import/data/phpbb_mysql.sql && \
bd4495f6
GS
86 touch /shared/import/mysql/imported
87 fi
88 else
89 sv stop mysql
90 fi
91
92 cd $home
93 echo "The phpBB3 import is starting..."
94 echo
95 su discourse -c 'bundle exec ruby script/import_scripts/phpbb3.rb /shared/import/settings.yml'
96
97 - exec:
98 cd: $home
99 cmd:
100 - mkdir -p /shared/import/data
101 - chown discourse -R /shared/import
102 - cp -n script/import_scripts/phpbb3/settings.yml /shared/import/settings.yml
103
104 after_bundle_exec:
105 - exec:
106 cd: $home
107 cmd:
108 - echo "gem 'mysql2'" >> Gemfile
109 - echo "gem 'ruby-bbcode-to-md', :github => 'nlalonde/ruby-bbcode-to-md'" >> Gemfile
110 - su discourse -c 'bundle install --no-deployment --without test --without development --path vendor/bundle'