From: Ian Kelling Date: Tue, 24 Feb 2026 01:07:58 +0000 (-0500) Subject: improvements X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=b11e6bad959e3f9d493fbbd41a8f5548ff6cccbf;p=distro-setup improvements --- diff --git a/brc b/brc index 69994e0..1793d64 100644 --- a/brc +++ b/brc @@ -1358,6 +1358,29 @@ dfp() { done } +# usage: funcp COMMAND [SECOND_INTERVAL] +# like dfp, but pass in a command name which will output a KiB integer. +# +# example, when removing a btrfs disk, waiting for its Data allocation to go down to 0: +# bf() { btrfs fi usage -k / | sed -rn '/^Data/,/S7KGNU0X708190H-root/p'|tail -n1|awk '{print $2}' | sed -r 's/[^0-9].*//'; } +# funcp bf +funcp() { + local a b mp interval + cmd=$1 + interval=${2:-90} + if [[ ! $cmd ]]; then + echo "funcp: error, missing 1st arg" >&2 + return 1 + fi + while true; do + a=$($cmd) + sleep $interval + b=$($cmd) + printf "used mib: %'d mib/min: %s gib/h: %s\n" $(( b /1000 )) $(( (b-a) / (interval * 1000 / 60 ) )) \ + $(( (b-a) / (interval * 1000000 / (60*60) ) )) + done +} + # get ipv4 ip from HOST. or if it is already a number, return that hostip() { local host="$1" @@ -1562,7 +1585,7 @@ etailbg() { etail() { tail -F /var/log/exim4/mainlog /var/log/exim4/*main /var/log/exim4/paniclog /var/log/exim4/*panic -n 200 "$@" - } +} etail1() { tail -F /var/log/exim4/mainlog -n 200 "$@" } @@ -4716,6 +4739,21 @@ dedup-node-modules() { #time /t/sc/scancode --info --classify --only-findings --max-in-memory 300000 -clpue --unknown-licenses --tallies --tallies-with-details --summary --generated --json-pp scan.json . } +# cryptsetup luksClose $1 + checks /dev/mapper for the arg. +cryptc() { + local arg="$1" + if [[ ! -e $arg && -e /dev/mapper/$arg ]]; then + arg="/dev/mapper/$arg" + echo "cryptc: path fixup: $arg" + fi + cryptsetup luksClose "$arg" +} + +# crypt open +crypto() { + cryptsetup luksOpen "$@" +} + # iptables -I without duplication. iptI() { ${*/ -I/ -C/} 2>/dev/null || "$@"; } # iptables -A without duplication. diff --git a/btrfsmaint b/btrfsmaint index bad4df8..8f56e4c 100755 --- a/btrfsmaint +++ b/btrfsmaint @@ -42,8 +42,6 @@ EOF } fi -dusage="5 10" -musage="5" check-idle() { type -p xscreensaver-command &>/dev/null || return 0 @@ -62,19 +60,8 @@ usage() { Usage: ${0##*/} [OPTIONS] Do btrfs maintence or stop if we have X and xprintidle shows a user -Normally, no options are needed. - ---check Only check if an existing maintence should be cancelled due to - nonidle user and run in a loop every 20 seconds for 10 - minutes. - --dry_run Just print out what we would do. ---force Run regardless of user idle status on all disks and do scrub - regardless of when it was last run. ---no-stats Avoid checking error statistics. Use this to avoid a rare race - condition when running --check concurrently with normal run. - -h|--help Show help @@ -90,19 +77,13 @@ EOF ret=0; getopt -T || ret=$? [[ $ret == 4 ]] || { echo "Install util-linux for enhanced getopt" >&2; exit 1; } -check=false dry_run=false -force=false -stats=true -temp=$(getopt -l help,check,dry_run,force,no-stats h "$@") || usage 1 +temp=$(getopt -l help,dry_run h "$@") || usage 1 eval set -- "$temp" while true; do case $1 in - --check) check=true ;; --dry_run) dry_run=true ;; - --force) force=true ;; - --no-stats) stats=false ;; -h|--help) usage ;; --) shift; break ;; *) echo "$0: unexpected args: $*" >&2 ; usage 1 ;; @@ -113,6 +94,32 @@ readonly check dry_run force stats ##### end command line parsing ######## +# todo: for previous scrubs, we shoudl do: +# cd /var/lib/btrfs +# for uid in *; do +# # grab 3 things out of that file: +# # scrub status:1 +# finished:1 +# t_start:1738738808 (epoch seconds roughly at the end or start of the last scrub. good enough for our purposes) +# I don't now what other status numbers are, but I should test it. +# +# Instead of canceling, we will just have a formula: +# +# $(nproc) +# +# read -r _ la1 la2 _ /dev/null - if $check; then - if ! $locked; then - if $dry_run; then - echo "$0: not idle. if this wasnt a dry run, btrfs scrub cancel $mnt" - else - echo "btrfsmaint: canceling scrub of $mnt" - btrfs scrub cancel $mnt &>/dev/null ||: - fi - fi - continue - fi - # for comparing before and after balance. - # the log is already fairly verbose, so commented. - # e btrfs filesystem df $mnt - # e df -H $mnt - if btrfs filesystem df $mnt | grep -q "Data+Metadata"; then - for usage in $dusage; do - dr ionice -c 3 btrfs balance start -dusage=$usage -musage=$usage $mnt - done - else - dr ionice -c 3 btrfs balance start -dusage=0 $mnt - for usage in $dusage; do - dr ionice -c 3 btrfs balance start -dusage=$usage $mnt - done - dr ionice -c 3 btrfs balance start -musage=0 $mnt - for usage in $musage; do - dr ionice -c 3 btrfs balance start -musage=$usage $mnt - done - fi date= scrub_status=$(btrfs scrub status $mnt) if printf "%s\n" "$scrub_status" | grep -i '^status:[[:space:]]*finished$' &>/dev/null; then @@ -208,7 +188,7 @@ EOF sed -rn 's/^\s*scrub started at (.*) and finished.*/\1/p' ) fi - if ! $force && [[ $date ]]; then + if [[ $date ]]; then if $dry_run; then echo "$0: last scrub finish for $mnt: $date" fi @@ -228,7 +208,7 @@ EOF # We normally only do one disk since this is meant to be run in # downtime and if we try to do all disks, we invariably end up doing -xc # a scrub after downtime. So, just do one disk per day. + # a scrub after downtime. So, just do one disk per day. if ! $force; then return 0 fi diff --git a/distro-end b/distro-end index 5e8e366..9d06ff0 100755 --- a/distro-end +++ b/distro-end @@ -692,11 +692,14 @@ EOF # ref: https://support.system76.com/articles/transition-firmware/ # # to manually get new firmware, - # system76-firmware-cli schedule --open - # to see a changelog, cd to - # /var/cache/system76-firmware-daemon - # extract the xz files there, one will contain a changelog. - # then to install an update: + # system76-firmware-cli schedule --open. Last time this printed + # out a directory with a changelog. + # + # But in the past, I had to go through files here + # /var/cache/system76-firmware-daemon, extracting and inspecting. eg: + # mkct; declare -i i=0; for f in /var/cache/system76-firmware-daemon/*; do mkdir $i; m tar -C $i -xf $f || continue; i+=1; done + # by the previous command including a changelog. + # To install an update: # s system76-firmware-cli schedule fi ;; @@ -2180,6 +2183,19 @@ esac # nfs server pi-nostart nfs-kernel-server + +# 10g host-to-host net + +case $HOSTNAME in + kd|frodo) + s /a/exe/cedit 10g /etc/hosts <<'EOF' +10.3.0.2 kdz kdz.b8.nz # kd zoom 10g +10.3.0.4 frodoz frodoz.b8.nz # frodo zoom +EOF + ;; +esac + + # todo, this is old, probably needs removing if [[ $HOSTNAME == tp ]]; then sd /etc/wireguard/wg0.conf <