From 36a33c32a094f65900d04b7e75ae828622561f92 Mon Sep 17 00:00:00 2001 From: Adar Nimrod <nimrod@shore.co.il> Date: Sat, 13 Mar 2021 19:05:15 +0200 Subject: [PATCH] Handle cases where there are no btrfs volumes. --- roles/debian_server/files/btrfs-scrub | 3 +++ 1 file changed, 3 insertions(+) diff --git a/roles/debian_server/files/btrfs-scrub b/roles/debian_server/files/btrfs-scrub index ac980d3..28e1240 100755 --- a/roles/debian_server/files/btrfs-scrub +++ b/roles/debian_server/files/btrfs-scrub @@ -5,6 +5,9 @@ for mp in $(lsblk --list --noheadings --output fstype,mountpoint | \ awk '$1 == "btrfs" {print $2}' | \ sort -u) do + # In case there are no btrfs volumes, the for loop will execute once with an + # empty string for mp. Validate that indeed we're passed a mountpoint. + [ -d "$mp" ] || continue status="$(btrfs scrub status "$mp" | awk '$1 == "Status:" {print $2}')" if [ "$status" = 'running' ] then -- GitLab