30 lines
894 B
Bash
30 lines
894 B
Bash
progress() {
|
|
value=$1
|
|
width=10
|
|
step_size=$((100 / $width))
|
|
num_of_progress_items=$(($value / $step_size))
|
|
|
|
printf '['
|
|
# if >= 90%, make it red
|
|
if [ $value -ge 90 ]; then printf '\033[1;31m'; fi
|
|
for i in $(seq 0 $width); do
|
|
[ $i -le $num_of_progress_items ] && printf '■' || printf ' '
|
|
done
|
|
printf '\033[0m' # reset color
|
|
printf ']'
|
|
}
|
|
|
|
space=$(zfs get -Ho value used,quota $HOME | paste - -)
|
|
used=$(echo $space | awk '{ print $1 }')
|
|
quota=$(echo $space | awk '{ print $2 }')
|
|
|
|
space_raw=$(zfs get -Hpo value used,quota $HOME | paste - -)
|
|
used_raw=$(echo $space_raw | awk '{ print $1 }')
|
|
quota_raw=$(echo $space_raw | awk '{ print $2 }')
|
|
pcent=$(((used_raw * 100) / quota_raw))
|
|
|
|
echo
|
|
echo "Welcome to your LayerZero backup server! ^(;.;)^"
|
|
echo "Use the command `man suggestions` to see what you can do."
|
|
echo "Your quota usage: $used / $quota $(progress $pcent) $pcent%"
|
|
echo
|