]> git.openstreetmap.org Git - chef.git/blob - cookbooks/forum/recipes/default.rb
Install some additional themes for the forum
[chef.git] / cookbooks / forum / recipes / default.rb
1 #
2 # Cookbook Name:: 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 include_recipe "apache"
20 include_recipe "git"
21 include_recipe "mysql"
22
23 passwords = data_bag_item("forum", "passwords")
24
25 package %w[
26   php
27   php-cli
28   php-mysql
29   php-xml
30   php-apcu
31 ]
32
33 apache_module "php7.2"
34 apache_module "rewrite"
35
36 ssl_certificate "forum.openstreetmap.org" do
37   domains ["forum.openstreetmap.org", "forum.osm.org"]
38   notifies :reload, "service[apache2]"
39 end
40
41 apache_site "forum.openstreetmap.org" do
42   template "apache.erb"
43 end
44
45 directory "/srv/forum.openstreetmap.org" do
46   owner "forum"
47   group "forum"
48   mode 0o755
49 end
50
51 git "/srv/forum.openstreetmap.org/html/" do
52   action :sync
53   repository "http://github.com/openstreetmap/openstreetmap-forum.git"
54   revision "openstreetmap-1.5.10"
55   depth 1
56   user "forum"
57   group "forum"
58   notifies :reload, "service[apache2]"
59 end
60
61 remote_file "/var/cache/chef/midnight-flat-responsive_v1.0.zip" do
62   action :create_if_missing
63   source "https://fluxbb.org/resources/styles/midnight-flat-responsive/releases/1.0/midnight-flat-responsive_v1.0.zip"
64   owner "root"
65   group "root"
66   mode 0o644
67   backup false
68 end
69
70 execute "/var/cache/chef/midnight-flat-responsive_v1.0.zip" do
71   action :nothing
72   command "unzip -qq /var/cache/chef/midnight-flat-responsive_v1.0.zip Midnight.css Midnight/*"
73   cwd "/srv/forum.openstreetmap.org/html/style"
74   user "forum"
75   group "forum"
76   subscribes :run, "remote_file[/var/cache/chef/midnight-flat-responsive_v1.0.zip]", :immediately
77 end
78
79 remote_file "/var/cache/chef/victory-responsive-fluxbb-style_v1.0.2.zip" do
80   action :create_if_missing
81   source "https://fluxbb.org/resources/styles/victory-responsive-fluxbb-style/releases/1.0.2/victory-responsive-fluxbb-style_v1.0.2.zip"
82   owner "root"
83   group "root"
84   mode 0o644
85   backup false
86 end
87
88 execute "/var/cache/chef/victory-responsive-fluxbb-style_v1.0.2.zip" do
89   action :nothing
90   command "unzip -qq /var/cache/chef/victory-responsive-fluxbb-style_v1.0.2.zip Victory.css Victory/*"
91   cwd "/srv/forum.openstreetmap.org/html/style"
92   user "forum"
93   group "forum"
94   subscribes :run, "remote_file[/var/cache/chef/victory-responsive-fluxbb-style_v1.0.2.zip]", :immediately
95 end
96
97 directory "/srv/forum.openstreetmap.org/html/cache/" do
98   owner "www-data"
99   group "www-data"
100   mode 0o755
101 end
102
103 directory "/srv/forum.openstreetmap.org/html/img/avatars/" do
104   owner "www-data"
105   group "www-data"
106   mode 0o755
107 end
108
109 template "/srv/forum.openstreetmap.org/html/config.php" do
110   source "config.php.erb"
111   owner "forum"
112   group "www-data"
113   mode 0o440
114   variables :passwords => passwords
115 end
116
117 mysql_user "forum@localhost" do
118   password passwords["database"]
119 end
120
121 mysql_database "forum" do
122   permissions "forum@localhost" => :all
123 end
124
125 template "/etc/cron.daily/forum-backup" do
126   source "backup.cron.erb"
127   owner "root"
128   group "root"
129   mode 0o750
130   variables :passwords => passwords
131 end