fixes
authorIan Kelling <ian@iankelling.org>
Fri, 18 Oct 2019 01:48:06 +0000 (21:48 -0400)
committerIan Kelling <ian@iankelling.org>
Fri, 18 Oct 2019 01:48:06 +0000 (21:48 -0400)
check-remote-mailqs [new file with mode: 0755]
distro-end
epanic-clean
filesystem/etc/cron.d/ian
system-status

diff --git a/check-remote-mailqs b/check-remote-mailqs
new file mode 100755 (executable)
index 0000000..1b3a029
--- /dev/null
@@ -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
index 6c0f446642d15916512a929ce22caad4ef9a71f2..2bb61ed367bd8c623245fdb905151181ad3275b5 100755 (executable)
@@ -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
+    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
+    rm -f $f
     #         t=$(mktemp)
     #         cat >$t <<EOF
     # deb http://http.us.debian.org/debian buster main
index ead3e9a8a34c9a8af337e57363bcd37b71dc4177..83533ea4fef9f5a5c72cb9546c00014a3de5f572 100755 (executable)
@@ -13,6 +13,9 @@ trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&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
index 2874944e9a7a3dfcf65eaf940ee423ebef702e65..35a69975730ef6e0edafb38c7880990ad95e1404 100644 (file)
@@ -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
index e01b15b6346af812f68779b88dcb4d2864f274de..0ab88b4d533a4ee4f2d01e2a0751f6a63f658458 100755 (executable)
@@ -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 && $(</sys/class/power_supply/AC/onli
   power=false
 fi
 
-if $power; then
-  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
-    msg=
-    if c=$(timeout 1 ssh $h exim -bpc 2>/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