aboutsummaryrefslogtreecommitdiff
path: root/lib/beam/common.in
diff options
context:
space:
mode:
Diffstat (limited to 'lib/beam/common.in')
-rw-r--r--lib/beam/common.in17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/beam/common.in b/lib/beam/common.in
index 1be075e..7e69640 100644
--- a/lib/beam/common.in
+++ b/lib/beam/common.in
@@ -30,6 +30,7 @@ backup_archive_dir=
backup_snapshot_dir=
backup_verbose=
backup_logfile="/var/log/backup"
+backup_pidfile="/var/run/beam.pid"
backup_tmp_dir=/tmp
error() {
@@ -47,6 +48,22 @@ abend() {
exit $ec
}
+beam_lock() {
+ if [ -r $backup_pidfile ]; then
+ pid=$(head -n 1 $backup_pidfile)
+ if [ -z "$pid" ]; then
+ abend "pidfile $backup_pidfile exists but is unreadable or empty"
+ fi
+ abend "another beam process (pid $backup_pid) is still running; exiting"
+ fi
+ echo $$ > $backup_pidfile || exit 1
+ epilogue_hook="$epilogue_hook beam_unlock"
+}
+
+beam_unlock() {
+ rm -f $backup_pidfile
+}
+
tarcode() {
case $1 in
0) logit "success";;

Return to:

Send suggestions and report system problems to the System administrator.