[libvirt] [PATCH] virt-sanlock-cleanup; Fix augtool usage

Surprisingly, augtool get (or print) returns "path = value" while we are only interested in the value. We need to remove the "path = " part from the augtool's output. The following is an example of the augtool command as used in virt-sanlock-cleanup script: $ augtool get /files/etc/libvirt/qemu-sanlock.conf/disk_lease_dir /files/etc/libvirt/qemu-sanlock.conf/disk_lease_dir = /var/lib/libvirt/sanlock --- tools/virt-sanlock-cleanup.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/virt-sanlock-cleanup.in b/tools/virt-sanlock-cleanup.in index e0e8083..9855f42 100644 --- a/tools/virt-sanlock-cleanup.in +++ b/tools/virt-sanlock-cleanup.in @@ -26,7 +26,8 @@ fi LOCKSPACE="__LIBVIRT__DISKS__" -LOCKDIR=`augtool print '/files@sysconfdir@/libvirt/qemu-sanlock.conf/disk_lease_dir'` +LOCKDIR=`augtool get '/files@sysconfdir@/libvirt/qemu-sanlock.conf/disk_lease_dir'` +LOCKDIR=${LOCKDIR#* = } if test $? != 0 || test "x$LOCKDIR" = "x" ; then LOCKDIR="@localstatedir@/lib/libvirt/sanlock" fi -- 1.8.3.2

On Wed, Aug 28, 2013 at 13:54:29 +0200, Jiri Denemark wrote:
Surprisingly, augtool get (or print) returns "path = value" while we are only interested in the value. We need to remove the "path = " part from the augtool's output. The following is an example of the augtool command as used in virt-sanlock-cleanup script:
$ augtool get /files/etc/libvirt/qemu-sanlock.conf/disk_lease_dir /files/etc/libvirt/qemu-sanlock.conf/disk_lease_dir = /var/lib/libvirt/sanlock --- tools/virt-sanlock-cleanup.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/virt-sanlock-cleanup.in b/tools/virt-sanlock-cleanup.in index e0e8083..9855f42 100644 --- a/tools/virt-sanlock-cleanup.in +++ b/tools/virt-sanlock-cleanup.in @@ -26,7 +26,8 @@ fi
LOCKSPACE="__LIBVIRT__DISKS__"
-LOCKDIR=`augtool print '/files@sysconfdir@/libvirt/qemu-sanlock.conf/disk_lease_dir'` +LOCKDIR=`augtool get '/files@sysconfdir@/libvirt/qemu-sanlock.conf/disk_lease_dir'` +LOCKDIR=${LOCKDIR#* = }
I'm not sure if this is a bashism or not but in case it is, we may need to filter the output with sed instead: LOCKDIR=`augtool get '/files@sysconfdir@/libvirt/qemu-sanlock.conf/disk_lease_dir' \ | sed -e 's/.* = //'` Jirka

On 08/28/2013 05:58 AM, Jiri Denemark wrote:
+++ b/tools/virt-sanlock-cleanup.in @@ -26,7 +26,8 @@ fi
LOCKSPACE="__LIBVIRT__DISKS__"
-LOCKDIR=`augtool print '/files@sysconfdir@/libvirt/qemu-sanlock.conf/disk_lease_dir'` +LOCKDIR=`augtool get '/files@sysconfdir@/libvirt/qemu-sanlock.conf/disk_lease_dir'` +LOCKDIR=${LOCKDIR#* = }
I'm not sure if this is a bashism or not but in case it is, we may need to filter the output with sed instead:
LOCKDIR=`augtool get '/files@sysconfdir@/libvirt/qemu-sanlock.conf/disk_lease_dir' \ | sed -e 's/.* = //'`
Fortunately, ${foo#pattern} is portable to POSIX, so you are just fine doing it in shell without needing a sed. ACK to the original version. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Wed, Aug 28, 2013 at 06:38:26 -0600, Eric Blake wrote:
On 08/28/2013 05:58 AM, Jiri Denemark wrote:
+++ b/tools/virt-sanlock-cleanup.in @@ -26,7 +26,8 @@ fi
LOCKSPACE="__LIBVIRT__DISKS__"
-LOCKDIR=`augtool print '/files@sysconfdir@/libvirt/qemu-sanlock.conf/disk_lease_dir'` +LOCKDIR=`augtool get '/files@sysconfdir@/libvirt/qemu-sanlock.conf/disk_lease_dir'` +LOCKDIR=${LOCKDIR#* = }
I'm not sure if this is a bashism or not but in case it is, we may need to filter the output with sed instead:
LOCKDIR=`augtool get '/files@sysconfdir@/libvirt/qemu-sanlock.conf/disk_lease_dir' \ | sed -e 's/.* = //'`
Fortunately, ${foo#pattern} is portable to POSIX, so you are just fine doing it in shell without needing a sed.
ACK to the original version.
Pushed, thanks. Jirka
participants (2)
-
Eric Blake
-
Jiri Denemark