Added exit code and regex

This commit is contained in:
Kevin Veen-Birkenbach 2022-04-05 18:24:02 +02:00
parent b31f8a4da8
commit 69bb10990e

View File

@ -1,6 +1,11 @@
#!/bin/bash
# Checks the healt of all btrfs volumes
exit_code=0
for path in $(btrfs filesystem show | awk '/ path /{print $NF}')
do
btrfs device stats $path
echo "Checking healt for $path..."
result=$(btrfs device stats $path)
echo "$result"
regex='\.(.*)_errs(\s*)[1-9]'
[[ "$result" =~ $regex ]] && echo "Errors found!" && exit_code=1;
done
exit $exit_code