From 90cf65550143edb0003250f509f3d07670648ee5 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 18 Jun 2020 18:47:09 +0100 Subject: [PATCH] Wrap DNS updates with a lock to avoid conflicts --- cookbooks/dns/recipes/default.rb | 1 + cookbooks/dns/templates/default/dns-check.erb | 4 ++++ cookbooks/dns/templates/default/dns-update.erb | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/cookbooks/dns/recipes/default.rb b/cookbooks/dns/recipes/default.rb index 3f44b7fa0..2f045a778 100644 --- a/cookbooks/dns/recipes/default.rb +++ b/cookbooks/dns/recipes/default.rb @@ -34,6 +34,7 @@ package %w[ libyaml-libyaml-perl libwww-perl libjson-xs-perl + lockfile-progs sshfp ] diff --git a/cookbooks/dns/templates/default/dns-check.erb b/cookbooks/dns/templates/default/dns-check.erb index 0c88edf42..00b97aa60 100755 --- a/cookbooks/dns/templates/default/dns-check.erb +++ b/cookbooks/dns/templates/default/dns-check.erb @@ -5,4 +5,8 @@ export STATUSCAKE_USERNAME="OpenStreetMap" export STATUSCAKE_APIKEY="<%= @passwords["statuscake"] %>" export PATH=/usr/local/bin:$PATH +lockfile-create --use-pid /var/lib/dns/update || exit 1 + make --quiet --jobs --directory=/var/lib/dns update > /dev/null + +lockfile-remove /var/lib/dns/update diff --git a/cookbooks/dns/templates/default/dns-update.erb b/cookbooks/dns/templates/default/dns-update.erb index 4da924be0..5353d69d4 100755 --- a/cookbooks/dns/templates/default/dns-update.erb +++ b/cookbooks/dns/templates/default/dns-update.erb @@ -11,6 +11,8 @@ export PATH=/usr/local/bin:$PATH cd /var/lib/dns +lockfile-create --use-pid update || exit 1 + if [ ! -d .git ] then git clone /var/lib/git/public/dns.git /var/lib/dns @@ -19,3 +21,5 @@ fi git pull -q make --jobs update + +lockfile-remove update -- 2.39.5