anchor.diff:    echo "Lock file exists"
     exit 0
   fi
  -trap 'rm $LOCK_FILE && fail' EXIT 1 2 3
  +trap 'fail $? && rm $LOCK_FILE' EXIT 1 2 3
  +set -e
   
   export PATH=$PATH:/usr/sbin:/usr/local/bin
   export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
  
positive.code: #!/bin/bash
  set -e
  
  function mv_stamp() {
    local b=$(basename ${1})
    mv ${1} ${b%.*}_${2}.${b##*.}
  
negative.code: }
  
  function fail() {
    if [[ $1 -ne 0 ]]; then
      /usr/sbin/sendmail -t - << EOF
  to:<%= node[:valhalla][:to_email] %>
  from:<%= node[:valhalla][:from_email] %>
  subject:Cut tiles failed!
  
  $(tail -n 100 <%= node[:valhalla][:log_dir] %>/cut_tiles.log)
  EOF
    fi
  }
  
  # make sure only one is running at any time...
  LOCK_FILE="<%= node[:valhalla][:lock_dir] %>/cut_tiles.lock"
  