5 # Copyright 2011, OpenStreetMap Foundation
 
   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
 
  11 #     http://www.apache.org/licenses/LICENSE-2.0
 
  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.
 
  20 include_recipe "web::base"
 
  22 db_passwords = data_bag_item("db", "passwords")
 
  27 package "libarchive-dev"
 
  29 package "libexpat1-dev"
 
  30 package "libgd2-noxpm-dev"
 
  31 package "libmemcached-dev"
 
  35 gpx_directory = "#{node[:web][:base_directory]}/gpx-import"
 
  36 pid_directory = node[:web][:pid_directory]
 
  37 log_directory = node[:web][:log_directory]
 
  39 execute "gpx-import-build" do
 
  41   command "make DB=postgres"
 
  42   cwd "#{gpx_directory}/src"
 
  49   repository "git://git.openstreetmap.org/gpx-import.git"
 
  53   notifies :run, "execute[gpx-import-build]", :immediate
 
  56 systemd_service "gpx-import" do
 
  57   description "GPX Import Daemon"
 
  58   after "network.target"
 
  60   environment_file "GPX_SLEEP_TIME" => "40",
 
  61                    "GPX_PATH_TRACES" => "/store/rails/gpx/traces",
 
  62                    "GPX_PATH_IMAGES" => "/store/rails/gpx/images",
 
  63                    "GPX_PATH_TEMPLATES" => "#{gpx_directory}/templates/",
 
  64                    "GPX_PGSQL_HOST" => node[:web][:database_host],
 
  65                    "GPX_PGSQL_USER" => "gpximport",
 
  66                    "GPX_PGSQL_PASS" => db_passwords["gpximport"],
 
  67                    "GPX_PGSQL_DB" => "openstreetmap",
 
  68                    "GPX_LOG_FILE" => "#{log_directory}/gpx-import.log",
 
  69                    "GPX_PID_FILE" => "#{pid_directory}/gpx-import.pid",
 
  70                    "GPX_MAIL_SENDER" => "bounces@openstreetmap.org"
 
  72   exec_start "#{gpx_directory}/src/gpx-import"
 
  73   exec_reload "/bin/kill -HUP $MAINPID"
 
  79   pid_file "#{pid_directory}/gpx-import.pid"
 
  82 if %w[database_offline database_readonly gpx_offline].include?(node[:web][:status])
 
  83   service "gpx-import" do
 
  87   service "gpx-import" do
 
  88     action [:enable, :start]
 
  89     supports :restart => true, :reload => true
 
  90     subscribes :restart, "execute[gpx-import-build]"
 
  91     subscribes :restart, "systemd_service[gpx-import]"