feat(script): List all snappable datasets (#1)

This commit is contained in:
hygienic-books 2023-03-06 00:32:58 +01:00
parent 8dca85c98f
commit 7427d8477f

View File

@ -43,6 +43,20 @@ function set_severity () {
fi fi
} }
function get_globally_snappable_datasets () {
local datasets_list
# For all datasets show their 'space.quico:auto-snapshot' property; only
# print dataset name in column 1 and property value in column 2. In awk
# limit this list to datasets where tab-delimited column 2 has exact
# string '^true$' then further limit output by eliminating snapshots
# from list, i.e. dataset names that contain an '@' character.
datasets_list="$(zfs get -H -o 'name,value' 'space.quico:auto-snapshot' | \
awk -F'\t' '{if($2 ~ /^true$/ && $1 !~ /@/) print $1}')"
while IFS= read -r dataset; do
globally_snappable_datasets+=("${dataset}")
done <<<"${datasets_list}"
}
function write_pkg_list_oneline () { function write_pkg_list_oneline () {
local unabridged_pkg_list_oneline local unabridged_pkg_list_oneline
if [[ "${severity}" == 'imp' ]]; then if [[ "${severity}" == 'imp' ]]; then
@ -75,6 +89,9 @@ function main () {
local severity local severity
set_severity set_severity
local -a globally_snappable_datasets
get_globally_snappable_datasets
local pkg_list_oneline local pkg_list_oneline
write_pkg_list_oneline write_pkg_list_oneline