mostly mail and monitoring fixes
authorIan Kelling <ian@iankelling.org>
Fri, 18 Oct 2019 16:56:51 +0000 (12:56 -0400)
committerIan Kelling <ian@iankelling.org>
Fri, 18 Oct 2019 16:56:51 +0000 (12:56 -0400)
Makefile
brc
brc2
check-mailq [new file with mode: 0755]
check-remote-mailqs
conflink
distro-end
mail-setup
pkgs
system-status

index b2d2dc8b2512bc53179d25f3b8266404fdfb5949..6050ebec5ff9eadd6354cd94e11293fd54c16eea 100644 (file)
--- 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 fe6528acd093ca63a4c9e4674ef63ae5bdaaa774..33e664616c36487ad7f0b426e6d3c25e303eea3f 100644 (file)
--- 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 bff0eb755462d8ee91cd3f31cda1ac340e84db73..144f0c62d1289b75ddbd96246e72a36019bcbc9f 100644 (file)
--- 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 (executable)
index 0000000..aa7ba76
--- /dev/null
@@ -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
index 1b3a0297a3f0586ef0c2ad0ef2a6d178233a4113..edf63880bb4febd1a795d7ff6388796a48e3ebec 100755 (executable)
@@ -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
index 30d868e4dae606d244bc2decb19126fda8d70799..a763c22a03eb2d29db832a3eed473d322d4e9b11 100755 (executable)
--- 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
index 2bb61ed367bd8c623245fdb905151181ad3275b5..c97df5182dc131ebb983ce3802d4658a032e7e58 100755 (executable)
@@ -554,7 +554,7 @@ EOF
     ###### stop znc setup #####
 
 
-
+    echo 0 >~/.local/distro-end
     echo "$0: $(date): ending now)"
     exit 0
     ;;
index dbdf8fa44cdb307624cdfefadad9133c45720ebf..3efee8bf7f7c7882ffef931ea2d39d9ecd45b3f5 100755 (executable)
@@ -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 <<EOF
-\$a root:
+\$a root: root@mail.iankelling.org
 /^root:/d
 EOF
 
diff --git a/pkgs b/pkgs
index 4d8fa2c4437fbd86f3788aed502fe59fedc205d6..1f484b16bae1c87f523fdc4a87dbc39f4eecb78a 100644 (file)
--- a/pkgs
+++ b/pkgs
@@ -26,6 +26,7 @@ p2=(
   ruby-rest-client
   traceroute
   tree
+  uptimed
   vim
   wcd
   wget
@@ -177,7 +178,6 @@ p3=(
   telnet
   transmission-remote-gtk
   trash-cli
-  uptimed
   vlc
   w3m
   whois
index 0ab88b4d533a4ee4f2d01e2a0751f6a63f658458..e137d06f3b4b15c44b884e6dc04e8eb17d0a3759 100755 (executable)
@@ -41,6 +41,7 @@ write-status() {
     chars+=("q $qlen")
   fi
 
+  cd /b/ds
   if ! make -q ~/.local/distro-begin || [[ $(<~/.local/distro-begin) != 0 ]]; then
     chars+=("DISTRO-BEGIN!")
   fi
@@ -51,7 +52,6 @@ write-status() {
 
   f=~/.local/conflink
   if [[ -e $f ]]; then
-    cd /b/ds
     now=$(date +%s)
     fsec=$(stat -c%Y $f)
     fmin=$(( (fsec - now ) / 60 + 1 ))