Files
restic-automatic-backup-sch…/sbin/cron_mail
Erik Westrup 9760cd05ec Truly support custom PREFIX= install
* Before, doing `$ PREFIX=/usr/local make install` would install files to`/usr/local/usr/local..` which is wrong
* With this PR, files will be installed to the expected location e.g. `/usr/local/etc/restic`
* `Makefile` almost completely rewritten
   * As e.g. `default.env` would source `_global.env`, `default.env` must be edited to find the right location of `_global.env` depending on what `$PREFIX` was set to.
   * see documented build stages in the `Makefile` itself.
   *  Made sure that the rules are correct so that only modifed files are installed, not all at once unnecessarily like before.
* A sub-goal was that the [PKGBUILD](https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=restic-systemd-automatic-backup#n20) for Arch should not need to do any custom install configuration, to keep everything easier to maintain. `$ make install` should work out of the box for Arch.
* Additionally added the `-b` flag to `install(1)` that makes a backup of existing `etc/restic/*` files before installing a newer version.

Fixes #49
2022-02-03 20:52:00 +01:00

25 lines
595 B
Bash
Executable File

#!/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
#@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