I'd like to see if there are any suggestions on how to improve a simple conditional test at the beginning of a backup script that verifies a ZFS volume is "online" and has the name "tank".
% zpool list NAME SIZE ALLOC FREE EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT tank 54.5T 36.0T 18.5T - 35% 66% 1.00x ONLINE -
The following simple script works, but I suspect there may be a more elegant way to do this. ShellCheck notes $STATUS is unused...
#!/bin/sh # STATUS=$(/sbin/zpool list | grep tank | grep ONLINE) if [ $? -gt 0 ]; then echo "Problems" exit 1 else echo all system go! exit 0 fi