From c578efcab3f35b96b1b3e4e7248f0fa24d815594 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Thu, 17 Oct 2019 21:48:06 -0400 Subject: [PATCH] fixes --- check-remote-mailqs | 20 ++++++++++++++++++++ distro-end | 4 ++-- epanic-clean | 3 +++ filesystem/etc/cron.d/ian | 1 + system-status | 21 +++------------------ 5 files changed, 29 insertions(+), 20 deletions(-) create mode 100755 check-remote-mailqs diff --git a/check-remote-mailqs b/check-remote-mailqs new file mode 100755 index 0000000..1b3a029 --- /dev/null +++ b/check-remote-mailqs @@ -0,0 +1,20 @@ +#!/bin/bash +# Copyright (C) 2019 Ian Kelling +# SPDX-License-Identifier: AGPL-3.0-or-later + +if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi + +source /a/bin/errhandle/err + +shopt -s nullglob +shopt -s dotglob + + +for h in tp.b8.nz vpn1 x2 x3.b8.nz frodo.b8.nz kd.b8.nz kw; do + if [[ $HOSTNAME == "${h%%.*}" ]]; then + continue + fi + if c=$(timeout 1 ssh $h /usr/sbin/exiqgrep -o 60 -c -b 2>/dev/null | awk '{print $1}' ) && [[ $c && $c != 0 ]]; then + echo q:$h=$c + fi +done diff --git a/distro-end b/distro-end index 6c0f446..2bb61ed 100755 --- a/distro-end +++ b/distro-end @@ -289,14 +289,14 @@ EOF # dont use buster because it causes dist-upgrade to think its downgrading # packages while really just reinstalling the same version. f=/etc/apt/apt.conf.d/01iank - rm -f $f + s rm -f $f # # stupid buster uses some key algorithm not supported by flidas gpg that apt uses. # s dd of=/etc/apt/apt.conf.d/01iank <<'EOF' # Acquire::AllowInsecureRepositories "true"; # EOF f=/etc/apt/sources.list.d/buster.list - rm -f $f + s rm -f $f # t=$(mktemp) # cat >$t <&2' ERR [[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@" +if [[ ! -s /var/log/exim4/paniclog ]]; then + exit 0 +fi wipe=false while read -r d1 d2; do diff --git a/filesystem/etc/cron.d/ian b/filesystem/etc/cron.d/ian index 2874944..35a6997 100644 --- a/filesystem/etc/cron.d/ian +++ b/filesystem/etc/cron.d/ian @@ -2,3 +2,4 @@ SHELL=/bin/bash */10 * * * * iank /a/exe/rootsshsync 2>&1 | /usr/local/bin/log-once -15 rootsshsync # this goes into bash prompt, does in cron for more efficient shell * * * * * iank /a/exe/system-status 2>&1 | /usr/local/bin/log-once system-status +2 * * * * iank /a/exe/check-remote-mailqs 2>&1 | /usr/local/bin/log-once check-remote-mailqs diff --git a/system-status b/system-status index e01b15b..0ab88b4 100755 --- a/system-status +++ b/system-status @@ -36,7 +36,7 @@ write-status() { chars+=("MAILPING!") fi - qlen=$(/usr/sbin/exim -bpc) + qlen=$(/usr/sbin/exiqgrep -o 60 -c -b | awk '{print $1}') if ((qlen)); then chars+=("q $qlen") fi @@ -82,7 +82,7 @@ write-status() { spamcount=0 fi if (( spamcount <= 4 )); then - if grep -q 'spam acl condition' /var/log/exim4/paniclog; then + if grep -q 'spam acl condition' /var/log/exim4/paniclog &>/dev/null; then printf . >>$loglog fi /a/bin/distro-setup/epanic-clean @@ -136,6 +136,7 @@ write-status() { fi } +# use this if we want to do something just once per minute first_chars=() power=true @@ -143,22 +144,6 @@ if [[ -e /sys/class/power_supply/AC/online && $(/dev/null) && [[ $c && $c != 0 ]]; then - msg=q:$h=$c - first_chars+=($msg) - fi - if [[ $1 ]]; then - echo q: $h $c - fi - lo -1 remote-mailq $msg - done -fi write-status if [[ $1 ]]; then cat $status_file -- 2.30.2