Manage generation of users_agreed and users_disagreed
authorTom Hughes <tom@compton.nu>
Tue, 16 Jul 2013 08:20:13 +0000 (09:20 +0100)
committerTom Hughes <tom@compton.nu>
Tue, 16 Jul 2013 08:21:55 +0000 (09:21 +0100)
cookbooks/planet/files/default/replication-bin/users-agreed [new file with mode: 0644]
cookbooks/planet/recipes/replication.rb
cookbooks/planet/templates/default/replication.cron.erb
cookbooks/planet/templates/default/users-agreed.conf.erb [new file with mode: 0644]

diff --git a/cookbooks/planet/files/default/replication-bin/users-agreed b/cookbooks/planet/files/default/replication-bin/users-agreed
new file mode 100644 (file)
index 0000000..1aa0c1b
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+# DO NOT EDIT - This file is being maintained by Chef
+
+T=$(mktemp -d -t -p /var/tmp users.XXXXXXXXXX)
+
+export PGPASSFILE=/etc/replication/users-agreed.conf
+
+echo "# user IDs < 286582 who have agreed to the contributor terms. " > $T/users_agreed
+echo "# any active user IDs >= 286582 would have agreed as part of the sign-up process." >> $T/users_agreed
+psql -h db -U planetdiff -t -c "select id from users where id < 286582 and terms_agreed is not null order by id asc" openstreetmap >> $T/users_agreed
+
+psql -h db -U planetdiff -t -c "select id from users where terms_seen and terms_agreed is null order by id asc" openstreetmap > $T/users_disagreed
+
+if cmp -s "${T}/users_agreed" "/store/planet/users_agreed/users_agreed.txt"; then
+  : # do nothing
+else
+  cp $T/users_agreed /store/planet/users_agreed/users_agreed.txt
+fi
+
+if cmp -s "${T}/users_disagreed" "/store/planet/users_agreed/users_disagreed.txt"; then
+  : #  do nothing
+else
+  cp $T/users_disagreed /store/planet/users_agreed/users_disagreed.txt
+fi
+
+rm -rf $T
index c2055e4ebc1099f6c208d4d15a0ca3a831ebbb30..28ca79a335c95c217a096d64eefb2788e9e75af0 100644 (file)
@@ -94,6 +94,14 @@ template "/etc/replication/changesets.conf" do
   variables :password => db_passwords["planetdiff"]
 end
 
+template "/etc/replication/users-agreed.conf" do
+  source "users-agreed.conf.erb"
+  user "root"
+  group "planet"
+  mode 0640
+  variables :password => db_passwords["planetdiff"]
+end
+
 directory "/var/lib/replication" do
   owner "planet"
   group "planet"
index cb019c0fbe45e40c9071059ed88da136ee862f1d..439de398348f9905e232c106208626be7e6d3c4a 100644 (file)
@@ -10,4 +10,5 @@ MAILTO=brett@bretth.com
 
 MAILTO=zerebubuth@gmail.com
 
+0 7 * * * planet /usr/local/bin/users-agreed
 * * * * * planet /usr/local/bin/replicate-changesets /etc/replication/changesets.conf
diff --git a/cookbooks/planet/templates/default/users-agreed.conf.erb b/cookbooks/planet/templates/default/users-agreed.conf.erb
new file mode 100644 (file)
index 0000000..c6dd2ff
--- /dev/null
@@ -0,0 +1,3 @@
+# DO NOT EDIT - This file is being maintained by Chef
+
+db:5432:openstreetmap:planetdiff:<%= @password %>