1
0
zfs-test/bin/logs-to-table

68 lines
1.6 KiB
Bash
Executable File

#!/bin/sh
links=
linkprefix=
if [ "$1" = "--links" ]
then
links=true
if [ -n "$2" ]
then
linkprefix="$2"
fi
fi
# Write header
printf "| %s |" "Create script"
alignment="| :--- |"
# All create directories have the same filenames, just choose any one.
# from https://unix.stackexchange.com/a/156326
for copy in ../logs/"$(set -- ../logs/*; basename "$1")"/*
do
alignment="$alignment ---: |"
copy_name="$(basename "$copy")"
if [ "$copy_name" = "_create" ]
then
printf " %s |" "*orig*"
else
if [ -n "$links" ]
then
printf " %s |" "[$copy_name](${linkprefix}bin/copy-snapshot/$copy_name)"
else
printf " %s |" "$copy_name"
fi
fi
done
echo
echo "$alignment"
for create in ../logs/*
do
create_name="$(basename "$create")"
if [ -n "$links" ]
then
printf "| %s |" "[$create_name](${linkprefix}bin/create-test-setup/$create_name)"
else
printf "| %s |" "$create_name"
fi
used_base="$(cat "$create/_create/used")"
for copy in ../logs/"$create_name"/*
do
copy_name="$(basename "$copy")"
used="$(cat "$copy/used_h")"
if [ "$copy_name" = "_create" ]
then
printf " **%s** |" "$used"
else
used_num="$(cat "$copy/used")"
# Allow up to 24k overage to still get a checkmark.
if [ $((used_num - used_base)) -le 24576 ]
then
printf " %s✅ |" "$used"
else
printf " %s❌ |" "$used"
fi
fi
done
echo
done