X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=sysd-mail-once;h=e53d6ee6e5f41df4df6b78a702e5f3f3ae9e05e9;hb=0025a0904ad317a102b2e94262a4b01942f13d52;hp=6e6807686a43c3e7f78a6c93b556533da9e8c02a;hpb=c2bd3ac77fd38aa90bb480b2665e5a64f6b93508;p=log-quiet diff --git a/sysd-mail-once b/sysd-mail-once index 6e68076..e53d6ee 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 + if (( errors == 1 )); then + journalctl -u $service.service --after-cursor=$(<$file) | \ + mail -s "$HOSTNAME: $service failure" $u@localhost + fi + fi fi