From 40235f5626c75a9e8c9313e807f91fc71d54a050 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Sat, 21 Feb 2026 08:00:45 -0500 Subject: [PATCH] misc fixes and improvements --- brc | 13 +++-- brc2 | 28 ++++++++++- btrfsmaint | 40 +++++++-------- distro-end | 49 +++++-------------- filesystem/usr/local/bin/btrbk-run | 2 +- fsf-script-lib | 11 +++++ .../systemd/system/wg-quick-tr-pre@.service | 5 +- .../etc/systemd/system/wg-quick-tr@.service | 3 +- .../systemd/system/wg-quick-tr-pre@.service | 5 +- .../etc/systemd/system/wg-quick-tr@.service | 3 +- .../systemd/system/wg-quick-tr-pre@.service | 5 +- .../etc/systemd/system/wg-quick-tr@.service | 3 +- .../systemd/system/wg-quick-tr-pre@.service | 5 +- .../etc/systemd/system/wg-quick-tr@.service | 3 +- .../systemd/system/wg-quick-tr-pre@.service | 5 +- .../etc/systemd/system/wg-quick-tr@.service | 3 +- .../systemd/system/wg-quick-tr-pre@.service | 5 +- .../etc/systemd/system/wg-quick-tr@.service | 3 +- .../systemd/system/wg-quick-tr-pre@.service | 5 +- .../etc/systemd/system/wg-quick-tr@.service | 3 +- .../systemd/system/wg-quick-tr-pre@.service | 5 +- .../etc/systemd/system/wg-quick-tr@.service | 3 +- .../systemd/system/wg-quick-tr-pre@.service | 5 +- .../etc/systemd/system/wg-quick-tr@.service | 3 +- pkgs | 31 +++++++++++- 25 files changed, 143 insertions(+), 103 deletions(-) diff --git a/brc b/brc index 72f1e96..69994e0 100644 --- a/brc +++ b/brc @@ -1554,18 +1554,23 @@ etailg() { } # mail related # shellcheck disable=SC2120 # we expect to pass arguments in use outside this file -etail() { +etailbg() { ngset ta /var/log/exim4/mainlog /var/log/exim4/*main /var/log/exim4/paniclog /var/log/exim4/*panic -n 200 "$@" ngreset } -etailm() { - ta /var/log/exim4/mainlog -n 200 "$@" + +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 "$@" } etail2() { - ta /var/log/exim4/nonnmain -n 200 "$@" + tail -F /var/log/exim4/nonnmain -n 200 "$@" } + # shortcut for tail -F + highlighting if we have it. tailf() { if type -t batcat >/dev/null; then diff --git a/brc2 b/brc2 index 2b90ce3..0268d26 100644 --- a/brc2 +++ b/brc2 @@ -385,7 +385,7 @@ crypttab-open() { for f in $(awk '{print $1}' /etc/crypttab | grep -v '#'); do m cryptdisks_start $f done - } +} # note: this is incomplete and untested. # https://wiki.archlinux.org/index.php/Install_Arch_Linux_from_existing_Linux#Creating_a_chroot @@ -5048,3 +5048,29 @@ pull-iankfsf() { m sl mail.fsf.org pull-iankfsf fi } + + +dummy-pkg() { + local ver="$1" + local pkg="$2" + if ! pcheck $pkg; then + e "warning: this will overwrite an installed package" + fi + local tmpdir="$(mktemp -d)" + # it puts the deb in .., so use a subdir to stay contained + mkdir $tmpdir/sub + cd "$tmpdir/sub" + # edited from output of equivs-control ubuntu-system-adjustments + cat >$pkg </dev/null || return 0 export XAUTHORITY=/home/iank/.Xauthority @@ -75,7 +68,7 @@ Normally, no options are needed. nonidle user and run in a loop every 20 seconds for 10 minutes. ---dryrun Just print out what we would do. +--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. @@ -98,16 +91,16 @@ ret=0; getopt -T || ret=$? [[ $ret == 4 ]] || { echo "Install util-linux for enhanced getopt" >&2; exit 1; } check=false -dryrun=false +dry_run=false force=false stats=true -temp=$(getopt -l help,check,dryrun,force,no-stats h "$@") || usage 1 +temp=$(getopt -l help,check,dry_run,force,no-stats h "$@") || usage 1 eval set -- "$temp" while true; do case $1 in --check) check=true ;; - --dryrun) dryrun=true ;; + --dry_run) dry_run=true ;; --force) force=true ;; --no-stats) stats=false ;; -h|--help) usage ;; @@ -116,7 +109,7 @@ while true; do esac shift done -readonly check dryrun force stats +readonly check dry_run force stats ##### end command line parsing ######## @@ -175,9 +168,10 @@ EOF if $check; then if ! $locked; then - if $dryrun; 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 @@ -190,16 +184,16 @@ EOF # e df -H $mnt if btrfs filesystem df $mnt | grep -q "Data+Metadata"; then for usage in $dusage; do - e ionice -c 3 btrfs balance start -dusage=$usage -musage=$usage $mnt + dr ionice -c 3 btrfs balance start -dusage=$usage -musage=$usage $mnt done else - e ionice -c 3 btrfs balance start -dusage=0 $mnt + dr ionice -c 3 btrfs balance start -dusage=0 $mnt for usage in $dusage; do - e ionice -c 3 btrfs balance start -dusage=$usage $mnt + dr ionice -c 3 btrfs balance start -dusage=$usage $mnt done - e ionice -c 3 btrfs balance start -musage=0 $mnt + dr ionice -c 3 btrfs balance start -musage=0 $mnt for usage in $musage; do - e ionice -c 3 btrfs balance start -musage=$usage $mnt + dr ionice -c 3 btrfs balance start -musage=$usage $mnt done fi date= @@ -215,7 +209,7 @@ EOF ) fi if ! $force && [[ $date ]]; then - if $dryrun; then + if $dry_run; then echo "$0: last scrub finish for $mnt: $date" fi date=$(date --date="$date" +%s) @@ -223,18 +217,18 @@ EOF # the wiki recommends 30 days or so, but # I'm going with 60 days. if (( date > EPOCHSECONDS - 60*60*24*60 )); then - if $dryrun; then + if $dry_run; then echo "$0: skiping scrub of $mnt, last was $(( (EPOCHSECONDS - date) / 60/60/24 )) days ago, < 30 days" fi continue fi fi # btrfsmaintenance does -c 2 -n 4, but I want lowest pri. - e btrfs scrub start -Bd -c 3 $mnt + dr btrfs scrub start -Bd -c 3 $mnt # 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 - # a scrub after downtime. So, just do one disk per day. +xc # 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 d09a62c..5e8e366 100755 --- a/distro-end +++ b/distro-end @@ -70,30 +70,6 @@ sudo() { m() { printf "$pre %s\n" "$*"; "$@"; } e() { printf "$pre %s\n" "$*"; } -dummy-pkg() { - ver="$1" - pkg="$2" - if ! pcheck $pkg; then - return 0 - fi - tmpdir="$(mktemp -d)" - # it puts the deb in .., so use a subdir to stay contained - mkdir $tmpdir/sub - cd "$tmpdir/sub" - # edited from output of equivs-control ubuntu-system-adjustments - cat >$pkg <