- unless node[:dev][:rails].include?(name) and node[:dev][:rails][name].include?(:repository)
- database_config = YAML.load_file("#{rails_directory}/config/database.yml")
- database_name = database_config["production"]["database"]
- site_name = "#{name}.apis.dev.openstreetmap.org"
+ if details[:cgimap_repository]
+ git cgimap_directory do
+ action :sync
+ repository details[:cgimap_repository]
+ revision details[:cgimap_revision]
+ user "apis"
+ group "apis"
+ end
+
+ execute "#{cgimap_directory}/autogen.sh" do
+ action :nothing
+ command "./autogen.sh"
+ cwd cgimap_directory
+ user "apis"
+ group "apis"
+ subscribes :run, "git[#{cgimap_directory}]", :immediately
+ end
+
+ execute "#{cgimap_directory}/configure" do
+ action :nothing
+ command "./configure --with-fcgi=/usr --with-boost-libdir=/usr/lib/x86_64-linux-gnu --enable-yajl"
+ cwd cgimap_directory
+ user "apis"
+ group "apis"
+ subscribes :run, "execute[#{cgimap_directory}/autogen.sh]", :immediately
+ end
+
+ execute "#{cgimap_directory}/Makefile" do
+ action :nothing
+ command "make -j"
+ cwd cgimap_directory
+ user "apis"
+ group "apis"
+ subscribes :run, "execute[#{cgimap_directory}/configure]", :immediately
+ notifies :restart, "service[cgimap@#{name}]"
+ end
+
+ template "/etc/default/cgimap-#{name}" do
+ source "cgimap.environment.erb"
+ owner "root"
+ group "root"
+ mode "640"
+ variables :cgimap_port => cgimap_port,
+ :database_port => node[:postgresql][:clusters][:"14/main"][:port],
+ :database_name => database_name,
+ :log_directory => log_directory
+ notifies :restart, "service[cgimap@#{name}]"
+ end
+
+ service "cgimap@#{name}" do
+ action [:start, :enable]
+ end
+ end
+
+ ssl_certificate site_name do
+ domains [site_name] + site_aliases
+ notifies :reload, "service[apache2]"
+ end