]> git.openstreetmap.org Git - chef.git/blob - cookbooks/web/recipes/gpx.rb
Fix new rubocop warnings
[chef.git] / cookbooks / web / recipes / gpx.rb
1 #
2 # Cookbook Name:: web
3 # Recipe:: gpx
4 #
5 # Copyright 2011, 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 #     http://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 "web::base"
21
22 db_passwords = data_bag_item("db", "passwords")
23
24 package "gcc"
25 package "make"
26 package "pkg-config"
27 package "libarchive-dev"
28 package "libbz2-dev"
29 package "libexpat1-dev"
30 package "libgd2-noxpm-dev"
31 package "libmemcached-dev"
32 package "libpq-dev"
33 package "zlib1g-dev"
34
35 gpx_directory = "#{node[:web][:base_directory]}/gpx-import"
36 pid_directory = node[:web][:pid_directory]
37 log_directory = node[:web][:log_directory]
38
39 execute "gpx-import-build" do
40   action :nothing
41   command "make DB=postgres"
42   cwd "#{gpx_directory}/src"
43   user "rails"
44   group "rails"
45 end
46
47 git gpx_directory do
48   action :sync
49   repository "git://git.openstreetmap.org/gpx-import.git"
50   revision "live"
51   user "rails"
52   group "rails"
53   notifies :run, "execute[gpx-import-build]", :immediate
54 end
55
56 template "/etc/init.d/gpx-import" do
57   source "init.gpx.erb"
58   owner "root"
59   group "root"
60   mode 0755
61   variables :gpx_directory => gpx_directory,
62             :pid_directory => pid_directory,
63             :log_directory => log_directory,
64             :database_host => node[:web][:database_host],
65             :database_name => "openstreetmap",
66             :database_username => "gpximport",
67             :database_password => db_passwords["gpximport"]
68 end
69
70 if %w(database_offline database_readonly gpx_offline).include?(node[:web][:status])
71   service "gpx-import" do
72     action :stop
73   end
74 else
75   service "gpx-import" do
76     action [:enable, :start]
77     supports :restart => true, :reload => true
78     subscribes :restart, "execute[gpx-import-build]"
79     subscribes :restart, "template[/etc/init.d/gpx-import]"
80   end
81 end