From d00a100aa1fc721e992f81849417942ec14bd56c Mon Sep 17 00:00:00 2001
From: root <root@pontos06.fi.muni.cz>
Date: Sat, 14 Dec 2019 10:16:22 +0100
Subject: [PATCH] Fix dfwatch on Debian (no mail)

---
 bin/dfwatch | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/bin/dfwatch b/bin/dfwatch
index a5764fc..36922c2 100755
--- a/bin/dfwatch
+++ b/bin/dfwatch
@@ -2,6 +2,10 @@
 
 DFFILT="-x tmpfs -x devtmpfs -l"
 FSFILT='\(/mnt/xstill\)'
+MAIL=mail
+if ! which $MAIL >&/dev/null; then
+    MAIL=bsd-mailx
+fi
 
 FULL=$(df --output=pcent,avail,target,size $DFFILT | tail -n+2 | sed -e 's/^[ ]*//' -e 's/[ ][ ]*/,/g' | while read e; do
     PRC=$(echo $e | cut -f1 -d, | sed 's/%//')
@@ -26,6 +30,6 @@ FULL=$(df --output=pcent,avail,target,size $DFFILT | tail -n+2 | sed -e 's/^[ ]*
 done)
 
 if test -n "$FULL"; then
-    df -h $DFFILT | mail -s "[DF:$(hostname)] Full: $FULL" xstill@fi.muni.cz
+    df -h $DFFILT | $MAIL -s "[DF:$(hostname)] Full: $FULL" xstill@fi.muni.cz
     exit 1
 fi
-- 
GitLab