various fixes and updates
authorIan Kelling <ian@iankelling.org>
Fri, 22 Nov 2019 23:57:17 +0000 (18:57 -0500)
committerIan Kelling <ian@iankelling.org>
Fri, 22 Nov 2019 23:57:17 +0000 (18:57 -0500)
15 files changed:
brc
brc2
btrbk-run
check-subvol-stale
distro-begin
distro-end
fsf-dnsmasq-servers.conf [deleted file]
i3-sway/common.conf
mount-latest-subvol
pkgs
subdir_files/.config/i3/config
subdir_files/.config/sway/config
subdir_files/sieve/lists.sieve
subdir_files/sieve/liststest.sieve
switch-mail-host

diff --git a/brc b/brc
index 51a04dcac0d59c3a29bd081522ee11a51dc738da..118ce01e18e27f7654cae2805c4ef1d44ab9d672 100644 (file)
--- a/brc
+++ b/brc
@@ -888,7 +888,9 @@ q() { # start / launch a program in the backround and redir output to null
 
 # shellcheck disable=SC2120
 r() {
-  history -a # save history
+  if [[ $HISTFILE ]]; then
+    history -a # save history
+  fi
   trap ERR # this avoids a segfault
   exit ${1:0}
   # i had this redir, not sure why
@@ -1268,7 +1270,9 @@ if [[ $- == *i* ]]; then
     local ps_char ps_color
     unset IFS
 
-    history -a # save history
+    if [[ $HISTFILE ]]; then
+      history -a # save history
+    fi
 
     case $return in
       0) ps_color="$term_purple"
diff --git a/brc2 b/brc2
index 56f4db6c860d4ff83bb91a254ab3a0eb683e33cf..50d51baab5ff3b3b03c98932a5bc0068a4c8235a 100644 (file)
--- a/brc2
+++ b/brc2
@@ -140,6 +140,20 @@ bigclock() {
   xclock -digital -update 1 -face 'arial black-80:bold'
 }
 
+inttrap() {
+  pid=$1
+  # just passing on -INT doesnt work.
+  kill -TERM $pid
+  sleep .05
+  if [[ ! -e /proc/$pid ]]; then
+    if [[ $old_int_trap ]]; then
+      $old_int_trap
+    else
+      trap INT
+    fi
+  fi
+}
+
 _jrun() { # journal run. run args, log to journal, tail and grep the journal.
   # Redirect all commands which might have stderr to stdout because of
   # wrapping.
@@ -154,19 +168,25 @@ _jrun() { # journal run. run args, log to journal, tail and grep the journal.
   cmd_name=${1##*/}
   systemd-cat -t "$cmd_name" "$@" 2>&1 &
   pid=$!
-  sedscript="/$pattern$cmd_name/p;/^.{16}[^ ]+ $cmd_name\[$pid]: $cmd_name: exiting with status [0-9]+\$/q"
+  old_int_trap="$(trap -p INT)"
+  # Note, just passing along INT wont actually stop it.
+  # Oddly, the log says ERROR: /script.sh returned 130
+  # but it continues on.
+  trap "inttrap $pid" INT
+  sedscript="/$pattern$cmd_name/p;/^.{16}[^ ]+ $cmd_name\[$pid]: ([^ ]*\/)?$cmd_name: exiting with status [0-9]+\$/q"
+  # debug:
+  #echo "sedscript: sed -nr '$sedscript'"
   journalctl -S "4 seconds ago" -f |& sed -nr "$sedscript" 2>&1 &
   jr_pid=$!
   wait $pid 2>&1 || ret=$?
   if (( $ret )); then
     echo "$0: ERROR: $* returned $ret"
   fi
-  jobs %'journalctl -S "4 seconds ago" -f' &>/dev/null
   ended=false
-  # give it about 5 seconds to find the end of the log
-  for (( i=0; i<20; i++ )); do
-    if jobs %'journalctl -S "4 seconds ago" -f' &>/dev/null; then
-      sleep .3 2>&1
+  # give it 4 seconds to find the end of the log
+  for (( i=0; i<80; i++ )); do
+    if [[ -e /proc/$jr_pid ]]; then
+      sleep .05 2>&1
     else
       ended=true
       break
@@ -175,6 +195,12 @@ _jrun() { # journal run. run args, log to journal, tail and grep the journal.
   if ! $ended; then
     kill $jr_pid 2>&1
   fi
+  if [[ $old_int_trap ]]; then
+    $old_int_trap
+  else
+    trap INT
+  fi
+  return 0
 }
 jrun() {
   # ditching stderr avoids the jobs status change output.
@@ -182,19 +208,10 @@ jrun() {
 }
 
 sm() {
-  (( $# == 2 )) || return 1
-  action=$1
-  shift
-  host=$1
-  shift
-  case $action in
-    pull|push) : ;;
-    *) return 1 ;;
-  esac
   c /
   # run latest
   install-my-scripts
-  jrun -p btrbk switch-mail-host $action $host
+  jrun -p btrbk switch-mail-host "$@"
   return $ret
 }
 
@@ -808,7 +825,8 @@ resolvcat() {
   m s nscd -i hosts
   f=/etc/resolv.conf
   echo $f:;  ccat $f
-  hr; m ser status dnsmasq | cat
+  # this will fail is dnsmasq is failed
+  hr; m ser status dnsmasq | cat || :
   hr; s ss -lpn 'sport = 53'
   #hr; echo dnsmasq is $(systemctl is-active dnsmasq)
   f=/var/run/dnsmasq/resolv.conf
@@ -820,6 +838,10 @@ resolvcat() {
 rcat() {
   resolvcat | less
 }
+reresolv() {
+  sudo nscd -i hosts
+  sudo systemctl restart dnsmasq
+}
 
 # only run on MAIL_HOST. simpler to keep this on one system.
 r2eadd() { # usage: name url
@@ -1220,6 +1242,8 @@ wtr() { curl wttr.in/boston; }
 
 xevkb() { xev -event keyboard; }
 
+ziva() { e "toot! i love dancing. fart"; }
+
 # * misc stuff
 
 # from curl cheat.sh/:bash_completion
index 3a2d2a493495fb2fc422f02b9f5f80b52c632b39..04a71a82da4c18db673c79bae3e7c2c9573b6150 100644 (file)
--- a/btrbk-run
+++ b/btrbk-run
@@ -66,6 +66,7 @@ dry_run=false # mostly for testing
 rate_limit=no
 verbose=true; verbose_arg=-v
 progress_arg="--progress"
+incremental_strict=true
 pull_reexec=false
 
 default_args_file=/etc/btrbk-run.conf
@@ -79,7 +80,7 @@ fi
 
 cron=false
 orig_args=("$@")
-temp=$(getopt -l cron,pull-reexec,help cl:m:npqs:t:vh "$@") || usage 1
+temp=$(getopt -l cron,pull-reexec,help cil:m:npqs:t:vh "$@") || usage 1
 eval set -- "$temp"
 while true; do
   case $1 in
@@ -90,6 +91,7 @@ while true; do
       ;;
     # only creates the config file, does not run btrbk
     -c) conf_only=true; shift ;;
+    -i) incremental_strict=false; shift ;;
     # bytes per second, suffix k m g
     -l) rate_limit=$2; shift 2 ;;
     # Comma separated mountpoints to backup. This has defaults set below.
@@ -131,6 +133,10 @@ if $verbose; then
 fi
 ### end options parsing
 
+if ! btrbk --version |& grep 0.29.0 >/dev/null; then
+  cd /a/opt/btrbk
+  m sudo make install
+fi
 
 # TODO: i wonder if there should be an option to send to the default
 # targets, plus any given on the command line.
@@ -150,8 +156,8 @@ if [[ ! -v targets && ! $source ]]; then
       ;;&
     x2|x3)
       if ping -q -c1 -w1 hal.office.fsf.org \
-              && ip n show 192.168.0.26 | grep . &>/dev/null; then
-      at_work=true
+          && ip n show 192.168.0.26 | grep . &>/dev/null; then
+        at_work=true
       fi
       ;;&
     kw|x2|x3)
@@ -162,7 +168,7 @@ if [[ ! -v targets && ! $source ]]; then
       fi
       ;;&
     kw)
-      targets=($home x2)
+      targets=($home x3)
       ;;
     x2|x3)
       targets=($home kw)
@@ -370,9 +376,11 @@ target_preserve_min 4h
 rate_limit $rate_limit
 EOF
 
-
-
-
+if $incremental_strict; then
+  cat >>/etc/btrbk.conf <<EOF
+incremental strict
+EOF
+fi
 
 vol=/mnt/root
 for m in ${mountpoints[@]}; do
index 07926ef49e3af16535a2d62c915f37cd88552426..d514bafa8ed22d047f751cb28a972f3724d0ea16 100644 (file)
@@ -106,6 +106,7 @@ for d; do
   snaps=($root_dir/btrbk/$subvol_dir.20*) # Assumes we are in the 21st century.
   if [[ ! ${snaps[*]} ]]; then
     # no snapshots yet
+    # TODO: make this an error and override with a cli flag
     echo "$0: warning: no snapshots found at $root_dir/btrbk/$subvol_dir.20*. this is expected for a brand new volume"
     continue
   fi
index 72d4d44f613e6ca7ef521dac93344526fc6a753f..eb51dcbe33fb67d0008357e8bddc203ad6f125f3 100755 (executable)
@@ -127,7 +127,7 @@ if encrypted; then
   # but it happened too late in the shutdown process.
   sudo dd of=/etc/systemd/system/keyscripton.service <<'EOF'
 [Unit]
-Description=Turn on automatic decryption of drives on boot
+Description=keyscripton
 # This is triggered by reboot and when keyscriptoff stops.
 
 # tried using graphical.target, but it made my display manager restart before rebooting.
@@ -153,7 +153,7 @@ EOF
 
   sudo dd of=/etc/systemd/system/keyscriptoff.service <<'EOF'
 [Unit]
-Description=Turn off automatic decryption of drives on boot
+Description=keyscriptoff
 
 [Service]
 Type=oneshot
@@ -212,8 +212,13 @@ if [[ $HOSTNAME != $(cat /etc/hostname) ]]; then
   echo $HOSTNAME > /etc/hostname
   hostname -F /etc/hostname
 fi
+# office vpn dhcp adds to /etc/resolv.conf search office.fsf.org which
+# makes that be #1 priority, which makes dnsmasq resolve that for
+# unqualified hosts first, which means we skip the hosts file. Ya, its
+# kinda dumb, but it is what it is. There is a dnsmasq config option to
+# override it too, but this seems simpler.
 sudo sed -i --follow-symlinks -f - /etc/hosts <<EOF
-\$a 127.0.1.1 $HOSTNAME.b8.nz $HOSTNAME
+\$a 127.0.1.1 $HOSTNAME.b8.nz $HOSTNAME.office.fsf.org $HOSTNAME
 /^127\.0\.1\.1/d
 EOF
 
index 18edaa56b8db4e3485e37f9d327acbdf62c40343..a53c8c8c26c593e236846c38dda1ea0b6eb95002 100755 (executable)
@@ -181,6 +181,10 @@ Pin-Priority: -100
 Package: *
 Pin: release a=xenial-security
 Pin-Priority: -100
+
+Package: firefox
+Pin: release n=xenial
+Pin-Priority: 500
 EOF
     sd /etc/apt/sources.list.d/xenial.list 2>/dev/null <<EOF
 deb http://us.archive.ubuntu.com/ubuntu/ xenial main
@@ -606,6 +610,11 @@ case $codename_compat in
     ;;
   bionic)
     pi gnome-core
+    # by default, it sleeps when not logged in to x/wayland and on ac power.
+    # stop that.
+    sudo -u gdm dbus-launch gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing'
+    systemctl --user stop gvfs-daemon
+    systemctl --user disable gvfs-daemon
     ;;
 esac
 
@@ -615,12 +624,12 @@ if [[ $codename_compat == flidas ]]; then
   pi gnupg-doc
 fi
 
-if [[ $codename == flidas ]]; then
-  pi abrowser
-else
-  pi firefox
-  sudo ln -sf /usr/bin/firefox /usr/local/bin/abrowser
-fi
+# abrowser is not in etiona yet, abrowser version is 68,
+# abrowser won't run on a firefox profile that was on firefox
+# version 70. firefox in ubuntu is at version 70.
+# have to rm compabibility.ini to even try downgrade.
+pi firefox
+sudo update-alternatives --set x-www-browser /usr/bin/firefox
 
 # TODO: some of the X programs can be removed from pall when using wayland
 
diff --git a/fsf-dnsmasq-servers.conf b/fsf-dnsmasq-servers.conf
deleted file mode 100644 (file)
index ae892f6..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-server=/fsf.org/gnu.org/192.168.0.10
-server=/fsf.org/gnu.org/192.168.0.25
-server=//192.168.0.10
-server=//192.168.0.25
-rev-server=192.168.0.0/24,192.168.0.10
-rev-server=192.168.0.0/24,192.168.0.25
-rev-server=172.16.0.0/23,192.168.0.10
-rev-server=172.16.0.0/23,192.168.0.25
index 44eb9506f95fc902b8772bf0921d16e281060003..c511dbc2b99cb77420bd522cca2d99be5f911fe2 100644 (file)
@@ -4,8 +4,8 @@
 set $mod Mod4
 
 bindsym $mod+2 exec "pavucontrol"
-bindsym $mod+3 exec "abrowser"
-bindsym $mod+4 exec "abrowser -no-remote -P firefox-main-profile"
+bindsym $mod+3 exec "x-www-browser"
+bindsym $mod+4 exec "x-www-browser -no-remote -P firefox-main-profile"
 bindsym $mod+5 exec "/a/bin/redshift.sh"
 
 bindsym $mod+w focus parent
index 026f490025538ffd1361217380b336836fe61c2c..49dfac72910f8ecb0ed8b42a5ca9c9f3cdb4a1be 100644 (file)
@@ -108,7 +108,7 @@ kill-dir() {
 
 # you can remove this if you do not have options which can have args with spaces or empty.
 
-verbose=false
+verbose=true
 force=false
 temp=$(getopt -l help,force,verbose hfv "$@") || usage 1
 eval set -- "$temp"
diff --git a/pkgs b/pkgs
index 55126fd1357030b54080afb3e06856c14ad0622d..7bc4db7cb272d469b1199820d01817f63c50ac00 100644 (file)
--- a/pkgs
+++ b/pkgs
@@ -8,6 +8,7 @@ p1=(
   lvm2
   mbuffer
   screen
+  nscd
 )
 p2=(
   bash-completion
@@ -16,6 +17,7 @@ p2=(
   eatmydata
   fping
   git
+  haveged
   htop
   iptables
   mailutils
index 4249289572c341ef80b5aa211cbbd5e999273964..e4486795054bcfb60e78ed3a416d352e0eb8f662 100644 (file)
@@ -4,8 +4,8 @@
 set $mod Mod4
 
 bindsym $mod+2 exec "pavucontrol"
-bindsym $mod+3 exec "abrowser"
-bindsym $mod+4 exec "abrowser -no-remote -P firefox-main-profile"
+bindsym $mod+3 exec "x-www-browser"
+bindsym $mod+4 exec "x-www-browser -no-remote -P firefox-main-profile"
 bindsym $mod+5 exec "/a/bin/redshift.sh"
 
 bindsym $mod+w focus parent
index 105ff90f6e3bee93049bb5665986a1b9ab999c75..b81cad517f18b2e1f4923debc31924d1e5ca356f 100644 (file)
@@ -4,8 +4,8 @@
 set $mod Mod4
 
 bindsym $mod+2 exec "pavucontrol"
-bindsym $mod+3 exec "abrowser"
-bindsym $mod+4 exec "abrowser -no-remote -P firefox-main-profile"
+bindsym $mod+3 exec "x-www-browser"
+bindsym $mod+4 exec "x-www-browser -no-remote -P firefox-main-profile"
 bindsym $mod+5 exec "/a/bin/redshift.sh"
 
 bindsym $mod+w focus parent
index 54f617f67b37ec58cf756560c80def01822cc626..00b9443cd68a22298e068838470e36e077671c39 100644 (file)
@@ -90,6 +90,16 @@ if anyof (
         }
          }
 
+
+
+if anyof (
+    header :contains "list-id" "<~sircmpwn/sr.ht-discuss.lists.sr.ht>"
+    ) {
+    fileinto :create "l/sr.ht-discuss";
+    stop;
+         }
+
+
 if anyof (
     header :contains "list-id" "<activists_masspirates.org.lists.mayfirst.org>",
     header :contains "list-id" "<gnu-prog-discuss.gnu.org>",
@@ -103,6 +113,8 @@ if anyof (
     header :contains "list-id" "<gnu-misc-discuss.gnu.org>",
     header :contains "list-id" "<Spdx-legal.lists.spdx.org>",
     header :contains "list-id" "<info-gnu.gnu.org>",
+    header :contains "list-id" "<discussion.lists.fsfe.org>",
+    header :contains "list-id" "<gnu-system-discuss.gnu.org>",
     header :contains "from" "<general-info@artisansasylum.com>",
     header :contains "list-id" "<spdx.lists.spdx.org>"
     ) {
@@ -110,6 +122,7 @@ if anyof (
     stop;
          }
 
+
 if allof (
     address :is "from" "mailman-owner@zope.org",
     header :is "subject" "zope.org mailing list memberships reminder"
index 54f617f67b37ec58cf756560c80def01822cc626..00b9443cd68a22298e068838470e36e077671c39 100644 (file)
@@ -90,6 +90,16 @@ if anyof (
         }
          }
 
+
+
+if anyof (
+    header :contains "list-id" "<~sircmpwn/sr.ht-discuss.lists.sr.ht>"
+    ) {
+    fileinto :create "l/sr.ht-discuss";
+    stop;
+         }
+
+
 if anyof (
     header :contains "list-id" "<activists_masspirates.org.lists.mayfirst.org>",
     header :contains "list-id" "<gnu-prog-discuss.gnu.org>",
@@ -103,6 +113,8 @@ if anyof (
     header :contains "list-id" "<gnu-misc-discuss.gnu.org>",
     header :contains "list-id" "<Spdx-legal.lists.spdx.org>",
     header :contains "list-id" "<info-gnu.gnu.org>",
+    header :contains "list-id" "<discussion.lists.fsfe.org>",
+    header :contains "list-id" "<gnu-system-discuss.gnu.org>",
     header :contains "from" "<general-info@artisansasylum.com>",
     header :contains "list-id" "<spdx.lists.spdx.org>"
     ) {
@@ -110,6 +122,7 @@ if anyof (
     stop;
          }
 
+
 if allof (
     address :is "from" "mailman-owner@zope.org",
     header :is "subject" "zope.org mailing list memberships reminder"
index eafe1044c0816c19aa7522b94445d6a3de7cec78..df0b83605ee25fc8c7743504d18a5698278a2916 100644 (file)
@@ -38,16 +38,18 @@ err-cleanup() {
 pre="${0##*/}:"
 m() { printf "$pre %s\n"  "$*"; "$@"; }
 e() { printf "$pre %s\n"  "$*"; }
-err() { echo "$pre: ERROR: $*" >&2; }
-mexit() { echo "$pre: exiting with status $1"; exit $1; }
+err() { echo "$pre ERROR: $*" >&2; }
+mexit() { echo "$pre exiting with status $1"; exit $1; }
 
 ##### begin command line parsing ########
 
-temp=$(getopt -l help owh "$@") || usage 1
+force=false
 mp_args="-m /o,/q,/a"
+temp=$(getopt -l force,help owh "$@") || usage 1
 eval set -- "$temp"
 while true; do
   case $1 in
+    --force) force=true ;;
     -o) mp_args="-m /o"; shift ;;
     -h|--help) usage ;;
     --) shift; break ;;
@@ -66,8 +68,9 @@ fi
 case $1 in
   push)
     old_host=$HOSTNAME
+    old_hostname=$HOSTNAME
     new_host=$2
-    bbk_args="-s $old_host"
+    bbk_args="-t $new_host"
     new_shell="ssh $new_host"
     new_hostname=$($new_shell hostname)
     ;;
@@ -75,11 +78,10 @@ case $1 in
     old_host=$2
     new_host=$HOSTNAME
     new_hostname=$HOSTNAME
-    bbk_args="-t $new_host"
     bbk_args="-s $old_host"
     old_shell="ssh $old_host"
-    # test ssh connection
-    $old_shell :
+    # tests ssh connection
+    old_hostname=$($old_shell hostname)
     ;;
   *)
     err invalid first argument
@@ -89,9 +91,9 @@ esac
 
 source /a/bin/bash_unpublished/source-state
 
-if [[ $old_host != "$MAIL_HOST" ]]; then
-  e "WARNING: \$old_host != \$MAIL_HOST. Sleeping for 5 seconds in case you want to reconsider"
-  sleep 5
+if [[ $old_hostname != "$MAIL_HOST" ]] && ! $force; then
+  err "\$old_hostname($old_hostname) != \$MAIL_HOST($MAIL_HOST). Rerun with --force if you really want this."
+  mexit 1
 fi
 
 if [[ ! $new_host || ! $old_host ]]; then
@@ -112,20 +114,24 @@ if $old_shell systemctl is-active btrbk.timer; then
 fi
 
 btrbk_test="systemctl is-active btrbk.service"
-while true; do
+active=true
+while $active; do
+  active=false
   for shell in "$new_shell" "$old_shell"; do
     e $shell $btrbk_test
     status=$($shell $btrbk_test) ||:
     case $status in
       inactive|failed) : ;;
       *)
+        # This covers conditions like "activating", which still return 3 from
+        # systemctl is-active.
+        active=true
         e "btrbk active on shell:$shell, status:$status, sleeping 8 seconds"
         sleep 8
-        continue
+        break
         ;;
     esac
   done
-  break
 done
 
 # ensure these are unused before doing anything
@@ -162,8 +168,8 @@ fi
 m $old_shell /a/exe/primary-setup $new_hostname
 
 e Running main btrbk
-if ! m btrbk-run -v $bbk_args -m /o; then
-  ret=$?
+m btrbk-run -v $bbk_args -m /o || ret=$?
+if (( ret )); then
   bang="$(printf "$(tput setaf 5)█$(tput sgr0)%.0s" 1 2 3 4 5 6 7)"
   e $bang failed btrbk of /o. restoring old host as primary
   m $old_shell /a/exe/primary-setup localhost