From: Ian Kelling Date: Thu, 5 Feb 2026 22:50:27 +0000 (-0500) Subject: bug fix sl, add feature, refactor for simplicity X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=e5b5e5cb3878f488d4aa3d8975a2b65134264d68;p=distro-setup bug fix sl, add feature, refactor for simplicity --- diff --git a/brc b/brc index 9a8de91..fde7dcb 100644 --- a/brc +++ b/brc @@ -806,7 +806,7 @@ tsl() { # Gets all the essential disk info on a machine. In case it gets ill, this # will help us know the expected state. disk-info() { - local cmds cmd + local cmds cmd cmd_name mapfile -t cmds <<'EOF' tail -n +1 /proc/mdstat /etc/mdadm/mdadm.conf /etc/fstab /etc/crypttab lsblk @@ -816,6 +816,8 @@ btrfs fi show EOF for cmd in "${cmds[@]}"; do + cmd_name="${cmd%% *}" + command -p $cmd_name &>/dev/null || continue # we dont have btrfs on some old hosts cat < info_sec )); then - #echo "d4 $files_sec > $info_sec" - do_rsync=true - fi - fi - sync_dirname=${SL_FILES_DIR##*/} - if [[ ! $SL_FILES_DIR ]]; then echo 'error: missing SL_FILES_DIR env var' >&2 return 1 fi - if $do_rsync; then - # todo: it would be nice if we did this with -v, but - # only showed the output if the command lasted more than - # about 4 seconds. + + if [[ $host_type == sync ]] && ! $pre_synced; then m RSYNC_RSH="ssh ${args[*]}" $sl_rsync_cmd -rptL --delete $SL_FILES_DIR "$remote": - fi - if $do_rsync || ! $haveinfo; then - if [[ $sshinfo && -e $sshinfo ]]; then rm -f $sshinfo; fi + sshinfo=$SL_INFO_DIR/$EPOCHSECONDS-$host_type-"$remote" [[ -e $SL_INFO_DIR ]] || mkdir -p $SL_INFO_DIR - # debug - #echo d3: $sshinfo printf "%s\n" "$extra_info" >$sshinfo chmod 666 $sshinfo fi + if [[ $host_type == sync ]]; then if (( ${#@} )); then # in the past, I used ${@@Q} passed to a bash subshell. Then @@ -3331,7 +3351,7 @@ sl() { # didn't see any benefit to doing it that way (perhaps forgot what # I originally saw in it). mq command ssh "${args[@]}" "$remote" \ - LC_USEBASHRC=t . $sync_dirname/.bashrc\; "$@" + LC_USEBASHRC=t . $sync_dirname/.bashrc\; "$@" elif [[ ! -t 0 ]]; then # This case is when commands are being piped to ssh. # Normally, no bashrc gets sourced. @@ -3349,6 +3369,12 @@ sl() { fi # this function inspired from https://github.com/Russell91/sshrc } +# sl dev notes: +# +# todo: it would be nice if -v would do verbose rsync, but only show the +# output if it took longer than 4 seconds or so. +# todo: try running slowdo on verbose ssh + slr() { sl --rsync "$@"