Files
restic-automatic-backup-sch…/bin/cron_mail
Gerard Bosch de28285741 fix: Change INSTALL_PREFIX placeholder notation to templating notation (#131)
* refactor: Change INSTALL_PREFIX placeholder notation to templating notation

The former shell notation `$INSTALL_PREFIX` could result confusing. As
this is a placeholder that's replaced in the `make`, we switch it to a
template notation `{{ INSTALL_PREFIX }}`.

* docs: Small fix on README/manual setup

* docs(email-notif): Document the `{{ INSTALL_PREFIX }}` placeholder

co-authored-by: giuaig <13609224+giuaig@users.noreply.github.com>

* Update README.md

Co-authored-by: Gerard Bosch <30733556+gerardbosch@users.noreply.github.com>

---------

Co-authored-by: giuaig <13609224+giuaig@users.noreply.github.com>
Co-authored-by: Erik Westrup <erik.westrup@icloud.com>
2023-12-13 23:49:41 +05:30

25 lines
620 B
Bash

#!/usr/bin/env sh
# vi: ft=sh
#
# To be called by a cron job as a wrapper that sends stdour and stderr via the mail program.
# Why? Because of FreeBSD the system cron uses sendmail, and I want to use ssmtp.
# Make your crontab files like:
#SHELL=/bin/sh
#PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin:{{ INSTALL_PREFIX }}/bin
#@daily root cron_mail freebsd-update cron
mail_target=root
scriptname=${0##*/}
if [ $# -eq 0 ]; then
echo "No program to run given!" >&2
exit 1
fi
cmd="$*"
body=$(eval "$cmd" 2>&1)
if [ -n "$body" ];then
echo "$body" | mail -s "${scriptname}: ${cmd}" $mail_target
fi