]> git.openstreetmap.org Git - chef.git/commitdiff
Use trap to release lock
authorMatt Amos <zerebubuth@gmail.com>
Sun, 21 Dec 2014 17:21:24 +0000 (17:21 +0000)
committerTom Hughes <tom@compton.nu>
Mon, 22 Dec 2014 14:28:20 +0000 (14:28 +0000)
cookbooks/planet/templates/default/planetdump.erb

index 068ce5d5fd09d0f0d85d14ac1cd1311af506382c..4d5bac02ce64c61e90de2214ab8a8f828b3dfb1e 100644 (file)
@@ -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