From c07fd635be75c7831509cdcdd1ec4618da4acb3a Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 7 Dec 2019 10:34:26 +0200 Subject: Fix: logic --- remove-vm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'remove-vm') diff --git a/remove-vm b/remove-vm index 9d1e940..77880d7 100755 --- a/remove-vm +++ b/remove-vm @@ -30,11 +30,12 @@ remove_vm() lvpath="/dev/$vg/$name" if [ -e "$lvpath" ] then - sudo lvremove --force "$lvpath" - else - # In case the LV was kpartx'd, undo that - sudo kpartx -dsv "$lvpath" - sudo lvremove --force "$lvpath" + if ! sudo lvremove --force "$lvpath" + then + # In case the LV was kpartx'd, undo that + sudo kpartx -dsv "$lvpath" + sudo lvremove --force "$lvpath" + fi fi # Remove the host from /etc/hosts, if there. -- cgit v1.2.1