]> git.openstreetmap.org Git - chef.git/blob - cookbooks/planet/recipes/dump.rb
Merge remote-tracking branch 'tigerfell/pr257'
[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 node.default[:incron][:planetdump] = {
21   :user => "root",
22   :path => "/store/backup",
23   :events => %w[IN_CREATE IN_MOVED_TO],
24   :command => "/bin/systemctl start planetdump@$#"
25 }
26
27 include_recipe "git"
28 include_recipe "incron"
29
30 package %w[
31   gcc
32   g++
33   make
34   autoconf
35   automake
36   pkg-config
37   libxml2-dev
38   libboost-dev
39   libboost-program-options-dev
40   libboost-date-time-dev
41   libboost-filesystem-dev
42   libboost-thread-dev
43   libboost-iostreams-dev
44   libosmpbf-dev
45   libprotobuf-dev
46   osmpbf-bin
47   pbzip2
48   php-cli
49   php-curl
50   mktorrent
51   xmlstarlet
52   libxml2-utils
53 ]
54
55 directory "/opt/planet-dump-ng" do
56   owner "root"
57   group "root"
58   mode "755"
59 end
60
61 git "/opt/planet-dump-ng" do
62   action :sync
63   repository "https://github.com/zerebubuth/planet-dump-ng.git"
64   revision "v1.2.4"
65   depth 1
66   user "root"
67   group "root"
68 end
69
70 execute "/opt/planet-dump-ng/autogen.sh" do
71   action :nothing
72   command "./autogen.sh"
73   cwd "/opt/planet-dump-ng"
74   user "root"
75   group "root"
76   subscribes :run, "git[/opt/planet-dump-ng]"
77 end
78
79 execute "/opt/planet-dump-ng/configure" do
80   action :nothing
81   command "./configure"
82   cwd "/opt/planet-dump-ng"
83   user "root"
84   group "root"
85   subscribes :run, "execute[/opt/planet-dump-ng/autogen.sh]"
86 end
87
88 execute "/opt/planet-dump-ng/Makefile" do
89   action :nothing
90   command "make"
91   cwd "/opt/planet-dump-ng"
92   user "root"
93   group "root"
94   subscribes :run, "execute[/opt/planet-dump-ng/configure]"
95 end
96
97 directory "/store/planetdump" do
98   owner "www-data"
99   group "www-data"
100   mode "755"
101   recursive true
102 end
103
104 %w[planetdump planet-mirror-redirect-update].each do |program|
105   template "/usr/local/bin/#{program}" do
106     source "#{program}.erb"
107     owner "root"
108     group "root"
109     mode "755"
110   end
111 end
112
113 systemd_service "planetdump@" do
114   description "Planet dump for %i"
115   user "www-data"
116   exec_start "/usr/local/bin/planetdump %i"
117   memory_max "64G"
118   private_tmp true
119   protect_system "full"
120   protect_home true
121   read_write_paths "/var/log/exim4"
122 end
123
124 cron_d "planet-dump-mirror" do
125   minute "*/10"
126   user "www-data"
127   command "/usr/local/bin/planet-mirror-redirect-update"
128   mailto "horntail-www-data-cron@firefishy.com"
129 end