live-build/functions/lockfile.sh

38 lines
678 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 ()
{
2007-09-23 08:04:49 +00:00
FILE="${1}"
2007-09-23 08:04:46 +00:00
# Checking lock file
2007-09-23 08:04:49 +00:00
if [ -f "${FILE}" ]
2007-09-23 08:04:46 +00:00
then
2007-09-23 08:04:49 +00:00
Echo_error "system locked"
2007-09-23 08:04:46 +00:00
exit 1
fi
}
Create_lockfile ()
{
2007-09-23 08:04:49 +00:00
FILE="${1}"
DIRECTORY="`dirname ${1}`"
2007-09-23 08:04:46 +00:00
# Creating lock directory
2007-09-23 08:05:11 +00:00
mkdir -p "${DIRECTORY}"
2007-09-23 08:04:46 +00:00
2007-09-23 08:04:47 +00:00
# Creating lock trap
2007-09-23 08:04:49 +00:00
trap "test -f ${FILE} && rm -f ${FILE}; exit 0" 0 1 2 3 9 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:49 +00:00
touch "${FILE}"
2007-09-23 08:04:46 +00:00
}