#!/bin/bash

set -x

export EMAIL_FILE=/root/filesystem-usage-email.txt
export EMAIL_TO=admin@ducoterra.net

printf "Subject: Driveripper Filesystem Usage\n\nTo: ${EMAIL_TO}\n\n" > ${EMAIL_FILE}

printf "Pool 0\n" >> ${EMAIL_FILE}
btrfs filesystem usage /btrfs/pool0 >> ${EMAIL_FILE}

printf "\nPool 1\n" >> ${EMAIL_FILE}
btrfs filesystem usage /btrfs/pool1 >> ${EMAIL_FILE}

printf "\nBackup 0\n" >> ${EMAIL_FILE}
btrfs filesystem usage /btrfs/backup0 >> ${EMAIL_FILE}

cat ${EMAIL_FILE} | msmtp ${EMAIL_TO}