summaryrefslogtreecommitdiffstats
path: root/core/modules/cron/data/opt/openslx/scripts/cron-sendmail
blob: f46c226df37a891ab71bd4edb98db75a59991c2f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/ash

. /opt/openslx/config

if [ "x$SLX_CRON_MAIL" = "xslxlog" ]; then
	# slxlog handling - special case
	TMP=$(mktemp)
	cat > "$TMP"

	SUBJ=$(grep '^Subject: .*$' "$TMP" | cut -c 10-)

	if [ -n "$SUBJ" ]; then
		slxlog --delete "cron" "$SUBJ" "$TMP"
	fi
elif [ -n "$SLX_CRON_MAIL" ] && [ -x "$SLX_CRON_MAIL" ]; then
	# see if SLX_CRON_MAIL is a valid binary and use that
	$SLX_CRON_MAIL "$@"
elif which sendmail 2> /dev/null; then
	# fallback to sendmail
	sendmail "$@"
elif which logger 2> /dev/null; then
	# nothing worked, write to syslog if logger is present
	TMP=$(mktemp /tmp/cron.XXXXXXXX)
	cat > "$TMP"
	chmod 0600 "$TMP"
	logger "cron tried to mail, but no mailer found! Mail dumped to $TMP"
fi