various fixes
[distro-setup] / brc2
diff --git a/brc2 b/brc2
index 5cd83b2223641705ff2762871aee5b22385f33c4..6b977839c870f2a4d37c0ae8bc3a3cc31aebe250 100644 (file)
--- a/brc2
+++ b/brc2
@@ -169,8 +169,10 @@ EOF
   fi
   sudo chroot $d apt-get update
   sudo DEBIAN_FRONTEND=noninteractive chroot $d apt-get -y dist-upgrade --purge --auto-remove
-  sudo DEBIAN_FRONTEND=noninteractive schroot -c $n -- apt-get install --allow-unauthenticated -y ${apps[@]}
   sudo cp -P {,$d}/etc/localtime
+  if (( ${#apps[@]} )); then
+    sudo DEBIAN_FRONTEND=noninteractive schroot -c $n -- apt-get install --allow-unauthenticated -y ${apps[@]}
+  fi
 }
 
 
@@ -379,6 +381,22 @@ bigclock() {
 
 nnn() { /a/opt/nnn -H "$@"; }
 
+locat() { # log-once cat
+  local files
+  ngset
+  files=(/var/local/cron-errors/* /home/iank/cron-errors/* /sysd-mail-once-state/*)
+  case ${#files[@]} in
+    0) : ;;
+    1)
+      echo ${files[0]}
+      head ${files[0]}
+      ;;
+    *)
+      head ${files[@]}
+      ;;
+  esac
+  ngreset
+}
 
 # duplicated somewhat below.
 jrun() { # journal run. run args, log to journal, tail and grep the journal.
@@ -1473,7 +1491,6 @@ testmail() {
 # always run this first, edit the test files, then run the following
 testsieve() {
   sieve-filter ~/sieve/maintest.sieve ${1:-INBOX} delete 2> >(head; tail) >/tmp/testsieve.log  && sed -rn '/^Performed actions:/,/^[^ ]/{/^ /p}' /tmp/testsieve.log | sort | uniq -c
-  _dosieve
 }
 runsieve() {
   c ~/sieve; cp personal{test,}.sieve; cp lists{test,}.sieve; cp personalend{test,}.sieve
@@ -1487,14 +1504,14 @@ runsieve() {
 alertme() {
   if [[ -t 0 ]]; then
     exim -t <<EOF
-From: alertme@iankelling.org
+From: alertme@b8.nz
 To: alerts@iankelling.org
 Subject: $*
 EOF
   else
     read sub
     { cat <<EOF
-From: alertme@iankelling.org
+From: alertme@b8.nz
 To: alerts@iankelling.org
 Subject: $sub
 
@@ -1503,6 +1520,39 @@ EOF
     } | exim -t
   fi
 }
+daylertme() {
+  if [[ -t 0 ]]; then
+    exim -t <<EOF
+From: alertme@b8.nz
+To: daylerts@iankelling.org
+Subject: $*
+EOF
+  else
+    read sub
+    { cat <<EOF
+From: alertme@b8.nz
+To: daylerts@iankelling.org
+Subject: $sub
+
+EOF
+      cat
+    } | exim -t
+  fi
+}
+
+# alert when a page goes live. not urgent.
+alert200() {
+  url="$1"
+  tmpdir="$(mktemp -d)"
+  cd $tmpdir
+  while true; do
+    if torsocks wget -q "$url"; then
+      alertme $tmpdir
+    fi
+    sleep 600 + $(( RANDOM % 300 ))
+  done
+}
+
 
 # mail related
 testexim() {