From: Matt Amos Date: Sun, 21 Dec 2014 17:21:24 +0000 (+0000) Subject: Use trap to release lock X-Git-Url: https://git.openstreetmap.org./chef.git/commitdiff_plain/a1f3d00ab0e8f8139a4d264c381108730d4f4189 Use trap to release lock --- diff --git a/cookbooks/planet/templates/default/planetdump.erb b/cookbooks/planet/templates/default/planetdump.erb index 068ce5d5f..4d5bac02c 100644 --- a/cookbooks/planet/templates/default/planetdump.erb +++ b/cookbooks/planet/templates/default/planetdump.erb @@ -26,6 +26,14 @@ fi # Create Lock echo $$ > /tmp/planetdump.lock +function cleanup { + # Release lock + rm /tmp/planetdump.lock +} + +# Remove lock on exit +trap cleanup EXIT + # Change to working directory cd /store/planetdump @@ -56,6 +64,3 @@ do md5sum "#{file}" > "#{file}.md5" mv "${file}" "${file}.md5" "/store/planet/pbf" done - -# Release lock -rm /tmp/planetdump.lock