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