3 # A script to cleanup resource leases auto-created by
4 # the libvirt lock plugin for sanlock
6 # Copyright (C) 2011, 2013 Red Hat, Inc.
8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public
10 # License as published by the Free Software Foundation; either
11 # version 2.1 of the License, or (at your option) any later version.
13 # This library is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Lesser General Public License for more details.
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with this library. If not, see
20 # <http://www.gnu.org/licenses/>.
23 if test "x$1" = "x-q" ; then
27 LOCKSPACE
="__LIBVIRT__DISKS__"
29 LOCKDIR
=`augtool get '/files@sysconfdir@/libvirt/qemu-sanlock.conf/disk_lease_dir'`
30 LOCKDIR
=${LOCKDIR#* = }
31 if test $?
!= 0 ||
test "x$LOCKDIR" = "x" ; then
32 LOCKDIR
="@localstatedir@/lib/libvirt/sanlock"
36 test $verbose = 1 ||
return
37 if test "x$1" = "x-n"; then
45 cd "$LOCKDIR" ||
exit 1
49 if test $MD5 != '*' && test $MD5 != $LOCKSPACE ; then
50 RESOURCE
="$LOCKSPACE:$MD5:$LOCKDIR/$MD5:0"
51 notify
-n "Cleanup: $RESOURCE "
52 sanlock client
command -r $RESOURCE -c /bin
/rm -f "$LOCKDIR/$MD5" 2>/dev
/null