X-Git-Url: https://iankelling.org/git/?p=log-quiet;a=blobdiff_plain;f=sysd-mail-once;h=8feedd377e6324d4d70b5e87f3566495c80fcec9;hp=6e6807686a43c3e7f78a6c93b556533da9e8c02a;hb=ea9d543d812b5ec13d4d3c6b424626f3afaaa5dc;hpb=457661424027a87b9ea600cfeb218574e95470d4 diff --git a/sysd-mail-once b/sysd-mail-once index 6e68076..8feedd3 100755 --- a/sysd-mail-once +++ b/sysd-mail-once @@ -20,8 +20,8 @@ trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR errors=3 cbase=$HOME/sysd-mail-once-state case "$1" in - -h|--help) - cat <$file + if [[ $file ]]; then + i=${file#$c} + if (( i < errors )); then + new_file=$c$((i+1)) + mv $file $new_file + file=$new_file + if [[ $file == $c$errors ]]; then + journalctl -u $service.service --after-cursor=$(<$file) | \ + mail -s "$HOSTNAME: $service failure" $u@localhost + fi fi + else + file=${c}1 + printf "%s\n" "$cursor" >$file + fi fi