daemon: Move TLS initialization to virInitialize
[libvirt/zwu.git] / tools / virt-sanlock-cleanup.in
blobd8a40a59b124cd12c53295da93625417fa5412df
1 #!/bin/sh
3 # A script to cleanup resource leases auto-created by
4 # the libvirt lock plugin for sanlock
6 verbose=1
7 if test "x$1" = "x-q" ; then
8 verbose=0
9 fi
11 LOCKSPACE="__LIBVIRT__DISKS__"
13 LOCKDIR=`augtool print '/files@SYSCONFDIR@/libvirt/qemu-sanlock.conf/disk_lease_dir'`
14 if test $? != 0 || "x$LOCKDIR" = "x" ; then
15 LOCKDIR="@LOCALSTATEDIR@/lib/libvirt/sanlock"
18 notify() {
19 test $verbose = 1 || return
20 if test "x$1" = "x-n"; then
21 shift
22 printf %s "$*"
23 else
24 printf %s\\n "$*"
28 cd "$LOCKDIR" || exit 1
30 for MD5 in *
32 if test $MD5 != '*' && $MD5 != $LOCKSPACE ; then
33 RESOURCE="$LOCKSPACE:$MD5:$LOCKDIR/$MD5:0"
34 notify -n "Cleanup: $RESOURCE "
35 sanlock client command -r $RESOURCE -c /bin/rm -f "$LOCKDIR/$MD5" 2>/dev/null
36 if test $? = 0 ; then
37 notify "PASS"
38 else
39 notify "FAIL"
42 done
44 exit 0
46 : <<=cut
47 =pod
49 =head1 NAME
51 virt-sanlock-cleanup - remove stale sanlock resource lease files
53 =head1 SYNOPSIS
55 virt-sanlock-cleanup
57 =head1 DESCRIPTION
59 This tool removes any resource lease files created by the sanlock
60 lock manager plugin. The resource lease files only need to exist
61 on disks when a guest using the resource is active. This script
62 reclaims the disk space used by resources which are not currently
63 active.
65 =head1 EXIT STATUS
67 Upon successful processing of leases cleanup, the exit status
68 will be 0 will be set. Upon fatal error a non-zero status will
69 be set.
71 =head1 AUTHOR
73 Daniel Berrange
75 =head1 BUGS
77 Report any bugs discovered to the libvirt community via the
78 mailing list C<http://libvirt.org/contact.html> or bug tracker C<http://libvirt.org/bugs.html>.
79 Alternatively report bugs to your software distributor / vendor.
81 =head1 COPYRIGHT
83 Copyright (C) 2011 Red Hat, Inc.
85 =head1 LICENSE
87 virt-sanlock-cleanup is distributed under the terms of the GNU GPL v2+.
88 This is free software; see the source for copying conditions. There
89 is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
90 PURPOSE
92 =head1 SEE ALSO
94 C<virsh(1)>, online instructions C<http://libvirt.org/locksanlock.html>
96 =cut