diff options
author | Benedikt Böhm <bb@xnull.de> | 2013-11-13 02:06:45 -0800 |
---|---|---|
committer | Benedikt Böhm <bb@xnull.de> | 2013-11-13 02:06:45 -0800 |
commit | 113b30bfafd2f8da54949a9819155dcc8ccbe1e5 (patch) | |
tree | d4702ed6177a7b1cf6b3a778852c343c90dba2f5 | |
parent | version bump (diff) | |
parent | Make subject format a configuration option (diff) | |
download | porticron-113b30bfafd2f8da54949a9819155dcc8ccbe1e5.tar.gz porticron-113b30bfafd2f8da54949a9819155dcc8ccbe1e5.tar.bz2 porticron-113b30bfafd2f8da54949a9819155dcc8ccbe1e5.zip |
Merge pull request #5 from raimue/subject-config
Make subject format a configuration option
-rwxr-xr-x | bin/porticron | 12 | ||||
-rw-r--r-- | etc/porticron.conf | 8 |
2 files changed, 18 insertions, 2 deletions
diff --git a/bin/porticron b/bin/porticron index e2de161..763ddb4 100755 --- a/bin/porticron +++ b/bin/porticron @@ -97,6 +97,8 @@ done : ${PORTICRON_CONF:=/etc/porticron.conf} : ${TMP:="/var/tmp/porticron."} : ${CHECK_DUP_MSG:=1} +: ${SUBJECT:=Gentoo package updates on {FQDN\} [ {IP\} ]} +: ${SUBJECT_WARN:=WARNING: Gentoo security updates on {FQDN\} [ {IP\} ]} log "using PORTICRON_CONF=${PORTICRON_CONF}, NOMAIL=${NOMAIL}, VERBOSE=${VERBOSE}" @@ -112,10 +114,16 @@ fi # detect some common variables SCRIPT_NAME=$(basename $0) FQDN=$(hostname --fqdn) +HOST=$(hostname -s) IP=$(dig +short ${FQDN} | tr '\n' ' ') DATE=$(date -R) PORTDIR=$(portageq portdir) +# replace variables +for var in FQDN HOST IP DATE; do + SUBJECT=${SUBJECT/\{$var\}/${!var}} + SUBJECT_WARN=${SUBJECT_WARN/\{$var\}/${!var}} +done # sync if desired log "running SYNC_CMD: ${SYNC_CMD:-/usr/bin/emerge --sync}" @@ -150,7 +158,7 @@ ${GLSA_UPGRADES} cat <<EOF | send_mail To: ${RCPT:-root@${FQDN}} From: root@${FQDN} -Subject: WARNING: Gentoo security updates on ${FQDN} [ ${IP} ] +Subject: ${SUBJECT_WARN} Date: ${DATE} porticron report [${DATE}] @@ -229,7 +237,7 @@ fi cat <<EOF | send_mail To: ${RCPT:-root@${FQDN}} From: root@${FQDN} -Subject: Gentoo package updates on ${FQDN} [ ${IP} ] +Subject: ${SUBJECT} Date: ${DATE} porticron report [${DATE}] diff --git a/etc/porticron.conf b/etc/porticron.conf index a937e29..3869b65 100644 --- a/etc/porticron.conf +++ b/etc/porticron.conf @@ -22,6 +22,14 @@ UPGRADE_OPTS="--deep --update" # recipient for reports RCPT=root@$(hostname -f) +# format of the e-mail subject +# use {FQDN}, {HOST}, {IP}, and {DATE} as variables +#SUBJECT="Gentoo package updates on {FQDN} [ {IP} ]" + +# format of the e-mail subject in case of warnings +# use {FQDN}, {HOST}, {IP}, and {DATE} as variables +#SUBJECT_WARN="WARNING: Gentoo security updates on {FQDN} [ {IP} ]" + # path to sendmail binary SENDMAIL=/usr/sbin/sendmail |