summaryrefslogtreecommitdiffstats
path: root/remote/modules/cron/data/opt/openslx
diff options
context:
space:
mode:
authorSimon Rettberg2014-01-03 19:20:49 +0100
committerSimon Rettberg2014-01-03 19:20:49 +0100
commit3e2c32e75c5e474b94ce80c2a43e81c10b2b4bd0 (patch)
treec927bc41ab135857f3bdd125018a353bf8c79c03 /remote/modules/cron/data/opt/openslx
parent[pam] SLX_REMOTE_LOG_SESSIONS controls whether session open/close is logged, ... (diff)
downloadtm-scripts-3e2c32e75c5e474b94ce80c2a43e81c10b2b4bd0.tar.gz
tm-scripts-3e2c32e75c5e474b94ce80c2a43e81c10b2b4bd0.tar.xz
tm-scripts-3e2c32e75c5e474b94ce80c2a43e81c10b2b4bd0.zip
[cron] Add sendmail wrapper so it's possible to redirect mail output without recompiling
Also tweaked compilation a bit
Diffstat (limited to 'remote/modules/cron/data/opt/openslx')
-rwxr-xr-xremote/modules/cron/data/opt/openslx/scripts/cron-sendmail30
1 files changed, 30 insertions, 0 deletions
diff --git a/remote/modules/cron/data/opt/openslx/scripts/cron-sendmail b/remote/modules/cron/data/opt/openslx/scripts/cron-sendmail
new file mode 100755
index 00000000..3ce2a19d
--- /dev/null
+++ b/remote/modules/cron/data/opt/openslx/scripts/cron-sendmail
@@ -0,0 +1,30 @@
+#!/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 "cron" "$SUBJ" "$TMP"
+ fi
+
+ rm -f -- "$TMP"
+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
+