minor fixes, improvements
authorIan Kelling <ian@iankelling.org>
Tue, 1 Oct 2024 03:47:01 +0000 (23:47 -0400)
committerIan Kelling <ian@iankelling.org>
Tue, 1 Oct 2024 03:47:01 +0000 (23:47 -0400)
brc3
filesystem/usr/local/bin/mount-latest-subvol
filesystem/usr/local/bin/umount-funcs

diff --git a/brc3 b/brc3
index ab6bcb955da45260817b655f341acbed1b1754e3..d123a4fee1e439c51dc7b036e0a96ec830bde833 100644 (file)
--- a/brc3
+++ b/brc3
@@ -100,3 +100,22 @@ ecne-basefile() {
   s tar $attributes --numeric-owner --one-file-system -C r -cf - . | zstd -9 > /b/fai-basefiles/ECNE64.tar.zst
   echo "WARNING: remove leftover /t/mmchroot"
 }
+
+# cleans up bind mounts that got leftover by an schroot. dunno yet why
+# this happens. Based on
+# http://logan.tw/posts/2018/02/24/manage-chroot-environments-with-schroot/#list-all-schroot-sessions
+
+schroot-cleanup() {
+  local session sessions
+  sessions=$(schroot -l --all-sessions | sed 's/session://')
+  for session in $sessions; do
+    schroot -e -c $session
+  done
+}
+
+
+massix-ping() {
+  ips=(206.53.143.47 206.53.143.5 206.53.143.46 206.53.143.21 206.53.143.69 206.53.143.10 206.53.143.23 206.53.143.79 206.53.143.36 206.53.143.48 206.53.143.78 206.53.143.4 206.53.143.29 206.53.143.7 206.53.143.25 206.53.143.38 206.53.143.34 206.53.143.80 206.53.143.19 206.53.143.18 206.53.143.22 206.53.143.63 206.53.143.9 206.53.143.31 206.53.143.28 206.53.143.24 206.53.143.58 206.53.143.6 206.53.143.52 206.53.143.53 206.53.143.8 206.53.143.39 206.53.143.72 206.53.143.54 206.53.143.75 206.53.143.2 206.53.143.15 206.53.143.50 206.53.143.17 206.53.143.16 206.53.143.68 206.53.143.61 206.53.143.42 206.53.143.81 206.53.143.252 206.53.143.253 206.53.143.55 206.53.143.73 206.53.143.30 206.53.143.14 206.53.143.26 206.53.143.40 206.53.143.35 206.53.143.1 206.53.143.20 206.53.143.11 206.53.143.67 206.53.143.3 206.53.143.41 206.53.143.56 206.53.143.62 206.53.143.32 206.53.143.84 206.53.143.37 206.53.143.70 206.53.143.60 206.53.143.88 206.53.143.49 206.53.143.43 206.53.143.74 206.53.143.13 206.53.143.51 206.53.143.44 206.53.143.33 206.53.143.87 206.53.143.77 206.53.143.76 206.53.143.65 206.53.143.12 206.53.143.27 206.53.143.57 206.53.143.71)
+
+  while true; do for i in 0 10 20 30 40 50 60 70; do fping -c 1 ${ips[@]:$i:10}; sleep 10 || break; done; done
+  }
index fd2aaf41f5b6db76d7dc60552ecb1179c24ec857..f74e42c05300aef43607e88044c4032b14f7a3cc 100755 (executable)
@@ -444,7 +444,7 @@ for dir in /mnt/r7/amy/{root/root,boot/boot}_ubuntubionic /mnt/{root2/root,boot2
   vol=${dir##*/}
   root_dir=${dir%/*}
   if [[ ! -d $root_dir ]]; then
-    # this only exists on host kd currently
+    # this only exists on one host.
     continue
   fi
   # if latest is already mounted, make sure binds are mounted and move on
@@ -454,6 +454,7 @@ for dir in /mnt/r7/amy/{root/root,boot/boot}_ubuntubionic /mnt/{root2/root,boot2
     continue
   fi
   if [[ -d $dir ]]; then
+    kill_dirs=($dir)
     if ! kill-dir TERM TERM TERM INT INT HUP HUP TERM TERM TERM INT INT HUP HUP; then
       if $force; then  kill-dir KILL; fi
     fi
index 5708a51a5b66d34eec983b9ed164f814eb86a6ee..794dfcb30835414811185c12ad00a3e83495cc89 100644 (file)
@@ -45,7 +45,24 @@ get-pids() {
       dir_regex="$dir_regex|${kill_dirs[$i]}"
     fi
   done
-  pids=$(timeout 30 lsof -XF n | awk 'BEGIN { RS = "\np" }; {if($1 in printed_pids) next; for(i=2;i<=NF;i++){ if($i ~ "^n('$dir_regex')(/|$)")  { printed_pids[$1]=1; printf("%s ", $1); break} } }')
+  pids=$(timeout 15 lsof -XF n | awk 'BEGIN { RS = "\np" }; {if($1 in printed_pids) next; for(i=2;i<=NF;i++){ if($i ~ "^n('$dir_regex')(/|$)")  { printed_pids[$1]=1; printf("%s ", $1); break} } }')
+}
+
+get-pids-debug() {
+  kill_dirs=("$@")
+  get-pids
+  echo "pids: $pids"
+  first_pid=true
+  for pid in $pids; do
+    if $first_pid; then
+      ps_pids=$pid
+      first_pid=false
+    else
+      ps_pids+=,$pid
+    fi
+  done
+  e ps -f -p $ps_pids
+  ps -f -p $ps_pids
 }
 
 kill-dir() {
@@ -60,6 +77,8 @@ kill-dir() {
     # ran out of signals to try:
     if (( i == $# )); then
       return 1
+    elif (( i >= 1 )); then
+      sleep .5
     fi
     sig=${sigs[$i]}
     pid-check
@@ -73,7 +92,7 @@ kill-dir() {
         ps_pids+=,$pid
       fi
     done
-    pd -f -p $ps_pids
+    ps -f -p $ps_pids
     kill -$sig $pids
   done
 }