]> arthur.barton.de Git - backup-script.git/commitdiff
backup-script-wrapper: Better detect default mail recipient
authorAlexander Barton <alex@barton.de>
Tue, 18 Aug 2015 07:49:35 +0000 (09:49 +0200)
committerAlexander Barton <alex@barton.de>
Tue, 18 Aug 2015 07:49:35 +0000 (09:49 +0200)
Use "logcheck" if an user exists by this name, or if an alias is defined
in /etc/aliases. Use "root" otherwise.

bin/backup-script-wrapper

index 2f81fa8a69b555a1a6c620956fa59f36423fa136..282cab0fd2156479914f2fc4e026b9e138c94565 100755 (executable)
 # Please read the file COPYING, README and AUTHORS for more information.
 #
 
-[ -n "$MAILTO" ] || MAILTO="logcheck"
+if [ -z "$MAILTO" ]; then
+       if id "logcheck" >/dev/null 2>&1; then
+               MAILTO="logcheck"
+       elif fgrep "logcheck:" /etc/aliases >/dev/null 2>&1; then
+               MAILTO="logcheck"
+       else
+               MAILTO="root"
+       fi
+fi
 
 NAME="backup-script"
 HOST=`hostname`