From 671538dd70b9aa0f1b38192b51dd0716e29eb6f0 Mon Sep 17 00:00:00 2001
From: Ian Kelling <ian@iankelling.org>
Date: Tue, 15 Feb 2022 21:27:38 -0500
Subject: [PATCH] minor improvements

---
 brc          | 33 +++++++++++++++++++++++----------
 brc2         |  8 ++++----
 distro-begin |  2 +-
 iboot        | 15 ++++++++++-----
 keyscript-on | 10 ++++++++++
 sl/.iank/ex  |  1 -
 6 files changed, 48 insertions(+), 21 deletions(-)
 delete mode 120000 sl/.iank/ex

diff --git a/brc b/brc
index 0b89b66..c47fca9 100644
--- a/brc
+++ b/brc
@@ -594,8 +594,12 @@ ev() {
     echo no args
   fi
   for arg; do
-    printf "%qEOL\n" "${!arg}"
-    printf "%s" "${!arg}" |& hexdump -C
+    if [[ -v $arg ]]; then
+      printf "%qEOL\n" "${!arg}"
+      printf "%s" "${!arg}" |& hexdump -C
+    else
+      echo arg $arg is unset
+    fi
   done
 }
 
@@ -1415,16 +1419,25 @@ 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
+
+
+  # note, if you do something like this
+  # x=( prefix* )
+  # then disable the warning with:
+  # shellcheck disable=SC2206 # globbing is intended
+
+  # 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: Quoting every var I set is way too much quotes.
+  # 2068: Double quote array expansions to avoid re-splitting elements: same as above.
+  # 2033: command arg is a function name: too many false positives.
+
+
+  # these ones I had disabled, but without a good written explanation, so enabling them temporarily
   # 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 2029,2164,2086,2046,2068,2119,2033 "$@" || return $?
-  # had this before. not sure what it is 2119
+
+  shellcheck -W 999 -x -e 2029,2164,2086,2068,2033 "$@" || return $?
 }
 
 
diff --git a/brc2 b/brc2
index 6f0d016..6effa21 100644
--- a/brc2
+++ b/brc2
@@ -1288,7 +1288,7 @@ pumpa() {
   # other tiling window managers in giving up on setting it at all
   #
   xprop -root -remove _NET_WORKAREA
-  command pumpa &r
+  command pumpa & r
 }
 
 # reviewboard, used at my old job
@@ -1491,7 +1491,7 @@ tm() {
   (sleep $(calc "$* * 60") && mpv --no-config --volume 50 /a/bin/data/alarm.mp3) > /dev/null 2>&1 &
 }
 
-trg() { transmission-remote-gtk&r; }
+trg() { transmission-remote-gtk & r; }
 trc() {
   # example, set global upload limit to 100 kilobytes:
   # trc -u 100
@@ -1585,10 +1585,10 @@ vpncmd() {
   m sudo -E env "PATH=$PATH" nsenter -t $(pgrep -f "/usr/sbin/openvpn .* --config /etc/openvpn/.*client.conf") -n -m "$@"
 }
 vpnf() {
-  vpncmd sudo -E -u iank env "PATH=$PATH" abrowser -no-remote -P vpn &r
+  vpncmd sudo -E -u iank env "PATH=$PATH" abrowser -no-remote -P vpn & r
 }
 vpn2f() {
-  vpncmd sudo -u iank env "PATH=$PATH" abrowser -no-remote -P vpn2 &r
+  vpncmd sudo -u iank env "PATH=$PATH" abrowser -no-remote -P vpn2 & r
 }
 
 vpni() {
diff --git a/distro-begin b/distro-begin
index 4a1ab21..e969940 100755
--- a/distro-begin
+++ b/distro-begin
@@ -152,7 +152,7 @@ EOF
 
   sudo dd of=/etc/systemd/system/keyscriptoff.service <<'EOF'
 [Unit]
-Description=keyscriptoffIMG_20200803_221621
+Description=keyscriptoff
 
 [Service]
 Type=oneshot
diff --git a/iboot b/iboot
index 78805bf..bc84f6c 100644
--- a/iboot
+++ b/iboot
@@ -1,5 +1,7 @@
 #!/bin/bash
 
+## in development, meant to be run manually
+
 [[ $EUID == 0 ]] || exec sudo -E "$script" "$@"
 
 if ! test "$BASH_VERSION"; then echo "error: shell is not bash" >&2; exit 1; fi
@@ -9,12 +11,13 @@ trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" exit status: $?, PIPESTATUS: ${P
 
 set -x
 
+d=(/dev/mapper/crypt_dev*)
+d=${d[0]}
+
+mount -o subvol=root_trisquelnabia $d /mnt
 
-boot_part=$(awk '$2 == "/boot" {print $1}' /etc/mtab)
-boot_dev=${boot_part%[0-9]*}
-# from partition.DEFAULT
-new_boot_part=${boot_dev}4
-mount -o subvol=debianbuster_bootstrap $new_boot_part /mnt
+boot_part=$(awk '$2 == "/" {print $1}' /etc/mtab)
+mount -o subvol=boot_trisquelnabia $boot_part /mnt/boot
 
 cd /mnt
 mount -o bind /dev dev
@@ -22,3 +25,5 @@ mount -o bind /proc proc
 mount -o bind /sys sys
 mkdir -p boot/efi
 mount $(awk '$2 == "/boot/efi" {print $1}' /etc/mtab) boot/efi
+chroot .
+# then run zboot-chroot
diff --git a/keyscript-on b/keyscript-on
index f26861b..a2f056c 100755
--- a/keyscript-on
+++ b/keyscript-on
@@ -19,6 +19,16 @@ sed="sed --follow-symlinks"
 # /sbin/update-initramfs: 157: mkinitramfs: not found
 PATH="/sbin:$PATH"
 
+if [[ $INVOCATION_ID ]]; then
+  if [[ -e /b/bash_unpublished/source-state ]]; then
+    source /b/bash_unpublished/source-state
+  fi
+  if [[ $MAIL_HOST && $MAIL_HOST != $HOSTNAME ]]; then
+    echo "$0: exiting early: running under systemd as MAIL_HOST"
+    exit 0
+  fi
+fi
+
 if [[ ! -e /tmp/keyscript-off ]]; then
   if [[ $($sed -rn 's/^ID=(.*)/\1/p' /etc/os-release) == arch ]]; then
     if ! grep -q '^\s*FILES=' /etc/mkinitcpio.conf; then
diff --git a/sl/.iank/ex b/sl/.iank/ex
deleted file mode 120000
index 420c5b2..0000000
--- a/sl/.iank/ex
+++ /dev/null
@@ -1 +0,0 @@
-/b/exim-tools/ex
\ No newline at end of file
-- 
2.30.2