X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=failmail;h=6360c7e31c0d84d7d3e2262adc925154683417a1;hb=7f7ce3ccf4269622c5e40556ef8b3b1e9b07ab47;hp=703e13038d6c7428d32e9c4a3f21f6d84966317b;hpb=caf623ada289608bdbcc2216058057a7390f7939;p=log-quiet diff --git a/failmail b/failmail old mode 100644 new mode 100755 index 703e130..6360c7e --- a/failmail +++ b/failmail @@ -14,19 +14,26 @@ # limitations under the License. case $1 in - -h|--help) - cat <<'EOF' -usage: logmail CMD [ARGS...] + -h|--help) + cat <<'EOF' +usage: failmail CMD [ARGS...] Send mail in case of failure of CMD + +Emails to $MAILTO or if unset, $USER@localhost EOF - exit 0 - ;; + exit 0 + ;; esac +mailto=$USER@localhost +if [[ $MAILTO ]]; then + mailto=$MAILTO +fi + t=$(mktemp) if ! "$@" &>"$t"; then - mail -s "$HOSTNAME: $*" $USER@localhost <"$t" - rm "$t" + mail -s "$HOSTNAME: $*" $mailto <"$t" + rm "$t" fi exit 0