add way to change lock file for flock using second parameter

This commit is contained in:
root 2020-08-21 11:45:31 +02:00
parent 0402f47302
commit 2a56c7c761

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 () {
@ -78,4 +85,4 @@ if [[ $# -eq 0 ]] ; then
fi
source $1
zfsnap_block
) 200>/var/lock/zfs-backup-mm
) 200>$lock_variable