trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
errors=3
-cbase=$HOME/sysd-mail-once-state
+tmp=(~)
+cbase="${tmp[0]}/sysd-mail-once-state"
to=root
dryrun=false
while [[ $1 == -* ]]; do
echo "sysd-mail-once: emailing on $errors errors. exit code: $code"
mi exim -odf -t <<EOF
To: $to
-From: $USER@$(hostname -f)
+From: $(id -u -n)@$(hostname -f)
Subject: $HOSTNAME: $service exit code: $code
$(journalctl -u $service.service --after-cursor="$(<$file)")
echo "sysd-mail-once: emailing success after >= $errors errors."
mi exim -odf -t <<EOF
To: $to
-From: $USER@$(hostname -f)
+From: $(id -u -n)@$(hostname -f)
Subject: $HOSTNAME: $service success
EOF