various fixes
authorIan Kelling <ian@iankelling.org>
Thu, 4 Mar 2021 18:22:26 +0000 (13:22 -0500)
committerIan Kelling <ian@iankelling.org>
Thu, 4 Mar 2021 18:22:26 +0000 (13:22 -0500)
brc
brc2
btrbk-run
btrfsmaint
distro-begin
distro-end
dsremote
filesystem/etc/apt/preferences.d/radicale [deleted file]
filesystem/usr/local/bin/abrowser
machine_specific/btrbk.hosts
pkgs

diff --git a/brc b/brc
index c9078eef1dc1da0d1a5d94586721633049016d39..f7d64f40806bf069aff16122d1ade9995ccceeb9 100644 (file)
--- a/brc
+++ b/brc
@@ -398,10 +398,11 @@ ccomp grep ccat
 
 chrbind() {
   local d
-  for d in dev proc sys; do
+  # dev/pts needed for pacman signature check
+  for d in dev proc sys dev/pts; do
     [[ -d $d ]]
     if ! mountpoint $d &>/dev/null; then
-      mount -o bind /$d $d
+      mount -o bind /$d $d
     fi
   done
 }
diff --git a/brc2 b/brc2
index 52e01d8aba882c61dc5dae3918eb6fa62f0d1ec4..169b847bd50b68e736c5ffbb5b7d81a39ec629a7 100644 (file)
--- a/brc2
+++ b/brc2
@@ -135,15 +135,56 @@ EOF
 }
 
 
+# note: this is incomplete and untested.
+# https://wiki.archlinux.org/index.php/Install_Arch_Linux_from_existing_Linux#Creating_a_chroot
+mkarchchroot() {
+  local tarball mirror
+  mirror=https://mirrors.edge.kernel.org/archlinux/iso/latest/
+  tarball=$(curl -s $mirror | sed -nr 's/.*"(archlinux-bootstrap-.*-x86_64.tar.gz)".*/\1/p')
+  wget -O /tmp/arch.tar.gz https://mirrors.edge.kernel.org/archlinux/iso/latest/$tarball
+  s mkdir -p /nocow/schroot/arch
+  cd _/nocow/schroot/arch
+  s sed -i '/## United States/,/^$/s,^#,,' etc/pacman.d/mirrorlist
+  # error: could not determine cachedir mount point /var/cache/pacman/pkg
+  s sed -i /^CheckSpace/d etc/pacman.conf
+  chroot . /bin/bash -s <<'EOF'
+pacman-key --init
+pacman-key --populate archlinux
+pacman -Syyu
+EOF
+  # example of building an aur package:
+  # pacman -Sy base-devel wget
+  # useradd -m iank
+  # f=$target/etc/sudoers
+  # line='iank  ALL=(ALL)  NOPASSWD: ALL'
+  # if [[ ! -e $f ]] || ! grep -xF "$line" $f; then
+  #   echo "$line" >> $f
+  # fi
+  # su iank
+  # wget https://aur.archlinux.org/cgit/aur.git/snapshot/anbox-image-gapps.tar.gz
+  # tar xzf anbox-image-gapps.tar.gz
+  # cd anbox-image-gapps
+  # makepkg -s
+}
+
+
 # clock back in to timetrack from last entry
 tback() {
   sqlite3 /p/.timetrap.db "update entries set end = NULL where id = (select max(id) from entries);"
 }
 
 bum() {
-  local host=$1
+  local cur host
+  host=$1
   (( $# == 1 )) || return 1
-  sshfs $host:/bu/md /bu/mnt
+  cur="$(awk '$2 == "/bu/mnt" {print $1}' /proc/mounts)"
+  if [[ $cur ]]; then
+    if [[ $cur != "$host:/bu/md" ]]; then
+      fusermount -u /bu/mnt
+    fi
+  else
+    sshfs $host:/bu/md /bu/mnt
+  fi
   ser start exim4
 }
 bu() {
@@ -295,8 +336,9 @@ jrun() { # journal run. run args, log to journal, tail and grep the journal.
     cmd=$(which $1)
   fi
   journalctl -qn2 -f -u "$cmd_name" &
-  # 1st guess to avoid missing some initial lines.
-  sleep .5
+  # Guess of time needed to avoid missing initial lines.
+  # .5 was not reliable.
+  sleep 1
   # We kill this in prompt-command for the case that we ctrl-c the
   # systemd-cat. i dont know any way to trap ctrl-c and still run the
   # normal action for it. There might be a way, unsure.
@@ -1555,7 +1597,7 @@ path-add --end ~/.npm-global
 path-add --end $HOME/.cargo/bin
 
 if type -P rg &>/dev/null; then
-  rg() { command rg -i -M 200 --no-ignore "$@"; }
+  rg() { command rg -i -M 300 --no-ignore "$@"; }
   complete -r rg
 else
   alias rg=grr
index 9aef6e03d6929f7e2940d723eab1ff528ed0538d..74deab78fad88f353f54c75ab99cb20f71d10d42 100644 (file)
--- a/btrbk-run
+++ b/btrbk-run
@@ -169,13 +169,13 @@ if [[ ! -v targets && ! $source ]]; then
     kw)
       at_work=true
       ;;&
-    x2|x3)
+    x2|x3|sy)
       if ping -q -c1 -w1 hal.office.fsf.org \
           && ip n show 192.168.0.26 | grep . &>/dev/null; then
         at_work=true
       fi
       ;;&
-    kw|x2|x3)
+    kw|x2|x3|sy)
       if $at_work && ping -q -c1 -w1 iank.vpn2.office.fsf.org &>/dev/null; then
         home=iank.vpn2.office.fsf.org
       else
@@ -185,7 +185,7 @@ if [[ ! -v targets && ! $source ]]; then
     kw)
       targets+=($home x3)
       ;;
-    x2|x3)
+    x2|x3|sy)
       targets+=($home kw.office.fsf.org)
       ;;
     kd)
index c410b7b3503359309ab6938f5c233f7193cd6a3e..06570b30e364ad580ff9037a8b572bdfd0643a3b 100755 (executable)
@@ -2,6 +2,8 @@
 set -eE -o pipefail
 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
 
+
+[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
 # inspired from
 # https://github.com/kdave/btrfsmaintenance
 
@@ -15,79 +17,93 @@ musage="1 5 10 20 30"
 e() { echo "cron: $*"; "$@"; }
 
 check-idle() {
-    export DISPLAY=:0
-    # 3 hours, assume a movie might run that long.
-    idle_limit=$((1000 * 60 * 60 * 3))
-    idle_time=$idle_limit
-    id=999
-    while id $((++id)) &>/dev/null; do
-        new_idle_time=$(sudo -u \#$id xprintidle 2>/dev/null) ||:
-        if [[ $new_idle_time && $new_idle_time -lt $idle_time ]]; then
-            idle_time=$new_idle_time
-        fi
-    done
-    if (( idle_time < idle_limit )); then
-        idle=false
-    else
-        idle=true
+  export DISPLAY=:0
+  # 3 hours, assume a movie might run that long.
+  idle_limit=$((1000 * 60 * 60 * 3))
+  idle_time=$idle_limit
+  id=999
+  while id $((++id)) &>/dev/null; do
+    new_idle_time=$(sudo -u \#$id xprintidle 2>/dev/null) ||:
+    if [[ $new_idle_time && $new_idle_time -lt $idle_time ]]; then
+      idle_time=$new_idle_time
     fi
+  done
+  if (( idle_time < idle_limit )); then
+    idle=false
+  else
+    idle=true
+  fi
 }
 
-if [[ $1 == check ]]; then
-    check=true
-else
-    check=false
+force=false
+check=false
+if [[ $1 ]]; then
+  case $1 in
+    check)
+      check=true
+      ;;
+    force)
+      force=true
+      ;;
+    *)
+      echo "$0: error: unexpected arg" >&2
+      exit 1
+      ;;
+  esac
 fi
 
-check-idle
+idle=true
+if ! $force; then
+  check-idle
+fi
 
 fnd="findmnt --types btrfs --noheading"
 for x in $($fnd --output "SOURCE" --nofsroot | sort -u); do
-    mnt=$($fnd --output "TARGET" --first-only --source $x)
-    [[ $mnt ]] || continue
+  mnt=$($fnd --output "TARGET" --first-only --source $x)
+  [[ $mnt ]] || continue
 
-    if ! $idle; then
-        btrfs scrub cancel $mnt &>/dev/null ||:
-        continue
-    fi
-    if $check; then
-        continue
-    fi
+  if ! $idle; then
+    btrfs scrub cancel $mnt &>/dev/null ||:
+    continue
+  fi
+  if $check; then
+    continue
+  fi
 
-    # for comparing before and after balance.
-    # the log is already fairly verbose, so commented.
-    # e btrfs filesystem df $mnt
-    # e df -H $mnt
-    if btrfs filesystem df $mnt | grep -q "Data+Metadata"; then
-        for usage in $dusage; do
-            e btrfs balance start -dusage=$usage -musage=$usage $mnt
-        done
-    else
-        e btrfs balance start -dusage=0 $mnt
-        for usage in $dusage; do
-            e btrfs balance start -dusage=$usage $mnt
-        done
-        e btrfs balance start -musage=0 $mnt
-        for usage in $musage; do
-            e btrfs balance start -musage=$usage $mnt
-        done
-    fi
-    # e btrfs filesystem df $mnt
-    # e df -H $mnt
-    date=$(
-        btrfs scrub status $mnt | \
-            sed -rn 's/^\s*scrub started at (.*) and finished.*/\1/p'
-        )
-    if [[ $date ]]; then
-        date=$(date --date="$date" +%s)
-        # if date is sooner than 90 days ago
-        # the wiki recommends 30 days or so, but
-        # it makes the comp lag like shit for a day,
-        # so I'm going with 90 days.
-        if (( date > $(date +%s) - 60*60*24*30 )); then
-            echo "cron: skiping scrub of $mnt"
-            continue
-        fi
+  # for comparing before and after balance.
+  # the log is already fairly verbose, so commented.
+  # e btrfs filesystem df $mnt
+  # e df -H $mnt
+  if btrfs filesystem df $mnt | grep -q "Data+Metadata"; then
+    for usage in $dusage; do
+      e btrfs balance start -dusage=$usage -musage=$usage $mnt
+    done
+  else
+    e btrfs balance start -dusage=0 $mnt
+    for usage in $dusage; do
+      e btrfs balance start -dusage=$usage $mnt
+    done
+    e btrfs balance start -musage=0 $mnt
+    for usage in $musage; do
+      e btrfs balance start -musage=$usage $mnt
+    done
+  fi
+  # e btrfs filesystem df $mnt
+  # e df -H $mnt
+  date=$(
+    btrfs scrub status $mnt | \
+      sed -rn 's/^\s*scrub started at (.*) and finished.*/\1/p'
+      )
+  if [[ $date ]]; then
+    date=$(date --date="$date" +%s)
+    # if date is sooner than 90 days ago
+    # the wiki recommends 30 days or so, but
+    # it makes the comp lag like shit for a day,
+    # so I'm going with 90 days.
+    if (( date > $(date +%s) - 60*60*24*30 )); then
+      echo "cron: skiping scrub of $mnt"
+      continue
     fi
-    e btrfs scrub start -Bd $mnt
+  fi
+  e btrfs scrub start -Bd $mnt
 done
index e4958f5fd85d11954666b617cfa1a97322386db7..df59a3ef652cc96d94cf9844931de7417994bb32 100755 (executable)
@@ -411,7 +411,7 @@ pi ${p1[@]}
 
 ######## fix evbug bug ######
 case $(debian-codename-compat) in
-  xenial|bionic)
+  xenial|bionic|focal)
     # noticed in flidas. dunno if it affects any others
     #https://bugs.launchpad.net/ubuntu/+source/module-init-tools/+bug/240553
     #https://wiki.debian.org/KernelModuleBlacklisting
index 5c802ca05887e22b6c38624c8ede14160abc1c8d..73d7a0a89345c7c4b34bd99d7f53295924c58b3e 100755 (executable)
@@ -428,6 +428,9 @@ EOF
 Package: *
 Pin: release n=bionic,o=Ubuntu
 Pin-Priority: -100
+Package: firefox
+Pin: release n=bionic,o=Ubuntu
+Pin-Priority: 500
 EOF
 
     sd /etc/apt/preferences.d/etiona-sa <<'EOF'
@@ -443,6 +446,9 @@ EOF
     fi
     ;;
 esac
+
+# 2020-03-03 old file
+rm -fv /etc/apt/preferences.d/radicale
 ######### end universal pinned packages ######
 
 ##### begin automatic upgrades (after checkrestart has been installed) ####
@@ -1610,6 +1616,11 @@ fi
 # note: to see when it was last run,
 # ser list-timers
 
+case $HOSTNAME in
+  kd)
+    sgo btrbkrust.timer
+    ;;
+esac
 
 end_msg <<'EOF'
 In mate settings settings, change scrolling to two-finger,
index 13a5176b05311abfb841dc303c4597bc13919bc9..21767404a53cfed9b1c045d79aa124f7f541c3f6 100755 (executable)
--- a/dsremote
+++ b/dsremote
@@ -25,6 +25,6 @@ if [[ ! $host || $host == -h ]]; then
     exit 1
 fi
 
-rlu $host /a/bin/distro-setup/
+bbk -t $host
 ssh $host /a/bin/distro-setup/distro-begin
 ssh $host /a/bin/distro-setup/distro-end
diff --git a/filesystem/etc/apt/preferences.d/radicale b/filesystem/etc/apt/preferences.d/radicale
deleted file mode 100644 (file)
index 073b78a..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-Package: firefox
-Pin: release a=unstable
-Pin-Priority: 500
index 520380a5fca45faa9e077161b1bcb59757efe823..36c64a6b6fa8efc003ac0b6874c75d1cc3e410e4 100755 (executable)
@@ -8,10 +8,12 @@ tmp=${tmp%:}
 tmp=${tmp#:}
 PATH=$tmp
 
-rm -f {/p/c/firefox-main-profile,/p/c/firefox-main-profile,/p/c/firefox-vpn2-profile,/mnt/z/firefox-vpn-profile}/compatibility.ini
+# -allow-downgrade good enough?
+#rm -f {/p/c/firefox-main-profile,/p/c/firefox-main-profile,/p/c/firefox-vpn2-profile,/mnt/z/firefox-vpn-profile}/compatibility.ini
 
-if type -P abrowser &>/dev/null; then
-  abrowser "$@"
+# abrowser is 2 releases behind, so prefer firefox for now
+if type -P firefox &>/dev/null; then
+  firefox -allow-downgrade "$@"
 else
-  firefox "$@"
+  abrowser -allow-downgrade "$@"
 fi
index 3e987fa613c1612a784ddb79ab16e25d2229e9c4..7af85a153406f9eddd790871c50b3bcbb1e72294 100644 (file)
@@ -3,3 +3,4 @@ kw
 x2
 x3
 frodo
+sy
diff --git a/pkgs b/pkgs
index db4f7c2b2d21a5f919e5dc35202c946fe679d023..e644f6ef56b77e3d038372d169c12d65f28ef816 100644 (file)
--- a/pkgs
+++ b/pkgs
@@ -49,6 +49,8 @@ p2=(
 # python3-autopep8 is nice, etiona only has python2 version, not bothering
 # to setup a conditional or pin to nabia.
 
+# metastore is for /p/c commit hook to store user/perms
+
 
 p3=(
   at
@@ -146,6 +148,7 @@ p3=(
   mdadm
   meld
   memtester
+  metastore
   mhonarc
   moreutils
   mps-youtube
@@ -179,6 +182,7 @@ p3=(
   qemu-user-static
   qrencode
   readline-doc
+  rename
   reportbug
   rfkill
   rng-tools