Adding lb_bootstrap_hooks manpage.
[debian-live-build.git] / functions / lockfile.sh
blob7a310770984136348a78584e7044bc597f504e52
1 #!/bin/sh
3 ## live-build(7) - System Build Scripts
4 ## Copyright (C) 2006-2013 Daniel Baumann <mail@daniel-baumann.ch>
5 ##
6 ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
7 ## This is free software, and you are welcome to redistribute it
8 ## under certain conditions; see COPYING for details.
11 Check_lockfile ()
13 FILE="${1}"
15 if [ -z "${FILE}" ]
16 then
17 FILE="/var/lock/${PROGRAM}.lock"
20 # Checking lock file
21 if [ -f "${FILE}" ]
22 then
23 Echo_error "${PROGRAM} locked"
24 exit 1
28 Create_lockfile ()
30 FILE="${1}"
32 if [ -z "${FILE}" ]
33 then
34 FILE="/var/lock/${PROGRAM}.lock"
37 DIRECTORY="$(dirname ${FILE})"
39 # Creating lock directory
40 mkdir -p "${DIRECTORY}"
42 # Creating lock trap
43 trap 'ret=${?}; '"rm -f \"${FILE}\";"' exit ${ret}' EXIT HUP INT QUIT TERM
45 # Creating lock file
46 touch "${FILE}"