Skip to content

Commit

Permalink
disk-deactivate: only run zfs command if they are present
Browse files Browse the repository at this point in the history
  • Loading branch information
Mic92 committed Sep 3, 2024
1 parent 37c83c0 commit c789d11
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions disk-deactivate/disk-deactivate.jq
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# since lsblk lacks zfs support, we have to do it this way
def remove:
if .fstype == "zfs_member" then
"zpool destroy -f \(.label)"
"if type zpool >/dev/null; then zpool destroy -f \(.label); fi"
elif .fstype == "LVM2_member" then
[
"vg=$(pvs \(.path) --noheadings --options vg_name | grep -o '[a-zA-Z0-9-]*')",
Expand All @@ -14,7 +14,7 @@ def remove:
# maybe its zfs
[
# the next line has some horrible escaping
"zpool=$(zdb -l \(.path) | sed -nr $'s/ +name: \\'(.*)\\'/\\\\1/p')",
"zpool=$(if type zdb >/dev/null; then zdb -l \(.path) | sed -nr $'s/ +name: \\'(.*)\\'/\\\\1/p') else echo ""; fi",
"if [[ -n \"${zpool}\" ]]; then zpool destroy -f \"$zpool\"; fi",
"unset zpool"
]
Expand Down

0 comments on commit c789d11

Please sign in to comment.