live-build/functions/lockfile.sh

41 lines
744 B
Bash
Raw Normal View History

2007-09-23 08:04:46 +00:00
#!/bin/sh
# lockfile.sh - handle lock files
2007-09-23 08:04:48 +00:00
# Copyright (C) 2006-2007 Daniel Baumann <daniel@debian.org>
#
# live-helper comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
# This is free software, and you are welcome to redistribute it
# under certain conditions; see COPYING for details.
2007-09-23 08:04:46 +00:00
set -e
Check_lockfile ()
{
LOCKFILE="${1}"
# Checking lock file
if [ -f "${LOCKFILE}" ]
then
echo "E: system locked"
exit 1
fi
}
Create_lockfile ()
{
LOCKFILE="${1}"
LOCKDIRECTORY="`dirname ${1}`"
# Creating lock directory
if [ ! -d "${LOCKDIRECTORY}" ]
then
mkdir -p "${LOCKDIRECTORY}"
fi
2007-09-23 08:04:47 +00:00
# Creating lock trap
trap "test -f ${LOCKFILE} && rm -f ${LOCKFILE}; exit 0" 0 2 15
2007-09-23 08:04:46 +00:00
2007-09-23 08:04:47 +00:00
# Creating lock file
2007-09-23 08:04:46 +00:00
touch "${LOCKFILE}"
}