Skip to content

Commit

Permalink
Fix deletion of partly matching datasets
Browse files Browse the repository at this point in the history
The delete command deleted partly matching dataset, for example
ISOs with the same name as the guest.
Changed it to exactly match the guestname.
  • Loading branch information
moogle19 committed Apr 25, 2016
1 parent f674686 commit 11658ff
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/ioh-guest
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,8 @@ __delete() {
local flagone="$2"
local flagtwo="$3"
if [ $flagone = "-f" ]; then
local target_dataset="$(zfs list -H -t filesystem -o name | grep iohyve | grep $flagtwo | head -n1)"
local pool="$(zfs list -H -t volume | grep iohyve/$flagtwo | cut -d '/' -f 1 | head -n1)"
local target_dataset="$pool/iohyve/$flagtwo"
echo ""
echo "[WARNING] Forcing permanent deletion of $flagtwo"
echo "Location: $target_dataset including children and clones"
Expand All @@ -586,7 +587,8 @@ __delete() {
echo "Deleting $flagtwo at $target_dataset..."
zfs destroy -rR $target_dataset
else
local target_dataset="$(zfs list -H -t filesystem -o name | grep iohyve | grep $flagone | head -n1)"
local pool="$(zfs list -H -t volume | grep iohyve/$flagone | cut -d '/' -f 1 | head -n1)"
local target_dataset="$pool/iohyve/$flagone"
echo ""
echo "[WARNING] Are you sure you want to permanently delete $flagone and all child datasets?"
read -p "Location: $target_dataset [Y/N]? " an </dev/tty
Expand Down

0 comments on commit 11658ff

Please sign in to comment.