diff options
author | Dirk Brenken <dev@brenken.org> | 2019-11-03 17:38:28 +0100 |
---|---|---|
committer | Dirk Brenken <dev@brenken.org> | 2019-11-03 19:44:41 +0100 |
commit | 9c82e9e2829a3182db84ae947a815a9741dba4c8 (patch) | |
tree | bad0d6f79a044fcf82a6ee575b8a42ed11b0377e /net/adblock/files/adblock.mail | |
parent | 426ed75dbeec4448ee2cec16bf7c78ee7b3528dc (diff) |
adblock: update 3.8.8
* print to stdout if 'logger' is not available
* small fixes
Signed-off-by: Dirk Brenken <dev@brenken.org>
Diffstat (limited to 'net/adblock/files/adblock.mail')
-rwxr-xr-x | net/adblock/files/adblock.mail | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/net/adblock/files/adblock.mail b/net/adblock/files/adblock.mail index 0f8b17661..a0b8c3f0b 100755 --- a/net/adblock/files/adblock.mail +++ b/net/adblock/files/adblock.mail @@ -21,6 +21,8 @@ then fi adb_ver="${1}" adb_mail="$(command -v msmtp)" +adb_logger="$(command -v logger)" +adb_logread="$(command -v logread)" adb_rc=1 if [ "${adb_debug}" -eq 1 ] @@ -28,13 +30,6 @@ then debug="--debug" fi -# mail header & receiver check -# -if [ -z "${adb_mreceiver}" ] -then - logger -p "err" -t "adblock-${adb_ver}[${$}]" "please set the mail receiver with the 'adb_mreceiver' option" - exit ${adb_rc} -fi adb_mhead="From: ${adb_msender}\\nTo: ${adb_mreceiver}\\nSubject: ${adb_mtopic}\\nReply-to: ${adb_msender}\\nMime-Version: 1.0\\nContent-Type: text/html\\nContent-Disposition: inline\\n\\n" # info preparation @@ -44,8 +39,9 @@ adb_info="$(/etc/init.d/adblock status 2>/dev/null)" if [ -f "/var/log/messages" ] then log_info="$(awk '/adblock-/{NR=1;max=79;if(length($0)>max+1)while($0){if(NR==1){print substr($0,1,max),"↵"} else {print " ",substr($0,1,max)}{$0=substr($0,max+1);NR=NR+1}}else print}' /var/log/messages)" -else - log_info="$(logread -e "adblock-" | awk '{NR=1;max=79;if(length($0)>max+1)while($0){if(NR==1){print substr($0,1,max),"↵"} else {print " ",substr($0,1,max)}{$0=substr($0,max+1);NR=NR+1}}else print}')" +elif [ -x "${adb_logread}" ] +then + log_info="$("${adb_logread}" -e "adblock-" | awk '{NR=1;max=79;if(length($0)>max+1)while($0){if(NR==1){print substr($0,1,max),"↵"} else {print " ",substr($0,1,max)}{$0=substr($0,max+1);NR=NR+1}}else print}')" fi # mail body @@ -58,13 +54,24 @@ adb_mtext="${adb_mtext}</pre></body></html>" # send mail # -if [ -x "${adb_mail}" ] +if [ -x "${adb_mail}" ] && [ -n "${adb_mreceiver}" ] then printf "%b" "${adb_mhead}${adb_mtext}" 2>/dev/null | "${adb_mail}" ${debug} -a "${adb_mprofile}" "${adb_mreceiver}" >/dev/null 2>&1 adb_rc=${?} - logger -p "info" -t "adblock-${adb_ver}[${$}]" "mail sent to '${adb_mreceiver}' with rc '${adb_rc}'" + class="info" + log_msg="mail sent to '${adb_mreceiver}' with rc '${adb_rc}'" +elif [ -z "${adb_mreceiver}" ] +then + class="err" + log_msg="please set the mail receiver with the 'adb_mreceiver' option" else - logger -p "err" -t "adblock-${adb_ver}[${$}]" "msmtp mail daemon not found" + class="err" + log_msg="msmtp mail daemon not found" +fi +if [ -x "${adb_logger}" ] +then + "${adb_logger}" -p "${class}" -t "adblock-${adb_ver}[${$}]" "${log_msg}" +else + printf "%s %s %s\\n" "${class}" "adblock-${adb_ver}[${$}]" "${log_msg}" fi - exit ${adb_rc} |