From f30d59e20c5c515986a14c86afbbc7f164ee1eb0 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 16 Oct 2013 19:20:16 +0100 Subject: [PATCH 1/1] Setup apache for the GPS tile server --- .../files/default/html/clientaccesspolicy.xml | 13 +++++++ .../files/default/html/crossdomain.xml | 6 ++++ .../gps-tile/files/default/html/robots.txt | 2 ++ cookbooks/gps-tile/recipes/default.rb | 27 +++++++++++++-- .../gps-tile/templates/default/apache.erb | 34 +++++++++++++++++++ .../templates/default/update.init.erb | 24 +++++++++++++ 6 files changed, 103 insertions(+), 3 deletions(-) create mode 100644 cookbooks/gps-tile/files/default/html/clientaccesspolicy.xml create mode 100644 cookbooks/gps-tile/files/default/html/crossdomain.xml create mode 100644 cookbooks/gps-tile/files/default/html/robots.txt create mode 100644 cookbooks/gps-tile/templates/default/apache.erb create mode 100644 cookbooks/gps-tile/templates/default/update.init.erb diff --git a/cookbooks/gps-tile/files/default/html/clientaccesspolicy.xml b/cookbooks/gps-tile/files/default/html/clientaccesspolicy.xml new file mode 100644 index 000000000..d60ec1d3f --- /dev/null +++ b/cookbooks/gps-tile/files/default/html/clientaccesspolicy.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/cookbooks/gps-tile/files/default/html/crossdomain.xml b/cookbooks/gps-tile/files/default/html/crossdomain.xml new file mode 100644 index 000000000..f90443e6d --- /dev/null +++ b/cookbooks/gps-tile/files/default/html/crossdomain.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/cookbooks/gps-tile/files/default/html/robots.txt b/cookbooks/gps-tile/files/default/html/robots.txt new file mode 100644 index 000000000..1f53798bb --- /dev/null +++ b/cookbooks/gps-tile/files/default/html/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: / diff --git a/cookbooks/gps-tile/recipes/default.rb b/cookbooks/gps-tile/recipes/default.rb index c0779f076..51f0fd411 100644 --- a/cookbooks/gps-tile/recipes/default.rb +++ b/cookbooks/gps-tile/recipes/default.rb @@ -44,7 +44,7 @@ git "/srv/gps-tile.openstreetmap.org/import" do group "gpstile" end -execute "import-make" do +execute "/srv/gps-tile.openstreetmap.org/import/src/Makefile" do action :nothing command "make" cwd "/srv/gps-tile.openstreetmap.org/import/src" @@ -61,7 +61,7 @@ git "/srv/gps-tile.openstreetmap.org/datamaps" do group "gpstile" end -execute "datamaps-make" do +execute "/srv/gps-tile.openstreetmap.org/datamaps/Makefile" do action :nothing command "make" cwd "/srv/gps-tile.openstreetmap.org/datamaps" @@ -78,8 +78,29 @@ git "/srv/gps-tile.openstreetmap.org/updater" do group "gpstile" end -directory "/srv/gps-tile.openstreetmap.org/html" do +template "/etc/init.d/gps-update" do + source "update.init.erb" + owner "root" + group "root" + mode 0755 +end + +#service "gps-update" do +# action [ :enable, :start ] +# supports :restart => true +# subscribes :restart, "git[/srv/gps-tile.openstreetmap.org/updater]" +#end + +remote_directory "/srv/gps-tile.openstreetmap.org/html" do + source "html" owner "gpstile" group "gpstile" mode 0755 + files_owner "gpstile" + files_group "gpstile" + mode 0644 +end + +apache_site "gps-tile.openstreetmap.org" do + template "apache.erb" end diff --git a/cookbooks/gps-tile/templates/default/apache.erb b/cookbooks/gps-tile/templates/default/apache.erb new file mode 100644 index 000000000..7572327c3 --- /dev/null +++ b/cookbooks/gps-tile/templates/default/apache.erb @@ -0,0 +1,34 @@ +# DO NOT EDIT - This file is being maintained by Chef + + + # Basic server configuration + ServerName <%= node[:fqdn] %> + ServerAlias gps-tile.openstreetmap.org + ServerAlias *.gps-tile.openstreetmap.org + ServerAdmin webmaster@openstreetmap.org + + # Configure location of static files + DocumentRoot /srv/gps-tile.openstreetmap.org/html + + # Configure the CGI script that serves the tiles + ScriptAlias /lines /srv/gps-tile.openstreetmap.org/updater/tile + + # Temporary redirect for old CGI location + RedirectPermanent /gps-lines/tile /lines + + # Setup logging + CustomLog /var/log/apache2/access.log combined + ErrorLog /var/log/apache2/error.log + BufferedLogs on + + # Always set Access-Control-Allow-Origin so that simple CORS requests + # will always work and can be cached + Header set Access-Control-Allow-Origin "*" + + + + Options None + AllowOverride None + Order allow,deny + Allow from all + diff --git a/cookbooks/gps-tile/templates/default/update.init.erb b/cookbooks/gps-tile/templates/default/update.init.erb new file mode 100644 index 000000000..724ecb164 --- /dev/null +++ b/cookbooks/gps-tile/templates/default/update.init.erb @@ -0,0 +1,24 @@ +#!/bin/bash + +# DO NOT EDIT - This file is being maintained by Chef + +start() { + start-stop-daemon --start --chuid gpstile --chdir /srv/gps-tile.openstreetmap.org --background --make-pidfile --pidfile /var/run/gps-update.pid --exec /src/gps-tile.openstreetmap.org/updater/update +} + +stop() { + start-stop-daemon --stop --retry 300 --pidfile /var/run/gps-update.pid +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + stop || exit $? + start + ;; +esac -- 2.43.2