email root instead of user. tends to work better
authorIan Kelling <iank@fsf.org>
Thu, 13 Jan 2022 23:46:14 +0000 (18:46 -0500)
committerIan Kelling <iank@fsf.org>
Thu, 13 Jan 2022 23:46:14 +0000 (18:46 -0500)
sysd-mail-once

index 711479c84b1dbecdeefbfa76b64122eaeb09467a..4ccc81c3f37ba1a4ae2554818c2b7f7075de1895 100755 (executable)
@@ -48,7 +48,6 @@ c=$cbase/$service # c for command file path base
 
 glob="$c[0-9]*"
 arr=($glob); file="${arr[0]}"; [[ $glob != "$file" ]] || file=
-u=${USER:-root}
 [[ -d $cbase ]] || mkdir -p $cbase
 
 if [[ ! $file ]]; then
@@ -78,13 +77,13 @@ if (( code )); then
   fi
   if $send_mail; then
     journalctl -u $service.service --after-cursor=$(<$file) | \
-      mail -s "$HOSTNAME: $service exit code: $code" $u@localhost
+      mail -s "$HOSTNAME: $service exit code: $code" root
   fi
 else
   if [[ $file ]]; then
     rm -f $file
     if [[ $file == $c$errors ]]; then
-      echo | mail -s "$HOSTNAME: $service success" $u@localhost
+      echo | mail -s "$HOSTNAME: $service success" root
     fi
   fi
 fi