]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/nominatim/templates/default/nominatim-update.erb
nominatim: complete rework of the setup
[chef.git] / cookbooks / nominatim / templates / default / nominatim-update.erb
diff --git a/cookbooks/nominatim/templates/default/nominatim-update.erb b/cookbooks/nominatim/templates/default/nominatim-update.erb
new file mode 100644 (file)
index 0000000..9f12220
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+# DO NOT EDIT - This file is being maintained by Chef
+
+date "+%c === Starting Nominatim update cycle"
+
+starttime=`date +%s`
+
+<% if node[:nominatim][:enable_git_updates] -%>
+if /sbin/runuser -u nominatim -- <%= @bindir %>/nominatim-update-source; then
+  pushd <%= @builddir %>
+  make install
+
+  if ! /sbin/runuser -u nominatim -- <%= @bindir %>/nominatim-update-refresh-db; then
+    date "+%c === Database refresh failed. Stopping updates."
+    exit 1
+  fi
+fi
+<% end -%>
+
+if ! /sbin/runuser -u nominatim -- <%= @bindir %>/nominatim-update-data; then
+  date "+%c === Data update failed. Stopping updates."
+  exit 1
+fi
+
+date "+%c === Nominatim update cycle finished"
+
+# sleep a bit if updates take less than a minute
+endtime=`date +%s`
+elapsed=$((endtime - starttime))
+if [[ $elapsed -lt 60 ]]; then
+  sleepy=$((60 - $elapsed))
+  date "+%c === Sleeping for ${sleepy}s..."
+  sleep $sleepy
+fi