bunch of misc updates
authorIan Kelling <ian@iankelling.org>
Sun, 5 Apr 2020 14:30:50 +0000 (10:30 -0400)
committerIan Kelling <ian@iankelling.org>
Sun, 5 Apr 2020 14:30:50 +0000 (10:30 -0400)
38 files changed:
.gitconfig
brc
brc2
btrbk-run
distro-begin
distro-end
distro-pkgs
email-date.py
filesystem/etc/cron.d/ian
filesystem/etc/profile.d/environment.sh
filesystem/usr/local/bin/irc [new file with mode: 0755]
filesystem/usr/local/bin/mycheckrestart
filesystem/usr/local/bin/myupgrade
filesystem/usr/share/applications/emacsmail.desktop [new file with mode: 0644]
i3-sway/common.conf
i3-sway/i3.conf
install-my-scripts
machine_specific/btrbk/filesystem/etc/systemd/system/btrbk.timer
mail-route
mail-setup
mailclean
mailtest-check
mount-latest-remote
mount-latest-subvol
myi3status [new file with mode: 0644]
mymimes
pkgs
subdir_files/.config/i3/config
subdir_files/.config/sakura/sakura.conf
subdir_files/.config/sway/config
subdir_files/.config/systemd/user/arbtt.service
subdir_files/.gnupg/gpg.conf
subdir_files/sieve/lists.sieve
subdir_files/sieve/liststest.sieve
switch-mail-host
system-status
trusted-network
untrusted-network

index 839cb5f57c76cdb66b236707223779f5b5827081..8c769eada45a2a27565f24ca8a82b57a123015d5 100644 (file)
@@ -5,11 +5,12 @@ email = iank@fsf.org
 [alias]
 # Always use the git lg alias instead of git log.  It's too easy to get
 # confused by not seeing branches in git log output.
-lg = log --graph --decorate
+lg = log --graph
+lgstat = log --stat --graph --pretty=format:'%h %ad- %s [%an]'
 co = checkout
 s = status
 ci = commit
-lol = log --graph --decorate --pretty=oneline --abbrev-commit --all
+lol = log --graph --pretty=oneline --abbrev-commit --all
 dt = difftool
 
 [core]
diff --git a/brc b/brc
index 08ad4067ce22bdb7d4742cbeb8aa0e8d7ba1d8c7..b881920cc87c4df584dd29caabad9e5b71b2ec2c 100644 (file)
--- a/brc
+++ b/brc
@@ -295,6 +295,14 @@ c4() { c /var/log/exim4; }
 
 caa() { git commit --amend --no-edit -a; }
 
+cf() {
+  for f; do
+    hr
+    echo "$f"
+    hr
+    cat "$f"
+  done
+}
 caf() {
   # shellcheck disable=SC2033
   find -L $1 -type f -not \( -name .svn -prune -o -name .git -prune \
@@ -493,8 +501,10 @@ eless() {
 }
 eqcat() {
   exiqgrep -i | while read -r i; do
-    exim -Mvh $i; hr; exim -Mvb $i; hr;
-    exigrep $i /var/log/exim4/mainlog; hr
+    m exim -Mvh $i
+    m exim -Mvb $i
+    hr
+    m exigrep $i /var/log/exim4/mainlog | cat ||:
   done
 }
 
@@ -624,7 +634,7 @@ gdkill() {
 }
 
 gr() {
-  grep -iIP --color=auto "$@"
+  grep -iIP --color=auto "$@" || return $?
 }
 
 grr() { # grep recursive
@@ -652,7 +662,10 @@ hrcat() { local f; for f; do [[ -f $f ]] || continue; hr; echo "$f"; cat "$f"; d
 # main command to use:
 # hub pull-request --no-edit
 # --no-edit means to use the first commit\'s message as the pull request message.
-# Also, you need to use a feature branch, not master in your fork.
+# If that fails, try doing
+# hub pull-request --no-edit -b UPSTREAM_OWNER:branch
+# where branch is usually master. it does the pr against your current branch.
+#
 # On first use, you input username/pass and it gets an oath token so you dont have to repeat
 # it\'s at ~/.config/hub
 hub() {
@@ -666,6 +679,8 @@ hub() {
     wget -P /a/opt $up
     tar -C /a/opt -zxf /a/opt/$uptar
     rm -f /a/opt/$uptar
+  fi
+  if ! which hub &>/dev/null; then
     sudo /a/opt/$updir/install
   fi
 
@@ -898,25 +913,29 @@ r() {
 }
 
 rl() {
+  readlink -f "$@"
+}
+
+rsd() {
   # rsync, root is required to keep permissions right.
   # rsync  --archive --human-readable --verbose --itemize-changes --checksum \(-ahvic\) \
     #                                  --no-times --delete
   # basically, make an exact copy, use checksums instead of file times to be more accurate
   rsync -ahvic --delete "$@"
 }
-rld() {
+rsa() {
   # like rlu, but dont delete files on the target end which
   # do not exist on the original end.
   rsync -ahvic "$@"
 }
 complete -F _rsync -o nospace rld rl rlt
 
-rlt() {
+rst() {
   # rl without preserving modification time.
   rsync -ahvic --delete --no-t "$@"
 }
 
-rlu() { # [OPTS] HOST PATH
+rsu() { # [OPTS] HOST PATH
   # eg. rlu -opts frodo /testpath
   # relative paths will expanded with readlink -f.
   opts=("${@:1:$#-2}") #  1 to last -2
@@ -971,6 +990,7 @@ safe_rename() { # warn and dont rename if file exists.
 sb() { # sudo bash -c
   # use sb instead of s is for sudo redirections,
   # eg. sb 'echo "ok fine" > /etc/file'
+  # shellcheck disable=SC2034
   local SUDOD="$PWD"
   sudo -i bash -c "$@"
 }
@@ -1035,13 +1055,15 @@ sgu() {
 
 
 sk() {
+  # 2029: "unescaped, this expands on the client side." yes, I know how ssh works
+  # 2164: "Use 'cd ... || exit' or 'cd ... || return' in case cd fails." i have automatic error handling
   # 2086: unquoted $var
   # 2046: unquoted $(cmd)
   # 2068: Double quote array expansions to avoid re-splitting elements.
   # 2119: Functions with optional args get bad warnings when none are passed.
   # 2033: too many false positives for thing that will never work, passing shell function to find.
   # i had -x as an arg, but debian testing(stretch) doesn\'t support it
-  shellcheck -x -e 2086,2046,2068,2119,2033 "$@" || return $?
+  shellcheck -x -e 2029,2164,2086,2046,2068,2119,2033 "$@" || return $?
   # had this before. not sure what it is 2119
 }
 
@@ -1178,6 +1200,13 @@ psnetns() {
 
 m() { printf "%s\n" "$*";  "$@"; }
 
+uptime() {
+  if type -p uprecords &>/dev/null; then
+    uprecords -B
+  else
+    uptime
+  fi
+}
 
 virshrm() {
   for x in "$@"; do virsh destroy "$x"; virsh undefine "$x"; done
@@ -1274,6 +1303,8 @@ if [[ $- == *i* ]]; then
       history -a # save history
     fi
 
+    # assigned in brc2
+    # shellcheck disable=SC1303
     if [[ $jr_pid ]]; then
       if [[ -e /proc/$jr_pid ]]; then
         kill $jr_pid
@@ -1301,7 +1332,7 @@ if [[ $- == *i* ]]; then
     fi
 
     # faster than sourceing the file im guessing
-    if [[ -e /dev/shm/iank-status ]]; then
+    if [[ -e /dev/shm/iank-status && ! -e /tmp/quiet-status ]]; then
       eval $(< /dev/shm/iank-status)
     fi
     if [[ ! $SSH_CLIENT && $MAIL_HOST != "$HOSTNAME" ]]; then
@@ -1311,7 +1342,6 @@ if [[ $- == *i* ]]; then
 
     # set titlebar
     #echo -ne "$title_escape ${PWD/#$HOME/~} \007"
-
   }
   PROMPT_COMMAND=prompt-command
 
@@ -1326,7 +1356,7 @@ if [[ $- == *i* ]]; then
     # one is running, otherwise, show nothing
     if [[ $1 == prompt-command ]]; then
       set --
-     fi
+    fi
     if [[ ${#BASH_ARGC[@]} == 1 ]]; then
       echo -ne "$_title_escape ${PWD/#$HOME/~} "
       printf "%s" "$*"
@@ -1334,14 +1364,18 @@ if [[ $- == *i* ]]; then
     fi
   }
 
-  # for titlebar.
-  # condition from the screen man page i think.
-  # note: duplicated in tx()
-  if [[ $TERM == *(screen*|xterm*|rxvt*) ]]; then
-    trap 'settitle "$BASH_COMMAND"' DEBUG
-  else
-    trap DEBUG
-  fi
+  # this is busted. for example, this wont work:
+  # x=$(mktemp); cp a $x
+  # I havnt figured out why, bigger fish to fry.
+  #
+  # # for titlebar.
+  # # condition from the screen man page i think.
+  # # note: duplicated in tx()
+  # if [[ $TERM == *(screen*|xterm*|rxvt*) ]]; then
+  #   trap 'settitle "$BASH_COMMAND"' DEBUG
+  # else
+  #   trap DEBUG
+  # fi
 
 fi
 
diff --git a/brc2 b/brc2
index d8a0358bbfab74bcabe5610208bcece1cb07039a..eb8c06f8280ceed152e5797f23f5f6d4d9b7944a 100644 (file)
--- a/brc2
+++ b/brc2
@@ -17,7 +17,7 @@ path-add /a/exe
 path-add --end ~/.local/bin
 path-add --ifexists --end /a/work/libremanage
 path-add --ifexists --end /a/opt/adt-bundle*/tools /a/opt/adt-bundle*/platform-tools
-path-add --ifexists --end /a/opt/scancode-toolkit-3.0.2
+path-add --ifexists --end /a/opt/scancode-toolkit-3.10.
 
 export WCDHOME=/a
 
@@ -109,7 +109,6 @@ EOF
 
 bbk() { # btrbk wrapper
 
-  local pid
   c /
   local active=true
   systemctl is-active btrbk.timer || active=false
@@ -125,7 +124,7 @@ bbk() { # btrbk wrapper
   install-my-scripts
   jrun -p btrbk btrbk-run "$@"
   if $active; then
-    if (( $ret )); then
+    if (( ret )); then
       echo bbk: WARNING: btrbk.timer not restarted due to failure
     else
       ser start btrbk.timer
@@ -140,26 +139,12 @@ 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.
   # Note, an alternative without systemd would be something like ts.
   # Note: I tried doing cmd | pee "sudo systemd-cat" cat, but that
   # had some problems like ctrl-c didnt work or something.
-  local pid pattern sedscript cmd_name ended
+  local pattern sedscript cmd_name
   ret=0
   case $1 in
     -p)
@@ -178,7 +163,7 @@ jrun() { # journal run. run args, log to journal, tail and grep the journal.
   # normal action for it. There might be a way, unsure.
   jr_pid=$!
   systemd-cat -t "$cmd_name" "$@" || ret=$?
-  if (( $ret )); then
+  if (( ret )); then
     echo "jrun: ERROR: $* returned $ret"
   fi
   # This justs lets the journal output its last line
@@ -197,6 +182,7 @@ sm() {
   return $ret
 }
 
+# shellcheck disable=SC2120
 lipush() {
   # note, i had --delete-excluded, but that deletes all files in --exclude-from on
   # the remote site, which doesn't make sense, so not sure why i had it.
@@ -276,7 +262,7 @@ chrome() {
   if type -p chromium &>/dev/null; then
     cmd=chromium
   else
-    cd
+    cd /
     cmd="schroot -c stretch chromium"
     CHROMIUM_FLAGS='--enable-remote-extensions' $cmd &r
   fi
@@ -674,13 +660,11 @@ mbenable() {
   local mb=$1
   dst=/m/4e/$mb
   src=/m/md/$mb
-  set -x
-  [[ -e $src ]] || { set +x; return 1; }
-  mv -T $src $dst || { set +x; return 1; }
-  ln -s -T $dst $src
-  /a/exe/lnf /m/.mu ~
+  [[ -e $src ]] || { echo "src:$src does not exist"; return 1; }
+  m mv -T $src $dst
+  m ln -s -T $dst $src
+  m /a/exe/lnf /m/.mu ~
   mu index --maildir=/m/4e
-  set +x
 }
 mbdisable() {
   local mb=$1
@@ -824,7 +808,7 @@ resolvcat() {
   fi
   if systemctl is-enabled systemd-resolved &>/dev/null || [[ $(systemctl is-active systemd-resolved ||:) != inactive ]]; then
     hr; m ser status systemd-resolved | cat || :
-    hr; m systemd-resolve --status
+    hr; m systemd-resolve --status | cat
   fi
 
 }
@@ -836,6 +820,9 @@ reresolv() {
   if [[ $(systemctl is-active dnsmasq ||:) != inactive ]]; then
     sudo systemctl restart dnsmasq
   fi
+  if [[ $(systemctl is-active systemd-resolved ||:) != inactive ]]; then
+    sudo systemctl restart systemd-resolved
+  fi
 }
 
 # only run on MAIL_HOST. simpler to keep this on one system.
@@ -960,7 +947,7 @@ sl() {
   # inspired from https://github.com/Russell91/sshrc
 
 
-  local args info_date info_t type now tmp tmp2 old sshinfo cmd haveinfo dorsync info_sec
+  local now args remote dorsync haveinfo tmpa sshinfo tmp tmp2 type info_sec
   declare -a args tmpa
   now=$(date +%s)
 
@@ -1164,8 +1151,7 @@ trc() {
 
 
 tu() {
-  local s dir
-  dir="$(dirname "$1")"
+  local s
   if [[ -e $1 && ! -w $1 || ! -w $(dirname "$1") ]]; then
     s=s;
   fi
@@ -1237,28 +1223,18 @@ wtr() { curl wttr.in/boston; }
 
 xevkb() { xev -event keyboard; }
 
-ziva() { e "toot! i love dancing. fart"; }
-
 # * misc stuff
 
-# from curl cheat.sh/:bash_completion
-_cheatsh_complete_curl()
-{
-  local cur prev opts
-  _get_comp_words_by_ref -n : cur
-
-  COMPREPLY=()
-  #cur="${COMP_WORDS[COMP_CWORD]}"
-  prev="${COMP_WORDS[COMP_CWORD-1]}"
-  opts="$(curl -s cheat.sh/:list | sed s@^@cheat.sh/@)"
-
-  if [[ ${cur} == cheat.sh/* ]] ; then
-    COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-    __ltrim_colon_completions "$cur"
-    return 0
-  fi
+vrun() {
+  printf "running: %s\n" "$*"
+  "$@"
 }
-complete -F _cheatsh_complete_curl curl
+
+f=/a/f/ansible-configs/files/common/etc/fsf-workstation-bashrc.sh
+if [[ -e $f ]]; then
+  # shellcheck disable=SC1090
+  source $f
+fi
 
 
 
@@ -1277,7 +1253,7 @@ reset-sakura() {
     # shellcheck disable=SC2154
     setini $k $v sakura /a/c/subdir_files/.config/sakura/sakura.conf
   done <<'EOF'
-colorset1_back rgb(33,37,39
+colorset1_back rgb(33,37,39)
 less_questions true
 audible_bell No
 visible_bell No
@@ -1353,11 +1329,13 @@ export ARDUINO_PATH=/a/opt/arduino-1.8.9
 # that should be avoided unless we really need it.
 path-add --end ~/.npm-global
 
+
 path-add --end $HOME/.cargo/bin
 
 # taken from default changes to bashrc and bash_profile
-path-add --end $HOME/.rvm/bin
-path-add --end $HOME/.gem/ruby/2.3.0/bin
+path-add --end --ifexists $HOME/.rvm/bin
+# also had ruby bin dir, but moved that to environment.sh
+# so its included in overall env
 
 
 export BASEFILE_DIR=/a/bin/fai-basefiles
index dde230ee85f6b5ece47163eaf2b3448fb595b4d0..2a15864954613c5121b9c09ac01a9b558b9cb1ad 100644 (file)
--- a/btrbk-run
+++ b/btrbk-run
 # limitations under the License.
 
 
-# todo: if we cancel in the middle of a btrfs send, then run again immediately, the received subvolume doesn't get a Received UUID: field, and we won't mount it. Need to figure out a solution that will fix this.
+# todo: if we cancel in the middle of a btrfs send, then run again
+# immediately, the received subvolume doesn't get a Received UUID:
+# field, and we won't mount it. Need to figure out a solution that will
+# fix this.
 
 
 [[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
@@ -66,7 +69,7 @@ dry_run=false # mostly for testing
 rate_limit=no
 verbose=true; verbose_arg=-v
 progress_arg="--progress"
-incremental_strict=true
+incremental_strict=false
 pull_reexec=false
 
 default_args_file=/etc/btrbk-run.conf
@@ -91,7 +94,7 @@ while true; do
       ;;
     # only creates the config file, does not run btrbk
     -c) conf_only=true; shift ;;
-    -i) incremental_strict=false; shift ;;
+    -i) incremental_strict=true; shift ;;
     # bytes per second, suffix k m g
     -l) rate_limit=$2; shift 2 ;;
     # Comma separated mountpoints to backup. This has defaults set below.
@@ -133,7 +136,8 @@ if $verbose; then
 fi
 ### end options parsing
 
-if ! btrbk --version |& grep 0.29.0 >/dev/null; then
+# note, this test succeeds if not installed
+if [[ /a/opt/btrbk/btrbk -nt /usr/sbin/btrbk ]]; then
   cd /a/opt/btrbk
   m sudo make install
 fi
@@ -176,8 +180,8 @@ if [[ ! -v targets && ! $source ]]; then
     tp)
       # kd disabled temporarily while its hot and i plan to work on it.
       #targets=(frodo kd)
-      #targets=(frodo x2.b8.nz)
-      targets=(frodo)
+      targets=(frodo x2.b8.nz)
+      #targets=(frodo)
       # might not be connected to the vpn
       if timeout -s 9 6 ssh kw :; then
         targets+=(kw)
@@ -205,8 +209,8 @@ if [[ $source ]]; then
 fi
 
 
-if [[ $mountpoints ]]; then
-  for mp in ${mountpoints[@]}; do # default mountpoints to sync
+if [[ ${mountpoints[0]} ]]; then
+  for mp in ${mountpoints[@]}; do
     if [[ -e /nocow/btrfs-stale/$mp ]]; then
       die "error: $mp is stale, mount-latest-subvol first"
     fi
@@ -229,7 +233,11 @@ else
         fi
       else
         if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
-          prospective_mps+=(/o)
+          if [[ $HOST2 && $HOST2 != "$HOSTNAME" ]]; then
+            echo "skipping /o because HOST2 is not us"
+          else
+            prospective_mps+=(/o)
+          fi
         fi
       fi
       ;;
@@ -268,7 +276,7 @@ done
 if ! $pull_reexec && [[ $source ]] && $pulla ; then
   tmpf=$(mktemp)
   scp $source:/a/bin/distro-setup/btrbk-run $tmpf
-  if ! diff -q $tmpf $BASH_SOURCE; then
+  if ! diff -q $tmpf ${BASH_SOURCE[0]}; then
     e "found newer version on host $source. reexecing"
     install -T $tmpf /usr/local/bin/btrbk-run
     m /usr/local/bin/btrbk-run --pull-reexec "${orig_args[@]}"
@@ -294,7 +302,7 @@ if [[ $source ]]; then
   if ! zone=$(ssh root@$source date +%z); then
     die failed to ssh to root@$source
   fi
-  if [[ $zone != $local_zone ]]; then
+  if [[ $zone != "$local_zone" ]]; then
     die "error: dont confuse yourself with multiple time zones. $h has different timezone than localhost"
   fi
 
@@ -318,17 +326,17 @@ else
         fi
       fi
       sshable+=($h)
-      if [[ $zone != $local_zone ]]; then
+      if [[ $zone != "$local_zone" ]]; then
         die "error: dont confuse yourself with multiple time zones. $h has different timezone than localhost"
       fi
     else
       sshfail+=($h)
     fi
   done
-  if [[ ! ${sshable[@]} ]] || { ! $cron && [[ ${sshfail[@]} ]]; }; then
+  if [[ ! ${sshable[*]} ]] || { ! $cron && [[ ${sshfail[*]} ]]; }; then
     die "failed to ssh to hosts: ${sshfail[*]}"
   else
-    if [[ ${sshfail[@]} ]]; then
+    if [[ ${sshfail[*]} ]]; then
       ret=1
       e "error: failed to ssh to ${sshfail[*]} but continuing with other hosts"
     fi
index 290b14de424193ee337a63af33bc5a25ed896da6..4a071e490d5843aef610895777a02f953ff0dc7a 100755 (executable)
@@ -352,7 +352,7 @@ case $(debian-codename-compat) in
     sudo rmmod evbug ||: # might not be loaded yet
     file=/etc/modprobe.d/evbug.conf
     line="blacklist evbug"
-    if [[ $(cat $file) != $line ]]; then
+    if [[ $(cat $file) != "$line" ]]; then
       sudo dd of=$file 2>/dev/null <<<"$line"
       sudo depmod -a
       sudo update-initramfs -u
@@ -364,6 +364,7 @@ esac
 ###### link files
 # convenient to just do all file linking in one place
 sudo /a/exe/lnf -T /a/bin /b
+sudo /a/exe/lnf -T /a/f /f
 sudo /a/exe/lnf -T /nocow/t /t
 if has_p; then
   lnf -T /p/News ~/News
@@ -538,7 +539,8 @@ if has_monitor; then
 
 
   ###### install X
-  pi i3
+  # no recommends due to this bug: https://trisquel.info/en/issues/26525
+  pi --no-install-recommends i3
 
   ##### install xinput
   case $(distro-name) in
index f391912be65334e77c43d99941e09bd490f73b94..0f8a2129bf5db03d535c56acd667dcf89b9157ea 100755 (executable)
@@ -1,6 +1,8 @@
 #!/bin/bash
 # Copyright (C) 2019 Ian Kelling
 # SPDX-License-Identifier: AGPL-3.0-or-later
+
+# shellcheck source=/a/bin/ds/.bashrc
 export BRC=t; if [[ -s ~/.bashrc ]];then . ~/.bashrc;fi
 
 ### setup
@@ -164,7 +166,8 @@ sgo certbotmail.timer
 # fi
 
 
-######### begin flidas pinned packages ######
+pi debootstrap
+######### begin universal pinned packages ######
 case $(debian-codename) in
   etiona|flidas)
     sd /etc/apt/preferences.d/etiona-buster <<EOF
@@ -384,10 +387,12 @@ Package: *
 Pin: release n=bionic
 Pin-Priority: -100
 
-Package: firefox gnome-screenshot gnome-icon-theme libnautilus-extension1a gnome-settings-daemon nautilus yelp gnome-settings-daemon-schemas nautilus-data ubuntu-wallpapers gnome-control-center gnome-control-center-data gnome-control-center-faces libsnapd-glib1 ubuntu-wallpapers-bionic gir1.2-snapd-1 ubuntu-drivers-common ubuntu-docs libyelp0
-Pin: release n=bionic
-Pin-Priority: 500
 EOF
+
+    # Package: firefox gnome-screenshot gnome-icon-theme libnautilus-extension1a gnome-settings-daemon nautilus yelp gnome-settings-daemon-schemas nautilus-data ubuntu-wallpapers gnome-control-center gnome-control-center-data gnome-control-center-faces libsnapd-glib1 ubuntu-wallpapers-bionic gir1.2-snapd-1 ubuntu-drivers-common ubuntu-docs libyelp0
+    # Pin: release n=bionic
+    # Pin-Priority: 500
+
     ;;&
   *)
     if isdeb; then
@@ -395,26 +400,32 @@ EOF
     fi
     ;;
 esac
-######### end flidas pinned packages ######
+######### end universal pinned packages ######
 
 ##### begin automatic upgrades (after checkrestart has been installed) ####
-sd /etc/apt/apt.conf.d/10periodic <<'EOF'
-# this file was mostly just comments.
+# if apt-config-auto-update is installed,
+# it also has similar config, in a file 10something,
+# but i think his overrides it since its higher number.
+# This file was part of the automatic-updates package,
+# and it has a configu option to not get new package lists,
+# which seems pretty stupid to me, you cant actually upgrade
+# anything if you dont have the new package list.
+sd /etc/apt/apt.conf.d/20auto-upgrades <<'EOF'
 APT::Periodic::Update-Package-Lists "1";
 APT::Periodic::Download-Upgradeable-Packages "1";
 APT::Periodic::AutocleanInterval "7";
 APT::Periodic::Unattended-Upgrade "1";
 EOF
 
-sd /etc/apt/apt.conf.d/50unattended-upgrades  <<EOF
 # fyi: default file has comments about available options,
 # you may want to read that, do pkx unattended-upgrades
+# default is just security updates. this list found from reading
+# match_whitelist_string() in $(which unattended-upgrades)
+sd /etc/apt/apt.conf.d/50unattended-upgrades  <<EOF
 Unattended-Upgrade::Mail "root";
 Unattended-Upgrade::MailOnlyOnError "true";
 Unattended-Upgrade::Remove-Unused-Dependencies "true";
 Unattended-Upgrade::Origins-Pattern {
-  # default is just security updates. this list found from reading
-  # match_whitelist_string() in $(which unattended-upgrades)
   "o=*,l=*,a=*,c=*,site=*,n=*";
 };
 EOF
@@ -430,8 +441,8 @@ sd /etc/cron.d/myupgrade <<'EOF'
 SHELL=/bin/bash
 # default is /usr/bin:/bin
 PATH=/usr/bin:/bin:/usr/local/bin
-20 7 * * * iank myupgrade |& log-once -1 myupgrade
-0  * * * * root mycheckrestart |& log-once -1 mycheckrestart
+#20 7 * * * iank myupgrade |& log-once -1 myupgrade
+#0  * * * * root mycheckrestart |& log-once -1 mycheckrestart
 EOF
 ##### end automatic upgrades ####
 
@@ -634,15 +645,20 @@ case $codename_compat in
     pi task-gnome-desktop
     ;;
   bionic)
-    pi gnome-core
+
+    pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras mate-indicator-applet anacron
+
+    # pi gnome-core
+    # # apt-get update periodically fails with an appstream error.
+    # # this removes gnome-core, but its just a package for dependencies
+    # p -y remove appstream
+
+
     # 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'
     m systemctl --user stop gvfs-daemon
     m systemctl --user disable gvfs-daemon
-    # apt-get update periodically fails with an appstream error.
-    # this removes gnome-core, but its just a package for dependencies
-    p -y remove appstream
     ;;
 esac
 
@@ -657,7 +673,7 @@ fi
 # 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
+sudo update-alternatives --set x-www-browser /usr/bin/abrowser
 
 # TODO: some of the X programs can be removed from pall when using wayland
 
@@ -931,6 +947,8 @@ m reset-xscreensaver
 case $codename in
   etiona)
     pi arbtt
+    seru enable arbtt
+    seru start arbtt
     ;;
 esac
 
@@ -1414,6 +1432,11 @@ DEVICESCAN -a -o on -S on -n standby,q $sched \
 
 ########### misc stuff
 
+if ! type -p t &>/dev/null; then
+  pi ruby-dev libsqlite3-dev
+  gem install --user timetrap
+fi
+
 case $codename in
   # needed for debootstrap scripts for fai since fai requires debian
   flidas)
@@ -1522,7 +1545,7 @@ m /a/bin/buildscripts/pithosfly
 #   guix package --install guile
 # fi
 
-
+lnf -T /a/opt ~/src
 
 pi tor
 m /a/bin/buildscripts/tor-browser
index ab6fa6495689aecb723f9ca561d9ee368b049e46..909cacaac68dd24e2c1a2873b691658539379894 100755 (executable)
@@ -1,6 +1,7 @@
 #!/bin/bash
 # Copyright (C) 2019 Ian Kelling
 # SPDX-License-Identifier: AGPL-3.0-or-later
+# shellcheck source=/a/bin/ds/.bashrc
 if [[ -s ~/.bashrc ]];then . ~/.bashrc;fi
 
 
@@ -33,14 +34,10 @@ isdeb() {
   return 1
 }
 
-bool_opt=false # default
-long_opt=foo # default
-temp=$(getopt -l help,long-opt: hso: "$@") || usage 1
+temp=$(getopt -l help h "$@") || usage 1
 eval set -- "$temp"
 while true; do
   case $1 in
-    -s) bool_opt=true; shift ;;
-    -o|--long-opt) long_opt="$2"; shift 2 ;;
     -h|--help) usage ;;
     --) shift; break ;;
     *) echo "$0: Internal error! unexpected args: $*" ; exit 1 ;;
@@ -130,12 +127,10 @@ case $distro in
   arch|fedora) e par2cmdline ;;
 esac
 
-# needed for my tex resume
-case $distro in
-  trisquel|ubuntu|debian) e texlive-full ;;
-  arch) e texlive-most ;;
-  # fedora unknown
-esac
+# for my tex resume. commented, due to t9 gnome causing package version conflict
+# case $distro in
+#   trisquel|ubuntu|debian) e texlive-full ;;
+# esac
 
 case $distro in
   # optional dep for firefox for h.264 video
index f0903364d5e03b7eb175e8f59461cf010546c687..27860377bd8ba1d66c0b6869ccb05da9b755c7da 100755 (executable)
@@ -1,4 +1,7 @@
 #!/usr/bin/env python3
+
+# unused. was in a mail archiving script, but its too slow.
+
 from email.parser import BytesParser, Parser
 from email.policy import default
 from pathlib import Path
index 5545e139b99fc46e46c6f76b0838f49b832a60ec..a97434d45259b7e4272aa654027e066ff1334c78 100644 (file)
@@ -6,3 +6,4 @@ PATH=/usr/bin:/bin:/usr/local/bin:/a/exe
 # If theres any logged errors we didnt handle in 4 days, maybe we accidentally missed them,
 # so report if we did
 4 9 * * 5   root find /var/local/cron-errors /home/iank/cron-errors /sysd-mail-once-state -type f -mtime +4
+4 15 * * 5   iank /a/bin/ds/mailclean
index 38a775f16b15ac0db372382be4d1e2e01a3f477d..fc6e8044d034c1147275e210b9aaaaedecaaf18f 100644 (file)
@@ -1,16 +1,21 @@
+#!/bin/sh
 if [ -f $HOME/path-add-function ]; then
   . $HOME/path-add-function
   path-add /usr/sbin /usr/local/sbin /sbin /a/exe /a/opt/bin
   path-add --end $HOME/.cabal/bin
 
+  for p in $HOME/.gem/ruby/*/bin; do
+    path-add --ifexists --end $p
+  done
+
   if [ -r /etc/alternatives/java_sdk ]; then
     export JAVA_HOME=/etc/alternatives/java_sdk
     path-add /etc/alternatives/java_sdk
   fi
 
   export GUIX_PROFILE=/root/.config/guix/current
-  if [[ -e $GUIX_PROFILE/etc/profile ]]; then
-    source $GUIX_PROFILE/etc/profile
+  if [ -f $GUIX_PROFILE/etc/profile ]; then
+    . $GUIX_PROFILE/etc/profile
   fi
   path-add $HOME/.guix-profile/bin
   export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale
@@ -57,7 +62,7 @@ if [ -f /etc/fedora-release ]; then
   if ! $GPGAGENT 2>/dev/null; then
     temp="$(mktemp)"
     eval "$($GPGAGENT --homedir /p/do-not-delete --daemon --sh --write-env-file=$PID_FILE 2>$temp)"
-    temperr="$(<"$temp")"
+    temperr="$(cat "$temp")"
     [ -n "$temperr" ] && xmessage "gpg-agent stderr: $temperr"
   elif [ -r "$PID_FILE" ]; then
     . "$PID_FILE"
diff --git a/filesystem/usr/local/bin/irc b/filesystem/usr/local/bin/irc
new file mode 100755 (executable)
index 0000000..19aca3b
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/bash
+exec emacs -f znc-all
index 1d4bdaa4fa584ffb5199099d11f2408ccc90908e..e5cf601a6857c1cbb230500ff07a343db97c4873 100755 (executable)
@@ -3,8 +3,6 @@
 # SPDX-License-Identifier: AGPL-3.0-or-later
 if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi
 
-if [[ $EUID != 0 ]]; then s=sudo; fi
-
 set -eE -o pipefail
 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
 
@@ -14,7 +12,25 @@ if [[ $HOSTNAME != "$MAIL_HOST" && $hn != li.b8.nz && ! $DISPLAY ]]; then
   exit 0
 fi
 
-cmd="$s /usr/sbin/checkrestart -p"
-if [[ $($cmd | sed '/^Found 0 processes using old versions of upgraded files$/d' | wc -l) != 0 ]]; then
-  $cmd
+# note this is duplicated in /a/bin/ds/filesystem/usr/local/bin/myupgrade
+ignore_lines=(
+  "Found 0 processes using old versions of upgraded files"
+  "lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs"
+  "Output information may be incomplete."
+  "Found 0 processes using old versions of upgraded files"
+)
+out=
+while read -r line; do
+  ignore=false
+  for l in "${ignore_lines[@]}"; do
+    if [[ $line == "$l" ]]; then
+      ignore=true
+      break
+    fi
+  done
+  if $ignore; then continue; fi
+  out+="$line"$'\n'
+done < <(sudo /usr/sbin/checkrestart -p 2>&1)
+if (( ${#out} )); then
+  printf "%s" "$out" | pee cat wall
 fi
index 737cb13ccb5c7a8967ae945d2f9208735f9f2dd5..f439562b47a13fda088f48c1de2a53aa9f2cd3d7 100755 (executable)
@@ -44,17 +44,44 @@ path-add /usr/local/go/bin
 l /a/bin/buildscripts/go
 l go get -u mvdan.cc/fdroidcl
 
-cmd="sudo /usr/sbin/checkrestart -p"
-if [[ $($cmd | sed '/^Found 0 processes using old versions of upgraded files$/d' | wc -l) != 0 ]]; then
-  $cmd | pee cat wall
+# i disabled gvfs-daemon.service. I ran systemd-analyze --user dot,
+# which doesnt show why it started, so its getting started by some
+# startup script, and I dont want to track it down.
+
+# note, this is duplicated in /a/bin/ds/filesystem/usr/local/bin/mycheckrestart
+ignore_lines=(
+  "Found 0 processes using old versions of upgraded files"
+  "lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs"
+  "Output information may be incomplete."
+  "Found 0 processes using old versions of upgraded files"
+)
+out=
+while read -r line; do
+  ignore=false
+  for l in "${ignore_lines[@]}"; do
+    if [[ $line == "$l" ]]; then
+      ignore=true
+      break
+    fi
+  done
+  if $ignore; then continue; fi
+  out+="$line"$'\n'
+done < <(sudo /usr/sbin/checkrestart -p 2>&1)
+if (( ${#out} )); then
+  printf "%s" "$out" | pee cat wall
 fi
 
+if (( ${#out} )); then
+dorestart=true
+fi
+
+
 # no automatic reboot for these hosts
-if [[ $HOSTNAME == "$MAIL_HOST" || $hn == li.b8.nz ]]; then
+if [[ $HOSTNAME == "$MAIL_HOST" || $HOSTNAME == kw ]]; then
   exit 0
 fi
 
-if [[ -s /var/log/checkrestart.log ]]; then
+if [[ -s /var/log/checkrestart.log ]] || $dorestart; then
   for x in {30..1}; do
     echo "pid $PID. unattended upgrade, rebooting in $((x*10)) seconds" | sudo wall -n
     sleep 10
@@ -62,6 +89,7 @@ if [[ -s /var/log/checkrestart.log ]]; then
   for x in {30..1}; do
     if ! fuser /var/lib/dpkg/lock &> /dev/null; then
       echo "pid $PID. unattended upgrade, rebooting now" | pee cat "sudo wall -n"
+      sudo /a/bin/ds/keyscript-on
       sudo /sbin/reboot
       exit 0
     fi
diff --git a/filesystem/usr/share/applications/emacsmail.desktop b/filesystem/usr/share/applications/emacsmail.desktop
new file mode 100644 (file)
index 0000000..c7c9796
--- /dev/null
@@ -0,0 +1,12 @@
+#!/usr/bin/env xdg-open
+# copied from mutt
+[Desktop Entry]
+Version=1.0
+Type=Application
+Terminal=false
+Name[en]=emacsmail
+Exec=/a/bin/emacsmail %u
+Name=emacsmail
+MimeType=x-scheme-handler/mailto;
+NoDisplay=false
+Categories=Office;Network;Email;
index 341613f1625227948452569928f7b78a06ae3570..f5f7d21fffd6237a76d1c18339cfa914255725d5 100644 (file)
@@ -7,12 +7,16 @@ bindsym $mod+2 exec "pavucontrol"
 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+equal exec "t s w; t in"
+bindsym $mod+Home exec "t out"
+bindsym $mod+End exec "t s x; t in x"
 
 bindsym $mod+w focus parent
 bindsym $mod+e fullscreen toggle
 bindsym $mod+r exec "/a/bin/ds/xl"
 # todo, in newer i3, make this toggle split tabbed
 bindsym $mod+t layout toggle split
+bindsym $mod+Shift+t move workspace to output right
 bindsym $mod+g layout tabbed
 
 # Use Mouse+$mod to drag floating windows to their wanted position
index 1107e7b0a839b7b19befc22d54369f2ca0ec05dc..29fb0a8bf388d6ff8ad25d5b0597acc9df23057f 100644 (file)
@@ -4,7 +4,9 @@ bindsym $mod+Shift+q exec "i3-nagbar -t warning -m 'You pressed the exit shortcu
 bindsym $mod+Shift+p restart
 
 bar {
-status_command i3status
+#status_command i3status
+status_command          /usr/local/bin/myi3status
 mode hide
 hidden_state hide
+font pango:monospace 14
 }
index 6a763ef446d4c9377690802659502540866dec47..ada75a34c5678d1219316f47c0100e1be2a6dece 100755 (executable)
@@ -35,5 +35,5 @@ x="$(readlink -f -- "${BASH_SOURCE[0]}")"; cd ${x%/*} # directory of this file
 # ran. Very strange, dunno why, but rsync won't do anything unless these
 # changed, so that should fix it.
 rsync -t --chmod=755 --chown=root:root /a/bin/log-quiet/log-once switch-mail-host btrbk-run mount-latest-subvol \
-      check-subvol-stale system-status /usr/local/bin
+      check-subvol-stale system-status myi3status /usr/local/bin
 rsync -t --chmod=755 --chown=root:root /a/bin/errhandle/err /usr/local/lib
index 27113f6ca74819dbfe65e31a1927383c2baba8cb..c63b9990ea747faa8ef77a0da65727e23d61e65a 100644 (file)
@@ -2,7 +2,7 @@
 Description=Run btrbk-run once every 20 mins
 
 [Timer]
-OnCalendar=*:0/20
+OnCalendar=*:0/45
 
 [Install]
 WantedBy=timers.target
index 599c9d3878cd4718c7baa1400d79b2e0dc2d7064..600ef076d7465a033bd6cc4f60245433b1502380 100755 (executable)
@@ -6,7 +6,7 @@
 
 #     http://www.apache.org/licenses/LICENSE-2.0
 
-set -x
+#set -x
 exec &> >(logger)
 # Unless required by applicable law or agreed to in writing, software
 # distributed under the License is distributed on an "AS IS" BASIS,
@@ -24,7 +24,7 @@ Usage: mail-route up|down|show
 
 Marks tcp packets on port 25, 143 and 587 to be routed through
 a vpn ip. If called from --up/--down in openvpn, (we have multiple args) $1 is the
-tun_dev, and action is from $script_type.
+tun_dev, and action is from $script_type env variable, openvpn sets this.
 
 Is idempotent.
 
@@ -174,6 +174,8 @@ modify() {
 
 if (( $# > 1 )); then
   tun_dev=$1
+  # environment var from openvpn
+  # shellcheck disable=SC2154
   $script_type
 else
   case $1 in
index 575511dcf36bd94718271078ae17183351c44212..301fd776ce2b08494b694e6bcd867055fd10dae9 100755 (executable)
@@ -1,5 +1,4 @@
 #!/bin/bash
-# -*- eval: (outline-minor-mode); -*-
 # * intro
 # Copyright (C) 2019 Ian Kelling
 # SPDX-License-Identifier: AGPL-3.0-or-later
@@ -245,10 +244,9 @@ systemctl daemon-reload
 
 # * spamassassin
 
-if [[ $HOSTNAME != "$MAIL_HOST" ]]; then
+if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
   m systemctl stop spamassassin
   m systemctl disable spamassassin
-else
 
   # per readme.debian
   sed -i '/^\s*CRON\s*=/d' /etc/default/spamassassin
@@ -289,8 +287,7 @@ EOF
   m systemctl daemon-reload
   m systemctl restart spamddnsfix.timer
   m systemctl enable spamddnsfix.timer
-
-fi # [[ $HOSTNAME != "$MAIL_HOST" ]]
+fi
 #####   end spamassassin config
 
 
@@ -724,6 +721,10 @@ CHECK_DATA_VERIFY_HEADER_SENDER = true
 CHECK_RCPT_SPF = true
 CHECK_RCPT_REVERSE_DNS = true
 CHECK_MAIL_HELO_ISSUED = true
+
+# enable 587 in addition to the default 25, so that
+# i can send mail where port 25 is firewalled by isp
+daemon_smtp_ports = 25 : 587
 EOF
 
     m systemctl enable mailclean.timer
@@ -732,7 +733,7 @@ EOF
     ;;&
   $MAIL_HOST)
 
-    # ** exim
+    # * exim
 
     # todo, these pem files look old and useless. whats going on
     sudo rsync -ahhi --chown=root:Debian-exim --chmod=0640 \
@@ -771,7 +772,7 @@ EOF
 # man page: is used to build the local_domains list, together with "localhost"
 # iank.bid is for testing
 # mail.iankelling.org is for machines i own
-dc_other_hostnames='*.iankelling.org;iankelling.org;*zroe.org;zroe.org;$HOSTNAME.b8.nz;b8.nz'
+dc_other_hostnames='*.iankelling.org;iankelling.org;*zroe.org;zroe.org;!l2.b8.nz;*.b8.nz;b8.nz'
 
 EOF
 
@@ -791,10 +792,6 @@ EOF
     # smarthost config type, not sure. all other settings
     # would be unused in that config type.
     cat >>/etc/exim4/conf.d/main/000_local <<EOF
-# enable 587 in addition to the default 25, so that
-# i can send mail where port 25 is firewalled by isp
-daemon_smtp_ports = 25 : 587
-
 # failing message on mail-tester.com:
 # We check if there is a server (A Record) behind your hostname kd.
 # You may want to publish a DNS record (A type) for the hostname kd or use a different hostname in your mail software
@@ -941,6 +938,17 @@ if [[ -e /nocow ]]; then
   if ! grep -Fx "/nocow/exim4  /var/spool/exim4  none  bind  0 0" /etc/fstab; then
     echo "/nocow/exim4  /var/spool/exim4  none  bind  0 0" >>/etc/fstab
   fi
+  f=/etc/systemd/system/exim4.service.d/override.conf
+  if [[ ! -s $f ]]; then
+    # without this, we get these kind of errors in paniclog on shutdown:
+    # 2020-03-12 07:25:31.965 [32678] 1jCLxz-0008V4-V9 Failed to create spool file /var/spool/exim4//input//1jCLxz-0008V4-V9-D: Permission denied
+    mkdir -p /etc/systemd/system/exim4.service.d
+    cat >$f <<'EOF'
+[Unit]
+After=local-fs.target
+EOF
+    m systemctl daemon-reload
+  fi
   if ! mountpoint -q $sdir; then
     m systemctl stop exim4
     if [[ -L $sdir ]]; then
@@ -989,6 +997,11 @@ else
   m systemctl start exim4
 fi
 
+if [[ $HOSTNAME != "$MAIL_HOST" ]]; then
+  m systemctl stop spamassassin
+  m systemctl disable spamassassin
+fi
+
 
 # * mail monitoring / testing
 
@@ -1038,7 +1051,17 @@ esac
 
 
 # * misc
-m sudo -u $u ln -sf -T /m/.mu /home/$u/.mu
+sudo -u $u mkdir -p /home/$u/.cache
+set -- /m/mucache /home/$u/.cache/mu /m/.mu /home/$u/.mu
+while (($#)); do
+  target=$1
+  f=$2
+  shift 2
+  if [[ -e $f && ! -L $f ]]; then
+    rm -rf $f
+  fi
+  m sudo -u $u ln -sf -T $target $f
+done
 
 
 # /etc/alias setup is debian specific, and exim postinst script sets up
@@ -1063,3 +1086,8 @@ m sudo -u $u ln -sf -T /m/.mu /home/$u/.mu
 
 exit 0
 :
+
+# Local Variables:
+# eval: (outline-minor-mode)
+# outline-regexp: "\\( *\\)# [*]\\{1,8\\} "
+# End:
index 04c8f9da39236d02b414930c507c88bdbe34e286..8755338bb62a93d2f0ac9bcc52acb22e6398272e 100755 (executable)
--- a/mailclean
+++ b/mailclean
@@ -1,9 +1,12 @@
 #!/bin/bash
 
-set -eE -o pipefail
-trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
-x="$(readlink -f -- "$BASH_SOURCE")"; scriptdir=${x%/*}
+if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi
+source /a/bin/errhandle/err
 
+source /a/bin/bash_unpublished/source-state
+if [[ $HOSTNAME != "$MAIL_HOST" ]]; then
+  exit 0
+fi
 
 
 # find but ignore directories which dont exist, assuming first args are directories
@@ -20,7 +23,7 @@ myfind() {
       dirs+=($d)
     fi
   done
-  if [[ $dirs ]]; then
+  if (( ${#dirs[*]} )); then
     find ${dirs[@]} $@
   fi
 }
@@ -29,9 +32,9 @@ myfind() {
 # I want to hop into conversations about our mailing
 # systems there, but I don't need many old messages.
 myfind /m/md/l/qemu-devel/new -type f -mtime +14 -execdir rm -- '{}' +
-myfind /m/md/{sec,Spam,Drafts,{rtcc,sysadmin,l/outreachy-mentors}/new} -type f -mtime +100 -execdir rm -- '{}' +
+myfind /m/md/{sec,Spam,Drafts,{rtcc,sysadmin}/new} -type f -mtime +100 -execdir rm -- '{}' +
 myfind /m/md/log -type f -mtime +300 -execdir rm -- '{}' +
-myfind /m/md/dmarc -type f -mtime +14 -execdir rm -- '{}' +
+myfind /m/md/dmarc -type f -mtime +60 -execdir rm -- '{}' +
 myfind /m/md/fsfalerts -type f -mtime +10 -execdir rm -- '{}' +
 
 
@@ -39,25 +42,25 @@ myfind /m/md/fsfalerts -type f -mtime +10 -execdir rm -- '{}' +
 shopt -s nullglob
 shopt -s extglob
 
-now=$(date +%s)
-cd /m/md
-for d in ./!(*archive|Drafts)/*(cur|new) ./l/!(*archive)/*(cur|new); do
-  madearchive=false
-  leafdir=${d##*/}
-  md=${d%/*}; md=${md##*/}
-  archivebase=${d%/*/*}/${md}-myarchive
-  archive=$archivebase/$leafdir
-  for f in $d/1*; do
-    date=$($scriptdir/email-date.py $f) || echo $f
-    [[ $date ]] || continue
-    if (( date < now - 60*60*24*400 )); then
-      if ! $madearchive; then
-        echo mkdir -p ${archivebase}/{cur,tmp,new}
-        mkdir -p ${archivebase}/{cur,tmp,new}
-        madearchive=true
-      fi
-      mv $f $archive
-      echo mv $f $archive
-    fi
+
+archive() {
+  days=$1
+  shift
+  for d; do
+    [[ -d $d ]] || continue
+    leafdir=${d##*/} # cur/new
+    archivebase=${d%/*}-myarchive
+    archive=$archivebase/$leafdir
+    mkdir -p ${archivebase}/{cur,tmp,new}
+    find $d -type f -mtime +$days -name '1*' -exec mv '{}' $archive \;
+    # count=$(find $d -type f -mtime +$days -name '1*' | wc -l)
+    # if (( count )); then
+    #   echo $d $count
+    # fi
   done
-done
+}
+
+cd /m/md
+archive 400 ./!(*archive|Drafts)/*(cur|new) ./l/!(*archive)/*(cur|new)
+archive 60 ./{sysadmin,rtcc,fsfcc,fsfmembers}/{cur,new}
+archive 14 ./Junk/{cur,new}
index 7adec9281f094932ae30efee2651bbf3f65ac8cd..e0272e2327358bb967d8d3d1762a268577a3fc58 100755 (executable)
@@ -41,8 +41,4 @@ limit=$(( now - 60 * min_limit ))
 
 if (( last_sec <= limit )); then
   echo $HOSTNAME mailtest failure
-  touch /nocow/user/mailtest-failure
-  break
-else
-  rm -f /nocow/user/mailtest-failure
 fi
index 2b5ca59fd81bfdf4efbf27385e22e86bfca3b3c5..2d17f1efa7217f8bad7c550dec4f1cb758a1ebb7 100755 (executable)
@@ -18,18 +18,20 @@ trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
 
 script_dir=$(dirname $(readlink -f "$BASH_SOURCE"))
 
-if [[ ! $@ ]]; then
+if (( ! $# )); then
   echo "mount-latest-remote: error: expected 1 or more host arguments"
   exit 1
 fi
-ret=0
+
+$script_dir/install-my-scripts
+cd /usr/local
 
 for tg; do
-  scp $script_dir/{mount-latest-subvol,check-subvol-stale} \
-      root@$tg:/usr/local/bin
+  rsync -RtO bin/{mount-latest-subvol,check-subvol-stale} lib/err root@$tg:/usr/local
   ssh root@$tg bash <<'EOF'
 set -e
 chmod +x /usr/local/bin/{mount-latest-subvol,check-subvol-stale}
-/usr/local/bin/mount-latest-subvol
+# this can hang if we have an old nfs mount
+timeout -s 9 600 /usr/local/bin/mount-latest-subvol
 EOF
 done
index bce478a7c4fa77a82c753dd6ffce72124e8ffc5d..5e3dbc07422d9023810193f99c8c72eca650b1d8 100644 (file)
@@ -237,7 +237,7 @@ for vol in q a o i; do
 
   if [[ $vol == q ]]; then
     # allow to fail, user might not be logged in
-    sudo -u iank systemctl --user stop arbtt ||:
+    x sudo -u $(id -nu 1000) XDG_RUNTIME_DIR=/run/user/1000 systemctl --user stop arbtt ||:
   fi
   umount_ret=true
   unmounted=()
@@ -316,7 +316,7 @@ for vol in q a o i; do
     count=1
     for leaf in ${leaf_vols[@]}; do
       leaf_secs=$(date -d ${leaf#$vol.leaf.} +%s)
-      if (( $(date +%s) - 60*60*24*60 > leaf_secs || count > 200 )); then # 60 days
+      if (( $(date +%s) - 60*60*24*60 > leaf_secs || count > 100 )); then # 60 days
         x btrfs sub del $leaf
       fi
       count=$((count+1))
@@ -334,7 +334,7 @@ for vol in q a o i; do
   done
   if [[ $vol == q ]]; then
     # maybe this will fail if X is not running
-    sudo -u iank systemctl --user stop arbtt ||:
+    x sudo -u $(id -nu 1000) XDG_RUNTIME_DIR=/run/user/1000 systemctl --user start arbtt ||:
   fi
   stale_dir=/nocow/btrfs-stale
   rm -f $stale_dir/$d
diff --git a/myi3status b/myi3status
new file mode 100644 (file)
index 0000000..34d44da
--- /dev/null
@@ -0,0 +1,79 @@
+#!/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
+
+shopt -s nullglob
+for p in ~/.gem/ruby/*/bin; do
+  PATH="$PATH:$p"
+done
+
+
+main() {
+
+  ps_char=
+  if [[ -e /dev/shm/iank-status ]]; then
+    eval $(< /dev/shm/iank-status)
+  fi
+
+  # clocked in or out?
+  cursheet=$(sqlite3 /p/.timetrap.db "select sheet from entries where end is NULL;")
+  : ${cursheet:=out}
+
+  # maybe sometime show work and x separate
+  today=$(t today -ftotal all)
+
+  # hours remaining in the day:
+
+  # work+study in the last week, not counting today.
+  # no arg to printf for the intentional behavior of no arg
+  # shellcheck disable=SC2183
+  cache=/tmp/timetrap$(printf '%(%F)T')
+  if [[ -e $cache ]]; then
+    eval $(<$cache)
+  else
+    week=$(t display -ftotal -s '8 days ago' -e 'yesterday' all)
+    printf 'week="%s"\n' "$week" >$cache
+    week4=$(t display -ftotal -s '29 days ago' -e 'yesterday' all)
+    printf 'week4="%s"\n' "$week4" >>$cache
+  fi
+  # weekly work+study in the last 4 weeks, not counting today.
+  # todo later:
+  # 4 weeks
+  # ($x4week + $w4week + .05) /4
+  #weekly work+study in the last 16 weeks, not counting today.
+  #weekly work+study in the last 52 weeks, not counting today.
+
+  unixtime=$(date +%s)
+  midnight=$(date +%s -d 'tomorrow 00:00')
+  tmp=($(echo "scale=1; today_left=($midnight-$unixtime) / 60 / 60;
+today_left;
+done_today=($today + .05) /1;
+/* hours I could do today by working 80% of the remainder time */
+today_left * .8 + done_today;
+done_today;
+($week + .05) /1;
+($week4 + .05) /1"|bc))
+  printf "[ { \"full_text\": \""
+  if [[ $ps_char ]]; then
+    printf "%s| " "$ps_char"
+  fi
+  printf "%s | left today %s %s | today %s | week %s | 4weeks %s | %s\" } ],\n" "$cursheet" "${tmp[@]}" "$(date "+%A, %B %d, %r")"
+}
+
+# pass any arg and we just run once
+if (( $# )); then
+  main
+else
+  printf '{ "version": 1 }\n['
+  while true; do
+    main
+    sleep 5
+  done
+fi
diff --git a/mymimes b/mymimes
index 31779080ecf753c92054bba9cbf2636c9476f183..4c5c2986e25b3d1a6ecd79ae6046acd55d68c21f 100755 (executable)
--- a/mymimes
+++ b/mymimes
@@ -10,6 +10,8 @@ shopt -s extglob nullglob
 echo '[Default Applications]' >/etc/xdg/defaults.list
 sed -r '/^MimeType=/!d;s/^MimeType=//;s/;/=mpv.desktop\n/g' /usr/share/applications/mpv.desktop >>/etc/xdg/defaults.list
 
+echo x-scheme-handler/mailto=emacsmail.desktop >>/etc/xdg/defaults.list
+
 # this is the new one, according to
 # https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html
 # https://wiki.debian.org/MIME
diff --git a/pkgs b/pkgs
index c24084c35d785d3aa37f2737e789a992eee52d23..26fcc3dc1649e1b2ea9f3922e14f243e3d025037 100644 (file)
--- a/pkgs
+++ b/pkgs
@@ -82,6 +82,7 @@ p3=(
   duplicity
   eclipse
   elinks
+  etckeeper
   evince
   fdupes
   feh
@@ -151,6 +152,7 @@ p3=(
   pdfgrep
   perl-doc
   pianobar
+  pinentry-tty
   pidgin
   pidgin-otr
   pry
@@ -196,4 +198,5 @@ p3=(
   python-pygments
 )
 
+# shellcheck disable=SC2034
 pall=(${p1[@]} ${p2[@]} ${p3[@]} )
index 3d6d055b4c5d9f49af18be3ff107c0899e9b0150..14b6924acc728f040ba0a0c42602740f85873694 100644 (file)
@@ -7,12 +7,16 @@ bindsym $mod+2 exec "pavucontrol"
 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+equal exec "t s w; t in"
+bindsym $mod+Home exec "t out"
+bindsym $mod+End exec "t s x; t in x"
 
 bindsym $mod+w focus parent
 bindsym $mod+e fullscreen toggle
 bindsym $mod+r exec "/a/bin/ds/xl"
 # todo, in newer i3, make this toggle split tabbed
 bindsym $mod+t layout toggle split
+bindsym $mod+Shift+t move workspace to output right
 bindsym $mod+g layout tabbed
 
 # Use Mouse+$mod to drag floating windows to their wanted position
@@ -80,7 +84,9 @@ bindsym $mod+Shift+q exec "i3-nagbar -t warning -m 'You pressed the exit shortcu
 bindsym $mod+Shift+p restart
 
 bar {
-status_command i3status
+#status_command i3status
+status_command          /usr/local/bin/myi3status
 mode hide
 hidden_state hide
+font pango:monospace 14
 }
index 266fd060db6985f96c60e67c7d64917164ba3f5b..1fb52159e042e2143adf1aa15f4f18591188a99e 100644 (file)
@@ -5,7 +5,7 @@ disable_numbered_tabswitch=true
 visible_bell=No
 audible_bell=No
 less_questions=true
-colorset1_back=rgb(33,37,39
+colorset1_back=rgb(33,37,39)
 stop_tab_cycling_at_end_tabs=No
 colorset1_fore=rgb(192,192,192)
 colorset1_curs=rgb(255,255,255)
index 27154652bdb09c939b0eaeb568ba8734a6690f9e..7f9c2dc319dd3e87d700d4b373e77ce3da049196 100644 (file)
@@ -7,12 +7,16 @@ bindsym $mod+2 exec "pavucontrol"
 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+equal exec "t s w; t in"
+bindsym $mod+Home exec "t out"
+bindsym $mod+End exec "t s x; t in x"
 
 bindsym $mod+w focus parent
 bindsym $mod+e fullscreen toggle
 bindsym $mod+r exec "/a/bin/ds/xl"
 # todo, in newer i3, make this toggle split tabbed
 bindsym $mod+t layout toggle split
+bindsym $mod+Shift+t move workspace to output right
 bindsym $mod+g layout tabbed
 
 # Use Mouse+$mod to drag floating windows to their wanted position
index 5ac2c44685f2b340198a88e46d39e5185870a0cf..26154dd904208dc6a2848ba05b1f4f4199c6cb11 100644 (file)
@@ -1,11 +1,15 @@
 [Unit]
 Description=arbtt
+# StartLimitIntervalSec in recent systemd versions
+StartLimitInterval=0
 
 [Service]
 Type=simple
 ExecStart=/usr/bin/arbtt-capture --sample-rate=15
 Environment="DISPLAY=:0"
 Restart=always
+# time to sleep before restarting a service
+RestartSec=10
 
 [Install]
 WantedBy=default.target
index 21955c404c6c71519d090e45945dd0885202f1f9..6759281f7cfacce7458f2373b155742c5454deb6 100644 (file)
@@ -40,13 +40,13 @@ default-key B125F60B7B287FF6A2B7DF8F170AF0E2954295DF
 #keyserver hkp://pool.sks-keyservers.net
 
 #keyserver hkp://keys.openpgp.org
-#keyserver hkp://pgp.mit.edu
+keyserver hkp://pgp.mit.edu
 #keyserver hkp://keyserver.pgp.com
 #keyserver hkp://ipv4.pool.sks-keyservers.net
-keyserver hkp://keys.gnupg.net
+#keyserver hkp://keys.gnupg.net
 #keyserver hkp://keyserver.ubuntu.com
 #keyserver hkp://keyring.debian.org
-keyserver keyserver.ubuntu.com
+#keyserver keyserver.ubuntu.com
 
 # more secure hkps, but had problems with my gpg version
 #keyserver hkps://hkps.pool.sks-keyservers.net
index 35a23550f8f059a1cd5734e1a1a756471cc62ebb..5ff6a68294059c2b8a4db62631d34857394b443d 100644 (file)
@@ -100,6 +100,12 @@ if anyof (
          }
 
 
+if anyof (
+    header :contains "list-id" "<license-review.lists.opensource.org>"
+    ) {
+    fileinto :create "l/license-discuss";
+    stop;
+         }
 
 if anyof (
     header :contains "list-id" "<~sircmpwn/sr.ht-discuss.lists.sr.ht>"
index 35a23550f8f059a1cd5734e1a1a756471cc62ebb..5ff6a68294059c2b8a4db62631d34857394b443d 100644 (file)
@@ -100,6 +100,12 @@ if anyof (
          }
 
 
+if anyof (
+    header :contains "list-id" "<license-review.lists.opensource.org>"
+    ) {
+    fileinto :create "l/license-discuss";
+    stop;
+         }
 
 if anyof (
     header :contains "list-id" "<~sircmpwn/sr.ht-discuss.lists.sr.ht>"
index df0b83605ee25fc8c7743504d18a5698278a2916..88f9d8f66fa4c5b6f2922514e65a43099eecd4ed 100644 (file)
@@ -4,12 +4,13 @@ source /usr/local/lib/err
 
 usage() {
   cat <<EOF
-Usage: ${0##*/} push|pull HOST
+Usage: ${0##*/} [OPTIONS] push|pull HOST
 
 Turn off mail receiving on OLD_HOST, run btrbk to move mail to NEW_HOST,
 turn on mail receiving on NEW_HOST.  Assumes we want to move all
 filesystems unless passing -o.
 
+-i         Disallow incremental backup.
 -o         Only btrbk /o, instead of all filesystems.
 -h|--help  Print help and exit.
 
@@ -45,11 +46,12 @@ mexit() { echo "$pre exiting with status $1"; exit $1; }
 
 force=false
 mp_args="-m /o,/q,/a"
-temp=$(getopt -l force,help owh "$@") || usage 1
+temp=$(getopt -l force,help ioh "$@") || usage 1
 eval set -- "$temp"
 while true; do
   case $1 in
     --force) force=true ;;
+    -i) incremental_arg="-i" ;;
     -o) mp_args="-m /o"; shift ;;
     -h|--help) usage ;;
     --) shift; break ;;
@@ -61,7 +63,7 @@ done
 (( $# == 2 )) || usage 1
 
 if [[ ! $HOSTNAME ]]; then
-  err '$HOSTNAME is unset'
+  err "\$HOSTNAME is unset"
   mexit 1
 fi
 
@@ -159,7 +161,7 @@ EOF
 
 
 e Running initial btrbk
-if ! m btrbk-run -v $bbk_args $mp_args; then
+if ! m btrbk-run -v $bbk_args $incremental_arg $mp_args; then
   ret=$?
   err "failed initial btrbk"
   mexit $ret
@@ -168,7 +170,7 @@ fi
 m $old_shell /a/exe/primary-setup $new_hostname
 
 e Running main btrbk
-m btrbk-run -v $bbk_args -m /o || ret=$?
+m btrbk-run -v $bbk_args $incremental_arg -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
index 430f8061c1c6611eafea56f369211c46d8804f94..c926fc76320b4c81c418251ea6c40f8952852889 100644 (file)
@@ -13,6 +13,11 @@ status_file=/dev/shm/iank-status
 shopt -s nullglob
 shopt -s dotglob
 
+for p in ~/.gem/ruby/*/bin; do
+  PATH="$PATH:$p"
+done
+
+
 verbose=false
 if [[ $1 ]]; then
   verbose=true
@@ -27,6 +32,18 @@ lo() { /usr/local/bin/log-once "$@"; }
 write-status() {
   chars=("${first_chars[@]}")
 
+  # clock us out in timetrap if are idle too long
+  export DISPLAY=:0
+  if type -p xprintidle &>/dev/null; then
+    xidle=$(xprintidle)
+    if [[ $xidle == [0-9]* ]]; then
+      now=$(sqlite3 /p/.timetrap.db "select sheet from entries where end is NULL;")
+      if [[ $now && $xidle -gt 300000 ]]; then
+        timetrap out
+      fi
+    fi
+  fi
+
   glob=(/nocow/btrfs-stale/*)
   if [[ -e ${glob[0]} ]]; then
     chars+=("STALE!")
@@ -43,9 +60,10 @@ write-status() {
   lo -1 bounce $bouncemsg
   glob=(/m/md/alerts/new/* /m/md/alerts/cur/*)
   if [[ -e ${glob[0]} ]]; then
-    chars+=("ALERT!")
+    chars+=("A")
   fi
-  if [[ -e /nocow/user/mailtest-failure ]]; then
+  tmp=(~/cron-errors/mailtest-failure*)
+  if (( ${#tmp[@]} )); then
     chars+=("MAILPING!")
   fi
 
@@ -84,6 +102,7 @@ write-status() {
     chars+=("DISTRO-END!")
   else
     f=~/.local/conflink
+    # shellcheck disable=SC2043
     for _ in 1; do
       if [[ -e $f ]]; then
         now=$(date +%s)
@@ -123,8 +142,11 @@ write-status() {
             break
           fi
 
-          untracked=$(git ls-files -o --exclude-standard)
-          if [[ $untracked && $(find $untracked -mmin $fminplus -type f -print -quit) ]]; then
+          untracked=()
+          while read -r l; do
+            untracked+=("$l")
+          done < <(git ls-files -o --exclude-standard)
+          if [[ ${untracked[0]} && $(find "${untracked[@]}" -mmin $fminplus -type f -print -quit) ]]; then
             v conflink: untracked in $d
             chars+=("CONFLINK!")
             break
@@ -181,6 +203,7 @@ write-status() {
     # Profiled it using time and also adding to the top of the file:
     # set -x
     # PS4='+ $(date "+%2N") '
+    # shellcheck disable=SC2012
     snaps=($(ls -1avdr /mnt/root/btrbk/$vol.20*|head -n1 || [[ $? == 141 ]] ))
     now=$(date +%s)
     maxtime=0
index 7cd754cf861476854f5ab6fe69f7e076b37da98a..ce1e6f428342b44dea18dbb19ce473109da54b96 100755 (executable)
@@ -9,8 +9,6 @@ trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
 # to a trusted one.
 
 if [[ -e /etc/dnsmasq.d/untrusted-network.conf ]]; then
-  rm -f /etc/dnsmasq.d/untrusted-network.conf
-
-  nscd -i hosts
-  systemctl restart dnsmasq
+  rm -f /etc/dnsmasq.d/untrusted-network.conf /etc/systemd/resolved.conf.d/untrusted-network.conf
+  reresolv
 fi
index b4fdb70e0e5304af943e683d34d0074d77c56e2b..1936de78f12341c4161166a99c85ef5e40c92388 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/bash -l
 
 set -eE -o pipefail
 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
@@ -8,8 +8,10 @@ trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
 # Usage: use when switching from a trusted network to an untrusted one,
 # like public wifi.
 
-if [[ ! -s /etc/dnsmasq.d/untrusted-network.conf ]]; then
-  cat >/etc/dnsmasq.d/untrusted-network.conf <<'EOF'
+if [[ -s /etc/dnsmasq.d/untrusted-network.conf ]]; then
+  exit 0
+fi
+cat >/etc/dnsmasq.d/untrusted-network.conf <<'EOF'
 server=8.8.4.4
 server=8.8.8.8
 server=2001:4860:4860::8844
@@ -19,6 +21,12 @@ no-resolv
 stop-dns-rebind
 EOF
 
-  nscd -i hosts
-  systemctl restart dnsmasq
-fi
+# https://wiki.archlinux.org/index.php/Systemd-resolved#Manually
+cat >/etc/systemd/resolved.conf.d/untrusted-network.conf <<'EOF'
+[Resolve]
+DNS=8.8.4.4 8.8.8.8 2001:4860:4860::8844 2001:4860:4860::8888
+Domains=~.
+EOF
+
+
+reresolv