]> git.openstreetmap.org Git - chef.git/blob - cookbooks/forum/recipes/default.rb
Fetch the forum style from github instead of fluxbb.org
[chef.git] / cookbooks / forum / recipes / default.rb
1 #
2 # Cookbook:: forum
3 # Recipe:: default
4 #
5 # Copyright:: 2014, OpenStreetMap Foundation
6 #
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #     https://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #
19
20 include_recipe "accounts"
21 include_recipe "apache"
22 include_recipe "git"
23 include_recipe "mysql"
24 include_recipe "php::fpm"
25
26 cache_dir = Chef::Config[:file_cache_path]
27
28 passwords = data_bag_item("forum", "passwords")
29
30 package %w[
31   php-cli
32   php-mysql
33   php-xml
34   php-apcu
35   unzip
36 ]
37
38 apache_module "env"
39 apache_module "rewrite"
40
41 ssl_certificate "forum.openstreetmap.org" do
42   domains ["forum.openstreetmap.org", "forum.osm.org"]
43   notifies :reload, "service[apache2]"
44 end
45
46 php_fpm "forum.openstreetmap.org" do
47   php_admin_values "open_basedir" => "/srv/forum.openstreetmap.org/html/:/usr/share/php/:/tmp/",
48                    "disable_functions" => "exec,shell_exec,system,passthru,popen,proc_open"
49   prometheus_port 9253
50 end
51
52 apache_site "forum.openstreetmap.org" do
53   template "apache.erb"
54 end
55
56 directory "/srv/forum.openstreetmap.org" do
57   owner "forum"
58   group "forum"
59   mode "755"
60 end
61
62 git "/srv/forum.openstreetmap.org/html/" do
63   action :sync
64   repository "http://github.com/openstreetmap/openstreetmap-forum.git"
65   revision "openstreetmap-1.5.10"
66   depth 1
67   user "forum"
68   group "forum"
69   notifies :reload, "service[apache2]"
70 end
71
72 remote_file "#{cache_dir}/air3_v0.8.tar.gz" do
73   action :create_if_missing
74   source "https://github.com/natrius/air3/archive/refs/tags/v0.8.tar.gz"
75   owner "root"
76   group "root"
77   mode "644"
78   backup false
79 end
80
81 execute "#{cache_dir}/air3_v0.8.tar.gz" do
82   action :nothing
83   command "tar --gunzip --extract --file=#{cache_dir}/air3_v0.8.tar.gz --strip-components=1 --wildcards air3-0.8/Air3.css 'air3-0.8/Air3/*'"
84   cwd "/srv/forum.openstreetmap.org/html/style"
85   user "forum"
86   group "forum"
87   subscribes :run, "remote_file[#{cache_dir}/air3_v0.8.tar.gz]", :immediately
88 end
89
90 directory "/srv/forum.openstreetmap.org/html/cache/" do
91   owner "www-data"
92   group "www-data"
93   mode "755"
94 end
95
96 directory "/srv/forum.openstreetmap.org/html/img/avatars/" do
97   owner "www-data"
98   group "www-data"
99   mode "755"
100 end
101
102 template "/srv/forum.openstreetmap.org/html/config.php" do
103   source "config.php.erb"
104   owner "forum"
105   group "www-data"
106   mode "440"
107   variables :passwords => passwords
108 end
109
110 mysql_user "forum@localhost" do
111   password passwords["database"]
112 end
113
114 mysql_database "forum" do
115   permissions "forum@localhost" => :all
116 end
117
118 template "/etc/cron.daily/forum-backup" do
119   source "backup.cron.erb"
120   owner "root"
121   group "root"
122   mode "750"
123   variables :passwords => passwords
124 end