mostly fixes
authorIan Kelling <ian@iankelling.org>
Tue, 4 Mar 2025 12:24:19 +0000 (07:24 -0500)
committerIan Kelling <ian@iankelling.org>
Tue, 4 Mar 2025 12:29:35 +0000 (07:29 -0500)
beetag
brc
brc2
distro-end
filesystem/etc/kaya.conf [new file with mode: 0644]
filesystem/etc/profile.d/environment.sh
filesystem/usr/local/bin/rootsshsync
filesystem/usr/local/bin/switch-mail-host
path_add-function [moved from path-add-function with 98% similarity]
sl/.iank/path-add-function [deleted symlink]
sl/.iank/path_add-function [new symlink]

diff --git a/beetag b/beetag
index 92c238038e639c6c43996504dfd4a371a6b91144..2816f7c608d42d9f170320f12d19003c94ac1c6a 100755 (executable)
--- a/beetag
+++ b/beetag
@@ -591,7 +591,8 @@ beetag()  {
               echo "$line_int | ${ls_lines[i]}"
               line_int+=1
             done
-          } | less -F
+            # returns 141 if you hit q before going to the end.
+          } | less -F || [[ $? == 141 ]]
           beetag-track-select
           if $got_track; then
             break
diff --git a/brc b/brc
index aa451e8f62ea9e163a054f22612a6e7bd206e919..aff932d17e918efe04a643917c025dc5a9ae655e 100644 (file)
--- a/brc
+++ b/brc
@@ -67,7 +67,6 @@ fi
 
 CDPATH=.
 
-
 # remove all aliases. aliases provided by the system tend to get in the way,
 # for example, error happens if I try to define a function the same name as an alias
 unalias -a
@@ -93,7 +92,8 @@ PS4='$LINENO+ '
 # perhaps its fixed in newer git version, which fails to make for me
 # this note is from 6-2014.
 # still broken in flidas.
-#shopt -s nullglob
+# Giving it a shot in 2025 again!
+shopt -s nullglob
 
 # make tab on an empty line do nothing
 shopt -s no_empty_cmd_completion
@@ -109,7 +109,6 @@ shopt -s cmdhist
 # enable **
 shopt -s globstar
 
-
 # inside emacs fixes
 if [[ $LC_INSIDE_EMACS ]]; then
   # EMACS is used by bash on startup, but we dont need it anymore.
@@ -301,10 +300,10 @@ export SL_INFO_DIR=/p/sshinfo
 
 # * include files
 
-if [[ -s $bashrc_dir/path-add-function ]]; then
-  source $bashrc_dir/path-add-function
+if [[ -s $bashrc_dir/path_add-function ]]; then
+  source $bashrc_dir/path_add-function
   if [[ $SSH_CLIENT ]]; then
-    path-add $bashrc_dir
+    path_add $bashrc_dir
   fi
 fi
 
@@ -323,7 +322,7 @@ if [[ $SOE ]]; then
 fi
 
 # go exists here
-path-add --ifexists /usr/local/go/bin
+path_add --ifexists /usr/local/go/bin
 
 # Wrap source command to look in alternate directory in conjunction with
 # sl().
@@ -2992,7 +2991,7 @@ sk-p() {
 shellcheck-except() {
   local quotes others
   quotes=2048,2064,2068,2086,2119,2206,2254,2231
-  others=2029,2032,2033,2054,2164,2317
+  others=2029,2032,2033,2054,2164,2190,2317
   shellcheck -e $quotes,$others "$@" || return $?
 }
 # wrapper for shellcheck with better defaults.
@@ -3000,8 +2999,6 @@ sk() {
   # see https://savannah.gnu.org/maintenance/fsf/bash-style-guide/ for justifications
   local quotes others
   local -i ret=0
-  quotes=2048,2064,2068,2086,2119,2206,2254,2231
-  others=2029,2032,2033,2054,2164,2317
   shellcheck-except -ax -W 999  "$@" || ret=$?
   if (( ret >= 1 )); then
     echo "A template comment to disable is now in clipboard. eg: # shellcheck disable=SC2206 # reason"
@@ -3876,8 +3873,6 @@ if [[ $- == *i* ]]; then
     # did work in 5.1 something. It did not work in emacs. And, one time
     # it just randomly output to the terminal. Not worth it.
 
-    unset IFS
-
     if [[ $HISTFILE ]]; then
       # save history. if our filesystem went read-only or something, continue on
       history -a ||:
@@ -4542,9 +4537,9 @@ d1() {
 
 # * stuff that makes sense to be at the end
 
-
-# best practice
-unset IFS
+# note, if we unset IFS, that will mess up completion scripts which
+# maybe try to set it back to its original value and don't have the
+# logic for unsetting it.
 
 if [[ -s "$HOME/.rvm/scripts/rvm" ]]; then
   # shellcheck disable=SC1091
diff --git a/brc2 b/brc2
index 08fb32dbef249e4300deae5b2e11bc11c6b40e8a..802aa551141150ac12f6903546f4070c912e4707 100644 (file)
--- a/brc2
+++ b/brc2
@@ -52,19 +52,19 @@ his() {
 }
 
 
-source /a/bin/distro-setup/path-add-function
-path-add /a/exe
+source /a/bin/distro-setup/path_add-function
+path_add /a/exe
 # add this with absolute paths as needed for better security
-#path-add --end /path/to/node_modules/.bin
+#path_add --end /path/to/node_modules/.bin
 ## for yarn, etc
-#path-add --end /usr/lib/node_modules/corepack/shims/
+#path_add --end /usr/lib/node_modules/corepack/shims/
 
 # pip3 --user things go here:
-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.10.
-path-add --ifexists --end /p/bin
+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.10.
+path_add --ifexists --end /p/bin
 
 case $HOSTNAME in
   sy|bo)
@@ -639,6 +639,11 @@ beetadd() {
   fi
   beet import --set totag=t $single_track_arg $genre_arg $rating_arg "$import_path"
   function err-cleanup() {
+    # If we run `beet import --set`, and import an album, the set works
+    # at the album level and the track level. Removing from album is
+    # supposed to remove from tracks too, but of course we have imported
+    # non-album tracks. Note, it seems we can just ignore album level
+    # tags for things like rating and genre that aren't smart tags.
     if beet ls -a totag:t | grep -q .; then
       beet modify -ay totag:t 'totag!'
     fi
@@ -715,17 +720,6 @@ beetconvert() {
 
 nav_convert_query="^genre:spoken-w ^genre:skit ^lesser_version:t rating:3..5"
 
-# Export beets ratings into navidrome
-beetrating() {
-  local ssh_prefix
-  source /p/c/domain-info
-  if [[ $HOSTNAME != "$d_host" ]]; then
-    ssh_prefix="ssh b8.nz"
-  fi
-  # shellcheck disable=SC2016 # obvious reason
-  beet ls -f '$rating $path' $nav_convert_query | $ssh_prefix beetrating-stdin
-}
-
 
 # This deletes files in the converted directory which should no longer
 # be there due to a rename of the unconverted file.
@@ -772,6 +766,17 @@ beetsmartplaylists() {
   rmdir /tmp/ianbeetstmp
 }
 
+# Export beets ratings into navidrome
+beetrating() {
+  local ssh_prefix
+  source /p/c/domain-info
+  if [[ $HOSTNAME != "$d_host" ]]; then
+    ssh_prefix="ssh b8.nz"
+  fi
+  # shellcheck disable=SC2016 # obvious reason
+  beet ls -f '$rating $path' $nav_convert_query | $ssh_prefix beetrating-stdin
+}
+
 # internal function for beetrating, in case we need to ssh
 beetrating-stdin() {
   local tmp rating path cpath sqlpath userid
@@ -1389,9 +1394,37 @@ apache-header() {
 # limitations under the License.
 
 EOF
+}
+
+apache-header-fsf() {
+  # First paragraph is to avoid people being confused about why a
+  # file is apache licensed.
+  cat <<'EOF'
+# FSF follows the GNU license recommendations at
+# https://www.gnu.org/licenses/license-recommendations.en.html. They
+# recommend that small programs, < 300 lines, be licensed under the
+# Apache License 2.0. This file contains or is part of one or more small
+# programs. If a small program grows beyond 300 lines, FSF will likely
+# change to change its license to a recommended GPL license.
+
+# Copyright 2025 Free Software Foundation
 
+# 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.
+
+EOF
 }
 
+
 # apply apache to git tracked bash files + README, except files with A?GPL3 header.
 apache-apply-repo() {
   for f in $(git ls-files); do
@@ -1405,6 +1438,11 @@ apache-apply-repo() {
 }
 
 apache-apply() {
+  local header_suffix
+  if [[ $1 == -* ]]; then
+    header_suffix="$1"
+    shift
+  fi
   for file; do
     if [[ ! -e $file ]]; then
       echo '#!/bin/bash' >$file
@@ -1413,17 +1451,21 @@ apache-apply() {
     if head -n1 "$file"| grep -E '^#!/' &>/dev/null; then
       {
         head -n1 "$file"
-        apache-header
+        apache-header$header_suffix
         tail -n+2 "$file"
       } | sponge "$file"
     else
       {
-        apache-header
+        apache-header$header_suffix
         cat "$file"
       } | sponge "$file"
     fi
   done
 }
+apache-fsf() {
+  apache-apply -fsf "$@"
+}
+
 # strip out the apache license from a file.
 apache-strip() {
   # shellcheck disable=SC2044 # meh
@@ -3139,9 +3181,9 @@ pakaraoke() {
 }
 
 pfind() { #find *$1* in $PATH
-  [[ $# != 1 ]] && { echo requires 1 argument; return 1; }
+  if [[ $# != 1 ]]; then echo requires 1 argument; return 1; fi
   local pathArray
-  IFS=: pathArray=($PATH); unset IFS
+  IFS=: pathArray=($PATH)
   find "${pathArray[@]}" -iname "*$1*"
 }
 
@@ -4097,7 +4139,7 @@ rep() {
       break
     fi
   done
-  paths="/p/c /p/profanity-config /b/bash_unpublished"
+  paths="/p/c/ /p/profanity-config/ /b/bash_unpublished/ /c/ /f/s/fsf/ /f/backup-scripts/ /f/gluestick/"
   find $paths -not \( -name .svn -prune -o -name .git -prune \
        -o -name .hg -prune -o -name .editor-backups -prune \
        -o -name .undo-tree-history -prune \) 2>/dev/null | grep -iP --color=auto -- "$*" ||:
@@ -4267,10 +4309,10 @@ export KALEIDOSCOPE_DIR=/a/opt/Kaleidoscope
 
 # They want to be added to the start, but i think
 # that should be avoided unless we really need it.
-path-add --end ~/.npm-global
+path_add --ifexists --end ~/.npm-global
 
 
-path-add --end $HOME/.cargo/bin
+path_add --end $HOME/.cargo/bin
 
 if type -P rg &>/dev/null; then
   # --no-messages because of annoying errors on broken symlinks
@@ -4365,7 +4407,7 @@ mpvyt() {
 }
 
 # taken from default changes to bashrc and bash_profile
-path-add --end --ifexists $HOME/.rvm/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
 
@@ -4726,9 +4768,6 @@ export BASEFILE_DIR=/a/bin/fai-basefiles
 # fi
 
 
-# best practice
-unset IFS
-
 # https://wiki.archlinux.org/index.php/Xinitrc#Autostart_X_at_login
 # i added an extra condition as gentoo xorg guide says depending on
 # $DISPLAY is fragile.
index 4ea6549ad9c3c7e393770c96f64e5e58a9acf906..178e8949ef7ce01ae6b11de4bcdcb8c7edfe4ce5 100755 (executable)
@@ -1652,7 +1652,7 @@ esac
 # pressing tab after sdf here:
 # scp sdfbash: set +o noglob: command not found
 # in t11, bash 5.1.16. this fixes it.
-sudo sed -ri 's/([[:space:]]*)(\$reset)$/\1set +o noglob #$reset/' /usr/share/bash-completion/bash_completion
+sudo sed -ri 's/^([[:space:]]*)(\$reset)$/\1set +o noglob #$reset/' /usr/share/bash-completion/bash_completion
 
 rm -fv /home/iank/.mpv/watch_later
 rm -rf /home/iank/.mpv
diff --git a/filesystem/etc/kaya.conf b/filesystem/etc/kaya.conf
new file mode 100644 (file)
index 0000000..d851a9b
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/bash
+#
+# Config file for Kaya, a restic backup wrapper
+#
+# This will be sourced by bash & systemd EnvironmentFile
+
+#backup_root=/srv/backups/kaya
+#backup_root=/backup/kaya
+backup_root=/mnt/r2/fsf/kaya
+
+# set if using non-default port as in 'rest-server --listen :PORT'
+# local_port=8000
+remote_port=8777        # some aribtrary port
index 31d55bb182f6d654ec4cc3a4775570f77b050370..8fb607200533b6b6cb1ed2a7b8efa1e30d5232a3 100644 (file)
@@ -3,30 +3,30 @@
 # Exports here get inherited by X, that is the only reason to do things
 # here. However, they do not get sent with sl().
 
-if [ -f $HOME/path-add-function ]; then
-  . $HOME/path-add-function
-  path-add /usr/sbin /usr/local/sbin /a/exe /a/opt/bin
+if [ -f $HOME/path_add-function ]; then
+  . $HOME/path_add-function
+  path_add /usr/sbin /usr/local/sbin /a/exe /a/opt/bin
   # if usr merge, dont need it
   if [[ ! -L /sbin ]]; then
-    path-add /sbin
+    path_add /sbin
   fi
-  path-add --end $HOME/.cabal/bin
-  path-add --end /snap/bin
+  path_add --ifexists --end $HOME/.cabal/bin
+  path_add --end /snap/bin
 
 
   # ~/.local is newer, eg ruby 3.0+
-  path-add --ifexists --end $HOME/.gem/ruby/*/bin $HOME/.local/share/gem/ruby/*/bin
+  path_add --ifexists --end $HOME/.gem/ruby/*/bin $HOME/.local/share/gem/ruby/*/bin
 
   if [ -r /etc/alternatives/java_sdk ]; then
     export JAVA_HOME=/etc/alternatives/java_sdk
-    path-add /etc/alternatives/java_sdk
+    path_add /etc/alternatives/java_sdk
   fi
 
   export GUIX_PROFILE=/root/.config/guix/current
   if [ -f $GUIX_PROFILE/etc/profile ]; then
     . $GUIX_PROFILE/etc/profile
   fi
-  path-add $HOME/.guix-profile/bin
+  path_add --ifexists $HOME/.guix-profile/bin
   export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale
 
 fi
index 278aad7cc9ff095998a2abd9bbbff17554c57ee0..887fbb5adb13a30dc3d4ddcd15410d90ab87d56e 100755 (executable)
@@ -47,7 +47,9 @@ find $user_ssh_dir -xtype l -exec rm '{}' \;
 # -L resolve links
 rsync --exclude=/h --exclude=/h.pub \
       --exclude=/hrsa --exclude=/hrsa.pub \
-      --exclude /config --exclude /confighome -rtL --delete $user_ssh_dir/ /root/.ssh
+      --exclude /config --exclude /confighome --exclude=/work -rtL --delete $user_ssh_dir/ /root/.ssh
+# copy of work key with no pass for kaya.
+rsync -a /q/root/work /root/.ssh
 if [[ -e /q/root/h ]]; then
   cp -a /q/root/{h,hrsa}{,.pub} /root/.ssh
 fi
index a0079b4d554a81c41e12c7719e20381eb1f632d1..21227f71f1f06cc988e65819a53bdcea488b9a6f 100755 (executable)
@@ -88,12 +88,15 @@ pull_reexec=false
 mp_args="-m /o,/a,/q,/qd,/qr"
 check_installed=false
 orig_args=("$@")
-if ! temp=$(getopt -l check-installed,force,pull-reexec,help afioh "$@"); then
+if ! temp=$(getopt -l check-installed,force,pull-reexec,help 2afioh "$@"); then
   err "args invalid. args=$*"
 fi
 eval set -- "$temp"
 while true; do
   case $1 in
+    -2)
+      host2_only=true
+      ;;
     -a) snapshot_arg=resume ;;
     --force|-f)
       force=true
@@ -134,19 +137,9 @@ source /a/bin/bash_unpublished/source-state
 direction=$1
 host=$2
 
-case $script_name in
-  switch-mail-host)
-    if [[ $MAIL_HOST != "$HOST2" ]]; then
-      mail_only=true
-    fi
-    ;;
-  switch-host2)
-    host2_only=true
-    ;;
-  *)
-    err unexpected script name
-    ;;
-esac
+if ! $host2_only && [[ $MAIL_HOST != "$HOST2" ]]; then
+  mail_only=true
+fi
 
 if $mail_only; then
   mp_args="-m /o"
similarity index 98%
rename from path-add-function
rename to path_add-function
index 251c56139f7b098df16a6f28334e6e24d01b6da5..3662140bdde7aa806333aadafbde29759af5ee63 100644 (file)
@@ -24,8 +24,7 @@
 
 # avoiding bashisms so it can be used in edge cases where I don't have bash,
 # however, I'm not super confident that I've avoided them all
-#
-path-add() {
+path_add() {
   local help="usage: path_add [options] PATH...
 --help:     print this
 --end:      adds to end of path, which will give it lowest priority
@@ -57,6 +56,7 @@ path-add() {
   if ! test "$1"; then
     return 0
   fi
+  ifs="$IFS"
   IFS=:
   # build up the path without the components we want to add
   for y in $PATH; do
@@ -76,7 +76,7 @@ path-add() {
     fi
   done
 
-  unset IFS
+  IFS="$ifs"
   PATH="$newpath"
   for x in "$@"; do
     if ! $ifexists || [ -d "$x" ]; then
diff --git a/sl/.iank/path-add-function b/sl/.iank/path-add-function
deleted file mode 120000 (symlink)
index e5050c8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../../path-add-function
\ No newline at end of file
diff --git a/sl/.iank/path_add-function b/sl/.iank/path_add-function
new file mode 120000 (symlink)
index 0000000..f9c2955
--- /dev/null
@@ -0,0 +1 @@
+../../path_add-function
\ No newline at end of file