some fixes, mainly improvements
authorIan Kelling <ian@iankelling.org>
Fri, 3 Jan 2025 09:59:59 +0000 (04:59 -0500)
committerIan Kelling <ian@iankelling.org>
Fri, 3 Jan 2025 09:59:59 +0000 (04:59 -0500)
14 files changed:
.bashrc
brc
brc2
c [new symlink]
distro-end
filesystem/usr/local/bin/awatch
filesystem/usr/local/bin/mailbindwatchdog
fsf-script-lib [new file with mode: 0644]
i3-sway/i3.conf
mail-setup
my-update-info-dir
mymimes
primary-setup
subdir_files/.gnupg/gpg.conf

diff --git a/.bashrc b/.bashrc
index 1ace08ba3120862763a88bb6aeedb99d23fad8d6..83b54d3c5341177405b87eb1b7bfdcd448b79a16 100644 (file)
--- a/.bashrc
+++ b/.bashrc
@@ -49,7 +49,7 @@ HISTCONTROL=ignoredups
 # This works in addition to HISTCONTROL to do more flexible things
 # it could also do the same things as HISTCONTROL and thus replace it,
 # but meh. dunno why, but just " *" does glob expansion, so use [ ] to avoid it.
-HISTIGNORE='pass *:otp *:oathtool *:histrm *:h *'
+HISTIGNORE='pass *:otp *:oathtool *:histrm *:hi *:vpn[a-z]*'
 
 # note: duplicated in /a/bin/ds/filesystem/etc/profile.d/environment.sh
 umask g-w,o-w
diff --git a/brc b/brc
index 77a79d1ccbac218ff5a44df23298c8923082613b..b5ed9e1594b8d79e7bd48588c2d30977469db59a 100644 (file)
--- a/brc
+++ b/brc
@@ -341,7 +341,7 @@ mysrc() {
   fi
 }
 
-
+mysrc /a/c/fsf-script-lib
 mysrc /a/bin/small-misc-bash/ll-function
 mysrc /a/bin/distro-functions/src/package-manager-abstractions
 mysrc /a/bin/fai/fai/config/distro-install-common/bash-misc-funcs
@@ -374,6 +374,11 @@ alias 9='};'
 
 # * functions
 
+# prospect letters for short functions:
+# a: ok
+# v, u: maybe
+# w: good
+
 
 # temporary functions go here
 
@@ -737,7 +742,7 @@ datelog() {
   date +%Y-%m-%d "$@"
 }
 
-# date in log appropriate format
+# timestamp in log appropriate format
 dtl() {
   date "+%F %T" "$@"
 }
@@ -747,6 +752,27 @@ tsf() {
   command ts "%F %T" "$@"
 }
 
+
+# remove the last slog log pair. For when we start a log but end up
+# doing something not worth logging.
+slog-rm-last() {
+  local log_tmp log_dir log_path
+  local -a paths to_rm
+  log_tmp=(~/log)
+  log_dir="${log_tmp[0]}"
+  paths=($log_dir/*.s)
+  to_rm="${paths[*]: -1}"
+  paths=($log_dir/*.t)
+  rm -Iv "$to_rm" "${paths[@]: -1}"
+}
+
+# script replay
+splay() {
+  scriptreplay "$1.t" "$1.s"
+}
+
+
+
 # ts log. log command to log file.
 # usage: tsl LOG_PATH_PREFIX COMMAND...
 # example: tsl /root/command
@@ -782,6 +808,8 @@ tsl() {
   fi
 }
 
+
+
 # Gets all the essential disk info on a machine. In case it gets ill, this
 # will help us know the expected state.
 disk-info() {
@@ -1097,7 +1125,11 @@ caf() {
        -o -name .undo-tree-history -prune \) -printf '%h\0%d\0%p\n' | sort -t '\0' -n \
     | awk -F '\0' '{print $3}' 2>/dev/null | while read -r file; do
     hr "$file"
-    v "$file"
+    if type -p v &>/dev/null; then
+      v "$file"
+    else
+      cat "$file"
+    fi
     # if the file is nonempty and the last char is nonempty, it is not
     # newline terminated.
     if [[ -s "$file" && "$(tail -c 1 "$file")" ]]; then
@@ -1348,10 +1380,6 @@ dus() {
 }
 ccomp du dus
 
-# echo
-e() { printf "%s\n" "$*"; }
-err() { echo "$(date +%Y-%m-%d) ${FUNCNAME[0]}: $*" >&2; }
-
 # echo args
 ea() {
   if (( ! $# )); then
@@ -1388,6 +1416,35 @@ eva() {
   done
 }
 
+# echo variable quickly & quietly
+evq() {
+  if (( ! $# )); then
+    echo no args
+  fi
+  for arg; do
+    if [[ -v $arg ]]; then
+      printf "%s\n" "${!arg}"
+    else
+      echo arg $arg is unset
+    fi
+  done
+}
+
+
+# echo variable verbosely
+evv() {
+  if (( ! $# )); then
+    echo no args
+  fi
+  for arg; do
+    if [[ -v $arg ]]; then
+      printf "%s: %s\n" "$arg" "${!arg}"
+    else
+      echo arg $arg is unset
+    fi
+  done
+}
+
 
 # emacs ediff from cli
 ediff() {
@@ -1430,7 +1487,7 @@ etailm() {
   ta /var/log/exim4/mainlog -n 200 "$@"
 }
 etail2() {
-  ta /var/log/exim4/nondmain -n 200 "$@"
+  ta /var/log/exim4/nonnmain -n 200 "$@"
 }
 
 # shortcut for tail -F + highlighting if we have it.
@@ -2189,6 +2246,13 @@ lowr() {
   done
 }
 
+strips() {
+  # remove leading whitespace characters
+  var="${var#"${var%%[![:space:]]*}"}"
+  # remove trailing whitespace characters
+  var="${var%"${var##*[![:space:]]}"}"
+}
+
 # make filenames lowercase, remove bad chars
 low() {
   local arg new dir f
@@ -2930,7 +2994,7 @@ sk-p() {
 sk() {
   # see https://savannah.gnu.org/maintenance/fsf/bash-style-guide/ for justifications
   local quotes others ret
-  quotes=2048,2068,2086,2206,2254
+  quotes=2048,2068,2086,2119,2206,2254
   others=2029,2032,2033,2054,2164,2317
   shellcheck -x -W 999 -e $quotes,$others "$@" || ret=$?
   if (( ret >= 1 )); then
@@ -3312,37 +3376,6 @@ ssh() {
 }
 
 
-# log with script. timing is $1.t and script is $1.s
-# -l to save to ~/typescripts/
-# -t to add a timestamp to the filenames
-slog() {
-  local logdir do_stamp arg_base
-  (( $# >= 1 )) || { echo "arguments wrong"; return 1; }
-  logdir="/a/dt/"
-  do_stamp=false
-  while getopts "lt" option
-  do
-    case $option in
-      l) arg_base=$logdir ;;
-      t) do_stamp=true ;;
-      *)
-        echo error: bad option
-        return 1
-        ;;
-    esac
-  done
-  shift $((OPTIND - 1))
-  arg_base+=$1
-  [[ -e $logdir ]] || mkdir -p $logdir
-  $do_stamp && arg_base+=$(date +%F.%T%z)
-  script -t $arg_base.s 2> $arg_base.t
-}
-# script replay
-splay() {
-  #logRoot="$HOME/typescripts/"
-  #scriptreplay "$logRoot$1.t" "$logRoot$1.s"
-  scriptreplay "$1.t" "$1.s"
-}
 
 # sudo redo. be aware, this command may not work right on strange
 # distros or earlier software
@@ -3489,6 +3522,13 @@ m2() { printf "%s\n" "$*" >&2;  "$@"; }
 # echo args, then run args in background, discarding output.
 mq() { printf "%s\n" "$*";  "$@" &>/dev/null & }
 
+# print args, then prompt to confirm running them.
+ma() {
+  printf "%s\n" "$PWD $ $*"
+  read -rs || return 1
+  "$@"
+}
+
 
 # better uptime
 uptime() {
@@ -3620,18 +3660,9 @@ spark()
   _spark_echo
 }
 
-pdfwc() { local f; for f; do echo "$f" "$(pdfinfo "$f" | awk '/^Pages:/ {print $2}')"; done }
-
 
-# nvm install script appended this to my .bashrc. I dont want to run it all the time,
-# so put it in a function.
-nvm-init() {
-  export NVM_DIR="$HOME/.nvm"
-  # shellcheck disable=SC1091 # may not exist, & third party
-  [ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh"  # This loads nvm
-  # shellcheck disable=SC1091 # may not exist, & third party
-  [ -s "$NVM_DIR/bash_completion" ] && source "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
-}
+# print page count of pdf file(s)
+pdf-wc() { local f; for f; do echo "$f" "$(pdfinfo "$f" | awk '/^Pages:/ {print $2}')"; done }
 
 
 leap-year() {
@@ -4084,7 +4115,7 @@ fsplit() {
 }
 
 # histignored function
-h() {
+hi() {
   "$@"
 }
 
@@ -4220,7 +4251,7 @@ ef() {
       imax=$(( ${#args[@]} - 1 ))
       for (( i=0; i <= imax; i++ )); do
         if [[ ! ${args[$i]} ]]; then
-          unset args[$i]
+          unset "args[$i]"
         fi
       done
       # debug
@@ -4466,6 +4497,107 @@ cgr() {
   "${cmd[@]}" | gr "${grep[@]}"
 }
 
+# call on .cert lets encrypt file.
+opensslcertinfo() {
+  openssl x509 -noout -text -in "$@"
+}
+
+
+# exec a redirection for logging.
+#
+# hmm, this is not working in bash version 4.4.20(1)-release
+logexec() {
+  log_tmp=(~/log)
+  log_dir="${log_tmp[0]}"
+  mkdir -p "$log_dir"
+
+  log_path="$log_dir/$(date +%F_%H_%M_%S).log"
+  if [[ -e $log_path ]]; then
+    sleep 1
+    log_path="$log_dir/$(date +%F_%H_%M_%S).log"
+  fi
+
+  exec &> >(pee cat 'ts "%F %T" >>'$log_path)
+}
+
+## begin debug-setx background / development notes
+#
+# I often end up writing little 5-10 line scripts. To log what they are doing,
+# I was annoyed with the available options. #1 There is set -x, which usually ends up
+# being > 50% useless lines, very anoying. #2
+# m() { printf "%s\n" "$*";
+#"$@"; } that annoyingly conflicts with command
+# redirected output, and I constantly forget to add it.
+#
+# Better option: debug trap, where we can print $BASH_COMMAND. The main
+# annoying thing about this is that $BASH_COMMAND doesn't have expanded
+# variables.
+#
+# options to expand variables in a $BASH_COMMAND:
+#
+# 1. get bash to do readline's shell-expand-line. I know a hacky way
+# with read, but it wasn't reliable when I tried it in a
+# prompt_command. I could probably create a c program that uses readline
+# to do it pretty easily
+#
+# 2. Use the prompt expansion features @P, but first escape the special
+# prompt characters if there are any. This was the option I went
+# with. It has a small flaw that I realized without calling a regex
+# substitution program, my escaping is not perfect: I temporarily insert
+# a long random string to identify "\\", but it is possible this string
+# could exist in the command and then I would improperly replace
+# it. However, my use case is simply viewing commands I intend to run
+# and I don't see any reason I would intend to run a command with that
+# or that even if I did, it would cause any serious problem to have it
+# be incorrectly displayed.
+#
+# NOTE: One imperfection with both of these, is that we don't want to
+# expand $() or ``, so I look for those chars and then avoid doing it. I
+# think the only way to avoid this would be to modify bash itself in
+# order to do shell-expand-line and then use the result, just as if you
+# pressed the key for it.
+#
+# \\ -> \\\\ : creates problem matching eg: \e
+#
+# alternate:
+#
+# \134 -> RANDOM_LONG_STRING
+#
+# \\ -> \134\134 : creates problem matching \134, we need to match \134!(\134), solved by the RANDOM_LONG_STRING
+#
+# \a -> \134a
+#
+# \D{*} and \123 -> \\&
+#
+# RANDOM_LONG_STRING -> \\134
+#
+# alternate, best:
+#
+# \\ -> RANDOM_LONG_STRING
+#
+# \a -> \\a
+#
+# \D{*} and \123 -> \\&
+#
+# RANDOM_LONG_STRING -> \\\\
+#
+# # incrementally built up test cases, where the output is expected to be the same as the initial _d
+#
+# _d='ok\\\\jyes'; _d="${_d//'\\'/SUBfopguensOfRifejmuSUB}" _d="${_d//\\[adehHjlnrstT@AuvVwW\!\#\$[\]]/\\&}" _d="${_d//SUBfopguensOfRifejmuSUB/'\\\\'}"; e "$_d  +  ${_d@P}"
+#
+# _d='ok\D{z_ds}yes'; _d="${_d//'\\'/SUBfopguensOfRifejmuSUB}" _d="${_d//\\[adehHjlnrstT@AuvVwW\!\#\$[\]]/\\&}" _d="${_d//\\D\{*\}/\\&}" _d="${_d//SUBfopguensOfRifejmuSUB/'\\\\'}"; e "$_d  +  ${_d@P}"
+#
+# _d='ok\144ye\134s'; _d="${_d//'\\'/SUBfopguensOfRifejmuSUB}" _d="${_d//\\[adehHjlnrstT@AuvVwW\!\#\$[\]]/\\&}" _d="${_d//\\D\{*\}/\\&}" _d="${_d//\\[012][0-9][0-9]/\\&}" _d="${_d//\\3[0-6][0-9]/\\&}" _d="${_d//\\37[0-7]/\\&}" _d="${_d//SUBfopguensOfRifejmuSUB/'\\\\'}"; e "$_d  +  ${_d@P}"
+#
+#
+# random interesting script:
+# x=4
+# echo "\$x ${BASH_COMMAND@P}"
+# Warning: Program '/bin/bash' crashed.
+#
+## end debug-setx background / development notes
+
+
 # * stuff that makes sense to be at the end
 
 
diff --git a/brc2 b/brc2
index bf3409fe213fbe95c3d770e4260ab1b2c50575c3..ec740c06cfca445e89e4bda2e701a4b2d79289df 100644 (file)
--- a/brc2
+++ b/brc2
@@ -90,6 +90,15 @@ case $EUID in
 esac
 
 
+if [[ $EUID == 1000 ]]; then
+  nvm-enable() {
+    export NVM_DIR=/home/iank/.nvm
+    # shellcheck disable=SC1091 # may not exist, & third party
+    . "$NVM_DIR/nvm.sh"
+    # shellcheck disable=SC1091 # may not exist, & third party
+    [[ -s "$NVM_DIR/bash_completion" ]] && source "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
+  }
+fi
 
 
 # * include files
@@ -2348,9 +2357,9 @@ tt() {
   # get highest version if we have more than one.
   for f in ~/.local/share/gem/ruby/*/bin/t; do
     cmd=$f
-    done
+  done
   $cmd "$@"
-  }
+}
 
 ## work log
 #
@@ -3078,6 +3087,7 @@ mnsd() { # mount namespace + systemd network namespace
         shift 2
         ;;
       -p)
+        # note: this must call mns-setup
         pre_check="$2"
         shift 2
         ;;
@@ -3099,9 +3109,9 @@ mnsd() { # mount namespace + systemd network namespace
     final_args=(bash -c ". $tmpf")
   fi
   if [[ $pre_check ]]; then
-    if ! sudm $pre_check; then
-      m sudm nsenter -t $pid -n -m mns-setup $ns
-    fi
+    sudm $pre_check
+  else
+    mns-setup $ns
   fi
   m sudm nsenter -t $pid -n --mount=/root/mount_namespaces/$ns sudo -u $user -i "${final_args[@]}"
 }
@@ -3975,7 +3985,7 @@ torshell() {
 }
 
 eless2() {
-  less /var/log/exim4/nondmain
+  less /var/log/exim4/nonnmain
 }
 
 
@@ -5009,9 +5019,6 @@ tclear() {
   done
 }
 
-opensslcertinfo() {
-  openssl x509 -txt -in "$@"
-}
 
 # dsh on btrbk hosts
 dsb() {
diff --git a/c b/c
new file mode 120000 (symlink)
index 0000000..5157537
--- /dev/null
+++ b/c
@@ -0,0 +1 @@
+.bashrc
\ No newline at end of file
index 6b60fd4a0996a0e080f1b3bb9aa03a58001e6739..5cddca9770c4f4f731e6fe2769fbfa6ce3e2b7f7 100755 (executable)
@@ -1292,11 +1292,11 @@ sgo schrootupdate.timer
 case $distro in
   trisquel|ubuntu)
     m mkschroot -s /a/bin/fai/fai/config/files/etc/apt/sources.list.d/bookworm.list/BOOKWORM_FREE \
-      debian bookworm chromium fonts-noto-color-emoji
+      debian bookworm chromium fonts-noto-color-emoji fonts-recommended
     ;;
   debian)
     # fonts are for emojis, which tend to get used as buttons on the web.
-    pi chromium fonts-noto-color-emoji
+    pi chromium fonts-noto-color-emoji fonts-recommended
     ;;
 esac
 
index d289aedbdace78986097731e3bccac1b6237370c..5250c2027f6466bf3560f1fd79d3931a787bee39 100755 (executable)
@@ -24,4 +24,5 @@ if [[ $EUID != 1000 ]]; then
   echo "$0: error: expected EUID=1000, got:$EUID"
   exit 1
 fi
-DISPLAY=:0 /a/opt/activity-watch/aw-qt &>/home/iank/aw.log &
+echo "awatch: $(date "+%F %T") starting" >>/home/iank/aw.log
+DISPLAY=:0 /a/opt/activity-watch/aw-qt &>>/home/iank/aw.log &
index 881b1ec92b475c10bc60d27411b7e39ebc065748..3ad297a7a67e6054062aab612f39cc3bd914177d 100755 (executable)
@@ -53,4 +53,13 @@ while true; do
         ;;
     esac
   done
+
+  # settings that go away when exim gets upgraded. obviously the best way to do this would be to modify the exim package itself, but this is easier
+  caps=$(getcap /usr/sbin/exim4)
+  if [[ ! $caps ]]; then
+    echo "$0: setting capabilities, user and setuid/gid on /usr/sbin/exim4"
+    chown Debian-exim:Debian-exim /usr/sbin/exim4
+    chmod g+s,u+s /usr/sbin/exim4
+    setcap CAP_NET_BIND_SERVICE+ei /usr/sbin/exim4
+  fi
 done
diff --git a/fsf-script-lib b/fsf-script-lib
new file mode 100644 (file)
index 0000000..950d612
--- /dev/null
@@ -0,0 +1,259 @@
+#!/bin/bash
+
+# Copyright (C) 2023 Free Software Foundation <sysadmin@fsf.org>
+#
+# Note: the FSF recommends copyleft licensing for programs > 300 lines, see
+# https://www.gnu.org/licenses/license-recommendations.en.html.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+
+#     http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+## Standard functions for any bash script. Also good to source from
+## .bashrc.
+##
+## It also enables bash-bear-trap automatic error handling.
+
+# Load bash-bear trap. Only function definitions & docs after this
+# block.
+set -e
+if [[ -s /usr/local/lib/bash-bear ]]; then
+  . /usr/local/lib/bash-bear
+elif [[ -s /usr/local/lib/err ]]; then
+  # old name
+  . /usr/local/lib/err
+elif [[ $- != *i* ]]; then
+  # error if this is a script, not an interactive shell.
+  echo "error: exit 1: missing dependency: /usr/local/lib/bash-bear"
+  exit 1
+fi
+set +e
+
+
+# low pri todo: compare this to a screen or tmux log.
+slog() {
+  local log_tmp log_dir log_path
+  log_tmp=(~/log)
+  log_dir="${log_tmp[0]}"
+  mkdir -p "$log_dir"
+
+  log_path="$log_dir/$(date +%F_%H_%M_%S).log"
+  if [[ -e $log_path ]]; then
+    sleep 1
+    log_path="$log_dir/$(date +%F_%H_%M_%S).log"
+  fi
+  script -t $log_path.s 2> $log_path.t
+}
+
+
+# usage: m COMMAND...
+#
+# echo COMMAND then run it.
+m() { printf "+ %s\n" "$*";  "$@"; }
+
+# usage: e [MESSAGE...]
+#
+# echo MESSAGE.
+e() { printf "${0##*/}: %s\n" "$*"; }
+
+# usage: err [ERROR_MESSAGE...]
+#
+# Print ERROR_MESSAGE to stderr, prefixed by timestamp & current
+# function. Outside of functions, the function is "main".
+#
+# 2025-01-03 03:51:59 main: test message2
+err() { echo "$(date "+%F %T") ${FUNCNAME[1]}: $*" >&2; }
+
+### begin debug-setx related functions ###
+#
+# usage: debug-setx
+#
+# Print executing commands like "set -x", but:
+#
+# - Skips printing many boring/redundant lines. There are related
+#   functions below to modify/toggle what gets printed.
+#
+# - Related function h() to prompt before executing printed command.
+#
+# Be default, no printing of commands inside functions. To enable, either
+#
+# 1: set debug_max_stack_depth to >= 1. Default = 0.
+#
+# 2: Allow specific functions with setx-func (see its doc below).
+#
+# There is a hard-coded list of commands to skip or maybe skip. You can
+# improve this.
+#
+debug-setx() {
+
+  # Note on commands we skip printing:
+  # - read ends up being what is shown for 'while read' loops.
+
+  # for inheriting debug in subshells
+  shopt -s extdebug
+
+  debug_prompt=false
+  debug_skip=false
+  debug_force_print=false
+
+  trap _debug-setx-func DEBUG
+}
+# internal function called via debug-setx trap.
+_debug-setx-func() {
+  local doprint=false func_depth random_delimiter func
+
+  if [[ $debug_max_stack_depth ]]; then
+    func_depth=$(( debug_max_stack_depth + 2 ))
+  else
+    # at a script top level we see depth of 2: debug-setx-func main
+    func_depth=2
+  fi
+
+  if $debug_skip; then
+    debug_skip=false
+    return 0
+  fi
+
+  if $debug_prompt; then
+    doprint=true
+  fi
+
+  if $debug_force_print; then
+    debug_force_print=false
+    doprint=true
+  fi
+
+  if $debug_print_default; then
+
+    ## block for debug_print_funcs
+    if ! $doprint; then
+      for func in ${debug_print_funcs[@]}; do
+        if [[ $func == "${FUNCNAME[1}" ]]; then
+          doprint=true
+          break
+        fi
+      done
+    fi
+
+    ## block for default command & function ignoring
+    if ! $doprint && (( ${#FUNCNAME[*]} <= func_depth )); then
+      case $BASH_COMMAND in
+        e\ *|err\ *|echo\ *|printf\ *|read\ *)
+          : ;;
+        for\ *)
+          # try to print just the first for loop iteration.
+          _script_pp_cur_for="$BASH_COMMAND ${BASH_LINENO[0]} ${FUNCNAME[1]}"
+          if [[ $_script_pp_cur_for != "$_script_pp_last_for" ]]; then
+            doprint=true
+          fi
+          _script_pp_last_for="_script_pp_cur_for"
+          ;;
+        *)
+          doprint=true
+          ;;
+      esac
+    fi
+
+  fi
+
+  if $doprint; then
+    if [[ $BASH_COMMAND != *\`* && $BASH_COMMAND != *\$\(* && $BASH_COMMAND == *\$* ]]; then
+      random_delimiter=$RANDOM$RANDOM$RANDOM
+      # shellcheck disable=SC1003
+      _d="$BASH_COMMAND" _d="${_d//'\\'/SUBfopguensOfRifejmu${random_delimiter}SUB}" _d="${_d//\\[adehHjlnrstT@AuvVwW\!\#\$[\]]/\\&}" _d="${_d//\\D\{*\}/\\&}" _d="${_d//\\[012][0-9][0-9]/\\&}" _d="${_d//\\3[0-6][0-9]/\\&}" _d="${_d//\\37[0-7]/\\&}" _d="${_d//SUBfopguensOfRifejmu${random_delimiter}SUB/'\\\\'}"
+      echo "+ ${_d@P}"
+    else
+      echo "+ $BASH_COMMAND"
+    fi
+  fi
+
+  if $debug_prompt; then
+    read -rs
+    debug_prompt=false
+  fi
+}
+
+# usage: ux [COMMAND...]
+#
+# disable/unset debug-setx default command printing.
+ux() {
+  debug_print_default=false
+  "$@"
+}
+
+# usage: u1 [COMMAND...]
+#
+# Disable debug-setx printing just for the next command.
+u1() {
+  debug_skip=true
+  "$@"
+}
+
+# usage: dx [COMMAND...]
+#
+# Undo ux() and reenable debug-setx printing.
+dx() {
+  debug_print_default=true
+  "$@"
+}
+
+# usage: d1 [COMMAND...]
+#
+# For just one command, reenable debug-setx printing.
+d1() {
+  debug_force_print=true
+  "$@"
+}
+
+# usage: h [COMMAND...]
+#
+# Print the next command then wait for user to press enter (or ctrl-c to
+# exit).
+#
+# note: h = random free letter.
+h() {
+  debug_prompt=true
+  "$@"
+}
+
+# usage: setx-func [FUNCTION...]
+#
+# Do debug-setx printing within current function or FUNCTION(s) even
+# when called with function stack size greater than
+# $debug_max_stack_depth.
+setx-func() {
+  local new_func new_funcs found existing_func
+  if [[ ! -v debug_print_funcs ]]; then
+    debug_print_funcs=()
+  fi
+
+  if (( $# )); then
+    new_funcs="$*"
+  else
+    new_funcs="${FUNCNAME[0]}"
+  fi
+  for new_func in $new_funcs; do
+    found=false
+    for existing_func in ${debug_print_funcs[@]}; do
+      if [[ $existing_func == "$new_func" ]]; then
+        found=true
+        break
+      fi
+    done
+    if $found; then
+      break
+    fi
+    debug_print_funcs+=($new_func)
+  done
+}
+
+### end debug-setx related functions ###
index 52bbca6f65e350c9f75dc6bc33e4a5d94007af80..a29f08f72f2bfd69ba1d827de9e7798290998583 100644 (file)
@@ -9,6 +9,6 @@ $ex copyq
 $ex dunst
 # haven't been using it enough to justify automatically running it.]
 #$ex /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd
-$ex awatch
+$ex /usr/local/bin/awatch
 # this dies when we restart i3.
 exec_always --no-startup-id i3-event-hook
index f8e245ac52c0c2e4ed2b299fe43a329af395a982..0d71591771c416db0f30a14591346733a1fe30d9 100755 (executable)
@@ -3271,6 +3271,7 @@ EOF
     # 2022-08-07 18:44:34.043 [892491] socket bind() to port 25 for address (any IPv6) failed: Permission denied: waiting 30s before trying again (9 more tries)
     # note: the daemon gives up and dies after retrying those 9 times.
     # I came upon this by guessing and trial and error.
+       # set capability
     setcap CAP_NET_BIND_SERVICE+ei /usr/sbin/exim4
     u /etc/exim4/trusted_configs <<'EOF'
 /etc/exim4/nn-mainlog.conf
@@ -4301,6 +4302,7 @@ case $HOSTNAME in
     ;;
   li)
     soff $spamd_ser clamav-daemon unbound
+    ;;
   *)
     soff radicale mailclean.timer dovecot $spamd_ser $vpnser mailnn clamav-daemon unbound
     ;;
index 17839848a6c23dce2e5a6f037ee5738bf37dc32d..f359bbfe438fadde7e52fbc9eb78402248ac970f 100755 (executable)
@@ -20,7 +20,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+set -e; . /usr/local/lib/bash-bear; set +e
 
+sudo -v
 
 INFODIR=/usr/share/info
 sudo rm -f "$INFODIR/dir"
diff --git a/mymimes b/mymimes
index 82637c725e720f5a954db8c6815a21345eed8180..760b56c59fece0de9192496b6b2b03a0f8b597de 100755 (executable)
--- a/mymimes
+++ b/mymimes
@@ -28,9 +28,12 @@ trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
 
 shopt -s extglob nullglob
 
-echo '[Default Applications]' >/etc/xdg/defaults.list
-# make these be the default for everything they can handle
-sed -r '/^MimeType=/!d;s/^MimeType=//;s/;/=mpv.desktop\n/g' /usr/share/applications/mpv.desktop >>/etc/xdg/defaults.list
+{
+  echo '[Default Applications]'
+  # make these be the default for everything they can handle
+  sed -r '/^MimeType=/!d;s/^MimeType=//;s/;/=mpv.desktop\n/g' /usr/share/applications/mpv.desktop
+} >/etc/xdg/defaults.list
+
 sed -r '/^MimeType=/!d;s/^MimeType=//;s/;/=org.gnome.Evince.desktop\n/g' /usr/share/applications/org.gnome.Evince.desktop >>/etc/xdg/defaults.list
 
 echo x-scheme-handler/mailto=emacsmail.desktop >>/etc/xdg/defaults.list
@@ -42,7 +45,7 @@ echo x-scheme-handler/mailto=emacsmail.desktop >>/etc/xdg/defaults.list
 cp /etc/xdg/defaults.list /etc/xdg/mimeapps.list
 
 for f in /usr/share/applications/!(defaults).list; do
-    cp /etc/xdg/defaults.list /etc/xdg/${f##*/}
+  cp /etc/xdg/defaults.list /etc/xdg/${f##*/}
 done
 
 update-desktop-database
index 80d39848865e89b0d258a369399ae12c11424286..b7b0585137300927382f251e9cfab448e2833ea6 100755 (executable)
@@ -28,7 +28,8 @@ set -e; . /usr/local/lib/bash-bear; set +e
 
 script_name="${BASH_SOURCE[0]}"
 script_name="${script_name##*/}"
-pre="$script_name:${0##*/}:${SSH_CLIENT:+ $HOSTNAME:}"
+# expansion reminder: if [[ $SSH_CLIENT ]] then $HOSTNAME, otherwise expands to empty string.
+pre="$script_name:${SSH_CLIENT:+ $HOSTNAME:}"
 m() { printf "$pre %s\n"  "$*"; "$@"; }
 e() { printf "$pre %s\n"  "$*"; }
 err() { echo "[$(date +'%Y-%m-%d %H:%M:%S%z')]: $0: $*" >&2; }
@@ -51,7 +52,10 @@ if [[ $1 ]]; then
   fi
   m sed -ri "s/MAIL_HOST=.*/MAIL_HOST=$new_host/" /a/bin/bash_unpublished/source-state
 fi
+set -x
 source /a/bin/bash_unpublished/source-state
+set +x
+e HOSTNAME=$HOSTNAME
 
 # fixing up a bad state that servers got in.
 if [[ -e /dev/shm/iank-status ]]; then
@@ -96,10 +100,11 @@ fi
 
 if [[ $HOSTNAME == "$HOST2" ]]; then
   if pgrep '^Xorg$'; then
-    sudo -u iank /usr/local/bin/awatch
+    sudo -u iank /usr/local/bin/awatch
   fi
 else
-  pkill -f '^/a/opt/activity-watch/aw-qt$'
+  pkill -f '^/a/opt/activity-watch/aw-qt$' ||:
+  pkill -f '^/a/opt/activity-watch/aw-server/aw-server$' ||:
 fi
 
 
index 0dbd8961613dcf4aade21ac4d553f19ba19b9137..60801d00808c2fe552571bfd49cfaddb523192dd 100644 (file)
@@ -49,13 +49,3 @@ keyserver hkp://keys.openpgp.org
 #keyserver keyserver.ubuntu.com
 # more secure hkps, but had problems with my gpg version
 #keyserver hkps://hkps.pool.sks-keyservers.net
-
-### begin things added by enigmail
-cert-digest-algo SHA256
-no-emit-version
-no-comments
-personal-cipher-preferences AES AES256 AES192 CAST5
-personal-digest-preferences SHA256 SHA512 SHA384 SHA224
-ignore-time-conflict
-allow-freeform-uid
-### end things added by enigmail