Added locking system

* locking.sh with acquire and release functions
* refactored die function for handling optionally
  rollback, tempdir removal and error message