]> git.openstreetmap.org Git - chef.git/blob - cookbooks/planet/recipes/dump.rb
7bd11aecef88497339137e48e5dddb376a6656ca
[chef.git] / cookbooks / planet / recipes / dump.rb
1 #
2 # Cookbook:: planet
3 # Recipe:: dump
4 #
5 # Copyright:: 2013, 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 "git"
21
22 package %w[
23   gcc
24   g++
25   make
26   autoconf
27   automake
28   pkg-config
29   libxml2-dev
30   libboost-dev
31   libboost-program-options-dev
32   libboost-date-time-dev
33   libboost-filesystem-dev
34   libboost-thread-dev
35   libboost-iostreams-dev
36   libosmpbf-dev
37   libprotobuf-dev
38   osmpbf-bin
39   pbzip2
40   php-cli
41   php-curl
42   mktorrent
43   xmlstarlet
44   libxml2-utils
45   inotify-tools
46 ]
47
48 directory "/opt/planet-dump-ng" do
49   owner "root"
50   group "root"
51   mode "755"
52 end
53
54 git "/opt/planet-dump-ng" do
55   action :sync
56   repository "https://github.com/zerebubuth/planet-dump-ng.git"
57   revision "v1.2.6"
58   depth 1
59   user "root"
60   group "root"
61 end
62
63 execute "/opt/planet-dump-ng/autogen.sh" do
64   action :nothing
65   command "./autogen.sh"
66   cwd "/opt/planet-dump-ng"
67   user "root"
68   group "root"
69   subscribes :run, "git[/opt/planet-dump-ng]"
70 end
71
72 execute "/opt/planet-dump-ng/configure" do
73   action :nothing
74   command "./configure"
75   cwd "/opt/planet-dump-ng"
76   user "root"
77   group "root"
78   subscribes :run, "execute[/opt/planet-dump-ng/autogen.sh]"
79 end
80
81 execute "/opt/planet-dump-ng/Makefile" do
82   action :nothing
83   command "make"
84   cwd "/opt/planet-dump-ng"
85   user "root"
86   group "root"
87   subscribes :run, "execute[/opt/planet-dump-ng/configure]"
88 end
89
90 directory "/store/planetdump" do
91   owner "www-data"
92   group "www-data"
93   mode "755"
94   recursive true
95 end
96
97 %w[planetdump planet-mirror-redirect-update].each do |program|
98   template "/usr/local/bin/#{program}" do
99     source "#{program}.erb"
100     owner "root"
101     group "root"
102     mode "755"
103   end
104 end
105
106 systemd_service "planetdump@" do
107   description "Planet dump for %i"
108   user "www-data"
109   exec_start "/usr/local/bin/planetdump %i"
110   memory_max "64G"
111   sandbox true
112   read_write_paths [
113     "/store/planetdump",
114     "/store/planet/pbf",
115     "/store/planet/planet",
116     "/var/log/exim4",
117     "/var/spool/exim4"
118   ]
119 end
120
121 systemd_service "planetdump-trigger" do
122   description "Planet dump trigger"
123   user "root"
124   exec_start "/usr/local/bin/planetdump-trigger"
125   sandbox true
126   restrict_address_families "AF_UNIX"
127 end
128
129 service "planetdump-trigger" do
130   action [:enable, :start]
131 end
132
133 systemd_service "planet-dump-mirror" do
134   description "Update planet dump mirrors"
135   exec_start "/usr/local/bin/planet-mirror-redirect-update"
136   user "www-data"
137   sandbox :enable_network => true
138   memory_deny_write_execute false
139   read_write_paths "/store/planet/.htaccess"
140 end
141
142 systemd_timer "planet-dump-mirror" do
143   description "Update planet dump mirrors"
144   on_boot_sec "10min"
145   on_unit_inactive_sec "10min"
146 end
147
148 service "planet-dump-mirror.timer" do
149   action [:enable, :start]
150 end