qemu: tpm: do not update profile name for transient domains
[libvirt.git] / tools / virt-sanlock-cleanup.in
blob6551b0476f92624960cc3036d8a4e78150947842
1 #!/bin/sh
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/>.
22 verbose=1
23 if test "x$1" = "x-q" ; then
24 verbose=0
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"
35 notify() {
36 test $verbose = 1 || return
37 if test "x$1" = "x-n"; then
38 shift
39 printf %s "$*"
40 else
41 printf %s\\n "$*"
45 cd "$LOCKDIR" || exit 1
47 for MD5 in *
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
53 if test $? = 0 ; then
54 notify "PASS"
55 else
56 notify "FAIL"
59 done
61 exit 0