From 246e575caf357c06b97fc728cb78295ab3bd8630 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Fri, 18 Oct 2019 12:56:51 -0400 Subject: [PATCH] mostly mail and monitoring fixes --- Makefile | 2 +- brc | 12 ++++++++++-- brc2 | 10 ++++++---- check-mailq | 15 +++++++++++++++ check-remote-mailqs | 4 ++-- conflink | 6 +++++- distro-end | 2 +- mail-setup | 8 +++++--- pkgs | 2 +- system-status | 2 +- 10 files changed, 47 insertions(+), 16 deletions(-) create mode 100755 check-mailq diff --git a/Makefile b/Makefile index b2d2dc8..6050ebe 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ all: ~/.local/distro-begin ~/.local/distro-end ~/.local/distro-begin: distro-begin - distro-begin + distro-begin mail-setup ~/.local/distro-end: distro-end distro-pkgs pkgs distro-end diff --git a/brc b/brc index fe6528a..33e6646 100644 --- a/brc +++ b/brc @@ -198,8 +198,10 @@ if [[ -s /usr/share/wcd/wcd-include.sh ]]; then source /usr/share/wcd/wcd-include.sh fi -if [[ -s ~/.iank/ll-function ]]; then - # shellcheck source=.iank/ll-function +if [[ -s /a/bin/small-misc-bash/ll-function ]]; then + # shellcheck source=/a/bin/small-misc-bash/ll-function + source /a/bin/small-misc-bash/ll-function +elif [[ -s ~/.iank/ll-function ]]; then source ~/.iank/ll-function fi @@ -441,6 +443,12 @@ etail() { eless() { less /var/log/exim4/mainlog } +eqcat() { + exiqgrep -i | while read i; do + exim -Mvh $i; hr; exim -Mvb $i; hr; + exigrep $i /var/log/exim4/mainlog; hr + done +} # shellcheck disable=SC2032 diff --git a/brc2 b/brc2 index bff0eb7..144f0c6 100644 --- a/brc2 +++ b/brc2 @@ -119,9 +119,10 @@ bpush() { } lipush() { rsync $@ --delete-excluded -ahviSAXPH --specials --devices --delete --relative \ - --exclude-from=/p/c/li-rsync-excludes /a/bin /a/exe /a/h /a/c /p/c/machine_specific/li /a/opt/{emacs,emacs-debianstable,mu} root@li:/ + --exclude-from=/p/c/li-rsync-excludes /a/bin /a/exe /a/h /a/c /p/c/machine_specific/li /a/opt/{emacs,emacs-debianstable,mu} root@iankelling.org:/ + rsync -ahviSAXPH root@iankelling.org:/a/h/proposed-comments/ /a/h/proposed-comments } -lipushnoe() { +lipushnoe() { # noe = noemacs. for running faster. rsync $@ --delete-excluded -ahviSAXPH --specials --devices --delete --relative \ --exclude-from=/p/c/li-rsync-excludes /a/bin /a/exe /a/h /a/c /p/c/machine_specific/li root@li:/ } @@ -233,11 +234,11 @@ dup() { ran_d=false case $PS1 in *DISTRO-BEGIN*) - /b/ds/distro-begin + /b/ds/distro-begin || return $? ran_d=true ;;& *DISTRO-END*) - /b/ds/distro-end + /b/ds/distro-end || return $? ran_d=true ;;& *CONFLINK*) @@ -246,6 +247,7 @@ dup() { fi ;; esac + system-status _ } envload() { # load environment from a previous: export > file diff --git a/check-mailq b/check-mailq new file mode 100755 index 0000000..aa7ba76 --- /dev/null +++ b/check-mailq @@ -0,0 +1,15 @@ +#!/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 + +set -eE -o pipefail +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR + +qlen=$(/usr/sbin/exiqgrep -o 60 -c -b | awk '{print $1}') +if [[ $qlen != 0 ]]; then + printf "%s" $qlen +fi +cd /var/mail +find . -type f \! -empty -print -quit diff --git a/check-remote-mailqs b/check-remote-mailqs index 1b3a029..edf6388 100755 --- a/check-remote-mailqs +++ b/check-remote-mailqs @@ -10,11 +10,11 @@ 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 +for h in tp.b8.nz vpn1 x2 x3.b8.nz frodo.b8.nz kd.b8.nz kw iankelling.org; 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 + if c=$(timeout 1 ssh root@$h /b/ds/check-mailq 2>/dev/null ) && [[ $c ]]; then echo q:$h=$c fi done diff --git a/conflink b/conflink index 30d868e..a763c22 100755 --- a/conflink +++ b/conflink @@ -24,8 +24,12 @@ m() { s() { sudo "$@"; } lnf() { /a/exe/lnf "$@"; } -if [[ $1 == -f ]]; then +if [[ $1 == -f ]]; then # f for fast lnf() { ln -sf "$@"; } +elif + [[ $1 ]]; then + echo "error: unrecognized arguments" >&2 + exit 0 fi shopt -s nullglob diff --git a/distro-end b/distro-end index 2bb61ed..c97df51 100755 --- a/distro-end +++ b/distro-end @@ -554,7 +554,7 @@ EOF ###### stop znc setup ##### - + echo 0 >~/.local/distro-end echo "$0: $(date): ending now)" exit 0 ;; diff --git a/mail-setup b/mail-setup index dbdf8fa..3efee8b 100755 --- a/mail-setup +++ b/mail-setup @@ -777,7 +777,9 @@ s#^(127\.0\.1\.1 .*)mail\.iankelling\.org +(.*)#\1\2# EOF echo | /a/exe/cedit mail /etc/dnsmasq-servers.conf || [[ $? == 1 ]] - systemctl reload dnsmasq + if systemctl is-active dnsmasq >/dev/null; then + systemctl reload dnsmasq + fi systemctl disable mailclean.timer &>/dev/null ||: systemctl stop mailclean.timer &>/dev/null ||: @@ -802,10 +804,10 @@ EOF hostname -f > /etc/mailname - # We set this to alerts on MAIL_HOST, but using a user that doesn't exist elsewhere + # This ends up at alerts mailbox on MAIL_HOST, but using a user that doesn't exist elsewhere # is no good. sed -i --follow-symlinks -f - /etc/aliases <