~vorlon/live-build/cloud-images-ppc64el

« back to all changes in this revision

Viewing changes to functions/lockfile.sh

  • Committer: Daniel Baumann
  • Date: 2011-03-09 17:14:51 UTC
  • Revision ID: git-v1:fe6eb1c593e2df135c8807bf94df614984b4d6ec
Adding live-helper 1.0~a1-1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
# lockfile.sh - handle lock files
 
4
 
 
5
set -e
 
6
 
 
7
Check_lockfile ()
 
8
{
 
9
        LOCKFILE="${1}"
 
10
 
 
11
        # Checking lock file
 
12
        if [ -f "${LOCKFILE}" ]
 
13
        then
 
14
                echo "E: system locked"
 
15
                exit 1
 
16
        fi
 
17
}
 
18
 
 
19
Create_lockfile ()
 
20
{
 
21
        LOCKFILE="${1}"
 
22
        LOCKDIRECTORY="`dirname ${1}`"
 
23
 
 
24
        # Creating lock directory
 
25
        if [ ! -d "${LOCKDIRECTORY}" ]
 
26
        then
 
27
                mkdir -p "${LOCKDIRECTORY}"
 
28
        fi
 
29
 
 
30
        # Creating lock file
 
31
        trap "test -f ${LOCKFILE} && \
 
32
        rm -f ${LOCKFILE}; exit 0" 0 2 15
 
33
 
 
34
        touch "${LOCKFILE}"
 
35
}