]> git.openstreetmap.org Git - chef.git/blob - cookbooks/osmosis/recipes/default.rb
42679ac3f956c10f78f527efbed8ba0ce5f39125
[chef.git] / cookbooks / osmosis / recipes / default.rb
1 #
2 # Cookbook Name:: osmosis
3 # Recipe:: default
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 #     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 "chef"
21
22 osmosis_package = "osmosis-#{node[:osmosis][:version]}.zip"
23 osmosis_directory = "/opt/osmosis-#{node[:osmosis][:version]}"
24
25 Dir.glob("/var/cache/chef/osmosis-*.zip").each do |zip|
26   if zip != "/var/cache/chef/#{osmosis_package}"
27     file zip do
28       action :delete
29       backup false
30     end
31   end
32 end
33
34 directory osmosis_directory do
35   owner "root"
36   group "root"
37   mode 0755
38 end
39
40 execute "/var/cache/chef/#{osmosis_package}" do
41   action :nothing
42   command "unzip -q /var/cache/chef/#{osmosis_package}"
43   cwd osmosis_directory
44   user "root"
45   group "root"
46 end
47
48 remote_file "/var/cache/chef/#{osmosis_package}" do
49   action :create_if_missing
50   source "http://bretth.dev.openstreetmap.org/osmosis-build/#{osmosis_package}"
51   owner "root"
52   group "root"
53   mode 0644
54   backup false
55   notifies :run, "execute[/var/cache/chef/#{osmosis_package}]"
56 end
57
58 link "/usr/local/bin/osmosis" do
59   to "#{osmosis_directory}/bin/osmosis"
60 end
61
62 link "/usr/local/bin/osmosis-extract-apidb-0.6" do
63   to "#{osmosis_directory}/bin/osmosis-extract-apidb-0.6"
64 end