source: live-build/trunk/fuentes/functions/lockfile.sh @ 900

Last change on this file since 900 was 900, checked in by kbut, 3 years ago

add original source

  • Property svn:executable set to *
File size: 840 bytes
Line 
1#!/bin/sh
2
3## live-build(7) - System Build Scripts
4## Copyright (C) 2006-2012 Daniel Baumann <daniel@debian.org>
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.
9
10
11Check_lockfile ()
12{
13        FILE="${1}"
14
15        if [ -z "${FILE}" ]
16        then
17                FILE="/var/lock/${PROGRAM}.lock"
18        fi
19
20        # Checking lock file
21        if [ -f "${FILE}" ]
22        then
23                Echo_error "${PROGRAM} locked"
24                exit 1
25        fi
26}
27
28Create_lockfile ()
29{
30        FILE="${1}"
31
32        if [ -z "${FILE}" ]
33        then
34                FILE="/var/lock/${PROGRAM}.lock"
35        fi
36
37        DIRECTORY="$(dirname ${FILE})"
38
39        # Creating lock directory
40        mkdir -p "${DIRECTORY}"
41
42        # Creating lock trap
43        trap 'ret=${?}; '"rm -f \"${FILE}\";"' exit ${ret}' EXIT HUP INT QUIT TERM
44
45        # Creating lock file
46        touch "${FILE}"
47}
Note: See TracBrowser for help on using the repository browser.