add way to change lock file for flock using second parameter

This commit is contained in:
Milan Meduna 2020-09-17 10:49:26 +02:00
parent cb7d9a4525
commit 305b08b544

View file

@ -1,6 +1,13 @@
#!/bin/bash
if [ -z "$2" ]
then
lock_variable="/var/lock/zfs-backup-mm"
else
lock_variable="$2"
fi
(
flock -n 200 || { echo 'locked via flock on file /var/lock/zfs-backup-mm' ; exit 1; }
flock -n 200 || { echo "locked via flock on file $lock_variable" ; exit 1; }
zfsnap_block () {
@ -83,4 +90,5 @@ if [[ $# -eq 0 ]] ; then
fi
source $1
zfsnap_block
) 200>/var/lock/zfs-backup-mm
) 200>$lock_variable