Merge pull request #217 from gschlager/phpbb3-import
[discourse_docker.git] / templates / import / phpbb3.template.yml
1 # This template installs MariaDB and all dependencies needed for importing from phpBB3.
2
3 params:
4 home: /var/www/discourse
5
6 hooks:
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
21 - file:
22 path: /etc/apt/sources.list.d/mariadb.list
23 contents: |
24 # MariaDB 10.1 repository list
25 # http://mariadb.org/mariadb/repositories/
26 deb [arch=amd64,i386] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.1/ubuntu trusty main
27 deb-src http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.1/ubuntu trusty main
28
29 - file:
30 path: /etc/apt/preferences.d/mariadb
31 contents: |
32 Package: *
33 Pin: release o=MariaDB
34 Pin-Priority: 1000
35
36 - file:
37 path: /etc/mysql/conf.d/import.cnf
38 contents: |
39 [mysqld]
40 # disable InnoDB since it is extremly slow in Docker container
41 default-storage-engine=MyISAM
42 default-tmp-storage-engine=MyISAM
43 innodb=OFF
44
45 datadir=/shared/import/mysql/data
46
47 skip-host-cache
48 skip-name-resolve
49
50 - exec:
51 cmd:
52 - mkdir -p /shared/import/mysql/data
53 - apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
54 - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y nano libmariadbclient-dev mariadb-server
55 - sed -Ei 's/^log/#&/' /etc/mysql/my.cnf
56
57 - file:
58 path: /etc/service/mysql/run
59 chmod: "+x"
60 contents: |
61 #!/bin/bash
62 # Make sure the datadir exists, is accessible and contains all system tables
63 mkdir -p /shared/import/mysql/data
64 chown mysql -R /shared/import/mysql/data
65 /usr/bin/mysql_install_db --user=mysql
66
67 # Shamelessly copied from http://smarden.org/runit1/runscripts.html#mysql
68 exec 2>&1
69 exec /usr/sbin/mysqld -u mysql
70
71 - file:
72 path: /etc/runit/3.d/99-mysql
73 chmod: "+x"
74 contents: |
75 #!/bin/bash
76 sv stop mysql
77
78 - file:
79 path: /usr/local/bin/import_phpbb3.sh
80 chmod: "+x"
81 contents: |
82 #!/bin/bash
83 chown discourse /shared/import/settings.yml
84 chown discourse -R /shared/import/data
85
86 if [ -f "/shared/import/data/phpbb_mysql.sql" ]; then
87 if [ ! -f "/shared/import/mysql/imported" ]; then
88 echo "Loading database dump into MySQL..."
89 mysql -uroot -e "DROP DATABASE IF EXISTS phpbb"
90 mysql -uroot -e "CREATE DATABASE phpbb"
91 mysql -uroot --default-character-set=utf8 --database=phpbb < /shared/import/data/phpbb_mysql.sql
92 touch /shared/import/mysql/imported
93 fi
94 else
95 sv stop mysql
96 fi
97
98 cd $home
99 echo "The phpBB3 import is starting..."
100 echo
101 su discourse -c 'bundle exec ruby script/import_scripts/phpbb3.rb /shared/import/settings.yml'
102
103 - exec:
104 cd: $home
105 cmd:
106 - mkdir -p /shared/import/data
107 - chown discourse -R /shared/import
108 - cp -n script/import_scripts/phpbb3/settings.yml /shared/import/settings.yml
109
110 after_bundle_exec:
111 - exec:
112 cd: $home
113 cmd:
114 - echo "gem 'mysql2'" >> Gemfile
115 - echo "gem 'ruby-bbcode-to-md', :github => 'nlalonde/ruby-bbcode-to-md'" >> Gemfile
116 - su discourse -c 'bundle install --no-deployment --without test --without development --path vendor/bundle'