From 40851f9e0d229e00f1699a913d9b29a95ae4c496 Mon Sep 17 00:00:00 2001 From: Simon Poole Date: Wed, 5 Sep 2018 15:20:11 +0200 Subject: [PATCH] Add a script to generate a list of deleted users uids --- cookbooks/planet/recipes/replication.rb | 7 +++++++ .../templates/default/replication.cron.erb | 1 + .../templates/default/users-deleted.erb | 19 +++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 cookbooks/planet/templates/default/users-deleted.erb diff --git a/cookbooks/planet/recipes/replication.rb b/cookbooks/planet/recipes/replication.rb index feedac7da..770d52c7c 100644 --- a/cookbooks/planet/recipes/replication.rb +++ b/cookbooks/planet/recipes/replication.rb @@ -69,6 +69,13 @@ template "/usr/local/bin/users-agreed" do mode 0o755 end +template "/usr/local/bin/users-deleted" do + source "users-deleted.erb" + owner "root" + group "root" + mode 0o755 +end + remote_directory "/store/planet/replication" do source "replication-cgi" owner "root" diff --git a/cookbooks/planet/templates/default/replication.cron.erb b/cookbooks/planet/templates/default/replication.cron.erb index 5300781be..0ccffdd1e 100644 --- a/cookbooks/planet/templates/default/replication.cron.erb +++ b/cookbooks/planet/templates/default/replication.cron.erb @@ -5,6 +5,7 @@ TZ=UTC MAILTO=zerebubuth@gmail.com 0 7 * * * planet /usr/local/bin/users-agreed +0 17 * * * planet /usr/local/bin/users-deleted * * * * * planet /usr/local/bin/replicate-changesets /etc/replication/changesets.conf MAILTO=brett@bretth.com diff --git a/cookbooks/planet/templates/default/users-deleted.erb b/cookbooks/planet/templates/default/users-deleted.erb new file mode 100644 index 000000000..6360d28c6 --- /dev/null +++ b/cookbooks/planet/templates/default/users-deleted.erb @@ -0,0 +1,19 @@ +#!/bin/sh + +# DO NOT EDIT - This file is being maintained by Chef + +T=$(mktemp -d -t -p /var/tmp users.XXXXXXXXXX) + +# use the same as for the users-agreed template +export PGPASSFILE=/etc/replication/users-agreed.conf + +echo "# user IDs of deleted users. " > $T/users_deleted +psql -h <%= node[:web][:readonly_database_host] %> -U planetdiff -t -c "select id from users where status='deleted' by id asc" openstreetmap >> $T/users_deleted + +if cmp -s "${T}/users_deleted "/store/planet/users_deleted.txt"; then + : # do nothing +else + cp $T/users_deleted /store/planet/users_deleted.txt +fi + +rm -rf $T -- 2.39.5