iankelling.org
/
git
/
log-quiet
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0913504
)
add mail to option for systemd
author
Ian Kelling
<iank@fsf.org>
Sun, 27 Mar 2022 10:04:32 +0000
(06:04 -0400)
committer
Ian Kelling
<iank@fsf.org>
Sun, 27 Mar 2022 10:04:32 +0000
(06:04 -0400)
sysd-mail-once
patch
|
blob
|
history
diff --git
a/sysd-mail-once
b/sysd-mail-once
index 4ccc81c3f37ba1a4ae2554818c2b7f7075de1895..2f7f4d5d9efd035d7803d623bb946090f4597be7 100755
(executable)
--- a/
sysd-mail-once
+++ b/
sysd-mail-once
@@
-19,10
+19,11
@@
trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
errors=3
cbase=$HOME/sysd-mail-once-state
errors=3
cbase=$HOME/sysd-mail-once-state
+to=root
case "$1" in
-h|--help)
cat <<EOF
case "$1" in
-h|--help)
cat <<EOF
-Usage: sysd-
log-once
[-ERRORS] SERVICE COMMAND [ARGS...]
+Usage: sysd-
mail-once [-t TO_ADDRESS]
[-ERRORS] SERVICE COMMAND [ARGS...]
For systemd timers, email on repeated failure & success after failure.
In the service triggered by the timer, prepend this script to the ExecStart.
For systemd timers, email on repeated failure & success after failure.
In the service triggered by the timer, prepend this script to the ExecStart.
@@
-40,6
+41,10
@@
EOF
errors=${1#-}
shift
;;
errors=${1#-}
shift
;;
+ -t)
+ to="$2"
+ shift 2
+ ;;
esac
service=$1
shift
esac
service=$1
shift
@@
-77,13
+82,13
@@
if (( code )); then
fi
if $send_mail; then
journalctl -u $service.service --after-cursor=$(<$file) | \
fi
if $send_mail; then
journalctl -u $service.service --after-cursor=$(<$file) | \
- mail -s "$HOSTNAME: $service exit code: $code"
root
+ mail -s "$HOSTNAME: $service exit code: $code"
"$to"
fi
else
if [[ $file ]]; then
rm -f $file
if [[ $file == $c$errors ]]; then
fi
else
if [[ $file ]]; then
rm -f $file
if [[ $file == $c$errors ]]; then
- echo | mail -s "$HOSTNAME: $service success"
root
+ echo | mail -s "$HOSTNAME: $service success"
"$to"
fi
fi
fi
fi
fi
fi