From: Ian Kelling Date: Tue, 14 Apr 2026 16:38:18 +0000 (-0400) Subject: mostly fixy type changes X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=bfad4916299a183bfd2867143b423a97401f1a2a;p=distro-setup mostly fixy type changes --- diff --git a/brc b/brc index 22bb487..3454360 100644 --- a/brc +++ b/brc @@ -801,6 +801,17 @@ tsl() { printf "%s\n" "note: this log file contains logs before those of previous command" | ts "%F %T" | tee -a "$log_path" fi } +# This is an awk script which adds timestamps to those lines that are missing it. +# It was a very specific/odd situation which drove me to make this. Actually ran +# it from a file, gawk -F ts.awk (ts.awk had the following string). +# { +# if ($0 !~ /^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/) { +# print strftime("%Y-%m-%d %H:%M:%S") " - " $0 +# } else { +# print $0 +# } +# } + # Gets all the essential disk info on a machine. In case it gets ill, this @@ -1060,7 +1071,7 @@ cbs() { # a1 = awk {print $1} for _field in {1..20}; do - eval a$_field"() { awk '{print \$$_field}'; }" + eval a$_field"() { awk '{print \$$_field}' \"\$@\"; }" done unset _field # h1 = head -n1 @@ -1069,6 +1080,10 @@ for _num in {1..9}; do done unset _num +# awk print final field. +af() { + awk '{print $NF}' "$@" +} hexipv4() { # shellcheck disable=SC2046 disable=SC2001 disable=SC2183 # hacks, expected @@ -4921,7 +4936,8 @@ na() { # wait for PID $1 to die pidw() { -local x=$(mktemp); e $pid >$x; pidwait -e -F $x; rm $x + local pid="$1" + local x=$(mktemp); e $pid >$x; pidwait -e -F $x; rm $x } # printf string + newline diff --git a/brc2 b/brc2 index d262054..f6f38be 100644 --- a/brc2 +++ b/brc2 @@ -65,17 +65,21 @@ path_add --end ~/.local/bin #path_add --ifexists --end /a/opt/scancode-toolkit-3.10. path_add --ifexists --end /p/bin -### stuff recommended by CPAN. However it is quite annoying that these things blindly + +### Commented because I tried a cpan module, but didn't want to keep it, so I removed cpan too, +### then I found that this was causing problems with my perl. +### +### Stuff recommended by CPAN. However it is quite annoying that these things blindly # add on to existing vars, so if you source this file multiple times, you get crazy long vars. -# So, I fix. -path_add --end /home/iank/perl5/bin -if [[ ! $PERL5LIB ]]; then - PERL5LIB=/home/iank/perl5/lib/perl5 - PERL_LOCAL_LIB_ROOT=/home/iank/perl5 - PERL_MB_OPT="--install_base /home/iank/perl5" - PERL_MM_OPT=INSTALL_BASE=/home/iank/perl5 - export PERL5LIB PERL_LOCAL_LIB_ROOT PERL_MB_OPT PERL_MM_OPT -fi +# So, I fixed. +# path_add --end /home/iank/perl5/bin +# if [[ ! $PERL5LIB ]]; then +# PERL5LIB=/home/iank/perl5/lib/perl5 +# PERL_LOCAL_LIB_ROOT=/home/iank/perl5 +# PERL_MB_OPT="--install_base /home/iank/perl5" +# PERL_MM_OPT=INSTALL_BASE=/home/iank/perl5 +# export PERL5LIB PERL_LOCAL_LIB_ROOT PERL_MB_OPT PERL_MM_OPT +# fi case $HOSTNAME in sy|bo) @@ -2503,6 +2507,7 @@ mns-setup() { # When we are setting up a mount namespace, we use this to avoid # redundant calls of mns-setup mns-no-setup() { + if (( $# < 2 )); then err "need at least 2 arguments"; return 1; fi local ns ns=$1 shift @@ -2512,6 +2517,7 @@ mns-no-setup() { } mns() { # mount namespace + if (( $# < 2 )); then err "need at least 2 arguments"; return 1; fi local ns ns=$1 shift @@ -2544,6 +2550,7 @@ mnsr() { # mns run (as normal user) ;; esac done + if (( $# < 2 )); then err "need at least 2 arguments"; return 1; fi ns=$1 shift @@ -2563,7 +2570,11 @@ mnsr() { # mns run (as normal user) m sudm nsenter --mount=/root/mount_namespaces/$ns sudo -u $user -i "${final_args[@]}" } -# Run cmd or shell in named mount namespace + systemd network namespace +# Run a command in named mount namespace + systemd network namespace +# Usage: mnsd [OPTIONS] MOUNT_NAMESPACE_NAME SYSTEMD_SERVICE_NAME CMD... +# +# See below for options. +# mnsd() { local ns unit user tmpf pre_check pid alt_user=false local -a final_args @@ -2588,6 +2599,7 @@ mnsd() { ;; esac done + if (( $# < 3 )); then err "need at least 3 arguments"; return 1; fi ns=$1 unit=$2 shift 2 @@ -5071,4 +5083,4 @@ vm.dirty_writeback_centisecs=1500 EOF s sysctl -p$t - } +} diff --git a/distro-end b/distro-end index 9ccc856..a9eece0 100755 --- a/distro-end +++ b/distro-end @@ -1416,11 +1416,13 @@ done # just fyi: default rpc port is 9091 tr-config-daemon() { + settings_copy=$(mktemp) + sudo cat $tconf_dir/settings.json >$settings_copy d_host_suffix=$(awk '$2 == "'$d_host'" {print $1}' /p/c/host-info) u ~/.config/transmission-daemon-iank.rb < '', 'rpc-whitelist-enabled' => false, @@ -1446,22 +1448,18 @@ EOF tmpf=$(mktemp) # shellcheck disable=SC2024 # false positive - chmod +x ~/.config/transmission-daemon-iank.rb - if ! sudo ~/.config/transmission-daemon-iank.rb >$tmpf; then - echo "iank ruby transmission error" >&2 - return 1 - fi + ruby ~/.config/transmission-daemon-iank.rb >$tmpf # shellcheck disable=SC2154 # false positive - if ! sudo diff -q $tmpf $tconf_dir/settings.json &>/dev/null; then + if ! diff -q $tmpf $settings_copy &>/dev/null; then restart_ser=false ser=transmission-daemon-nn if ser is-active $ser &>/dev/null; then m ser stop $ser restart_ser=true fi - sudo dd of=$tconf_dir/settings.json <$tmpf 2>/dev/null + sudo dd if=$tmpf of=$tconf_dir/settings.json 2>/dev/null if $restart_ser; then sudo cat $tconf_dir/settings.json #debug m ser start $ser @@ -2074,14 +2072,11 @@ curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo ##### postgres ##### ver=18 -if [[ $HOSTNAME == frodo ]]; then - ver=17 -fi # based on https://www.postgresql.org/download/linux/ubuntu/ if [[ ! -e /etc/apt/sources.list.d/pgdg.sources ]]; then pi postgresql-common sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y noble - pi-nostart postgresql-$ver + pi-nostart postgresql-$ver postgresql-doc-$ver # when we run it, do: #sudo -u postgres createuser -d iank sudo usermod -a -G postgres iank diff --git a/filesystem/etc/systemd/system/profanity.service b/filesystem/etc/systemd/system/profanity.service new file mode 100644 index 0000000..a7a207c --- /dev/null +++ b/filesystem/etc/systemd/system/profanity.service @@ -0,0 +1,26 @@ +[Unit] +Description=profanity +After=local-fs.target +# on desktop, we need /d to mount, and generally having it start later +# is find and good and this is the last target. +After=multi-user.target + +[Service] +# tmux requirement +Type=forking +# new-session is a tmux command which allows launching profanity. +ExecStart=/usr/bin/tmux -L profanity new-session -d profanity + +Restart=always +RestartSec=30 +TimeoutStartSec=300 + +User=iank +Group=iank + +# note: when running it as a system service instead of a user service, it +# complains about not being able to connect to gpg on startup. but it +# seems to work fine. + +[Install] +WantedBy=multi-user.target diff --git a/filesystem/usr/local/bin/prof-tail b/filesystem/usr/local/bin/prof-tail index 40260e5..f3df297 100755 --- a/filesystem/usr/local/bin/prof-tail +++ b/filesystem/usr/local/bin/prof-tail @@ -58,7 +58,7 @@ if [[ $1 == -e ]]; then shift fi -if pgrep -fA '^/bin/bash /usr/local/bin/prof-tail'; then +if pgrep -fA '^/bin/bash /usr/local/bin/prof-tail' >/dev/null; then if [[ -t 1 ]]; then echo "prof-tail already running. exiting" fi diff --git a/filesystem/usr/local/bin/prof-tmux-attach b/filesystem/usr/local/bin/prof-tmux-attach index 0ab3dcc..9a08948 100755 --- a/filesystem/usr/local/bin/prof-tmux-attach +++ b/filesystem/usr/local/bin/prof-tmux-attach @@ -39,7 +39,7 @@ fastcon=0 while true; do start=$EPOCHSECONDS if ! ssh-add -l | grep SHA256:YEhwH5u+wkqkSl/dCq8rFebi2qz7Os3RmIWPxMg13eA &>/dev/null; then - ssh -n prof + ssh -l iank -n prof fi ssh -l iank -t prof tmux -L profanity a ||: if (( EPOCHSECONDS > start + 600 )); then diff --git a/filesystem/usr/local/bin/switch-mail-host b/filesystem/usr/local/bin/switch-mail-host index a4c5f63..809b4f5 100755 --- a/filesystem/usr/local/bin/switch-mail-host +++ b/filesystem/usr/local/bin/switch-mail-host @@ -371,10 +371,8 @@ if (( ret )); then e finished restoring old host as primary, now exiting $ret due to earlier failed btrbk of /o. exit $ret fi - +_s=$(stty size); c=${_s#* }; while ((c-- >0)); do printf $; done; echo # new system is usable at this point -blocks=██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ -printf "%s\n" "${blocks:0:${COLUMNS:-100}}" # once I accidentally accepted incoming mail on old host. I used this script to copy over that mail: # diff --git a/fsf-script-lib b/fsf-script-lib index 2c5588b..d561fc6 100644 --- a/fsf-script-lib +++ b/fsf-script-lib @@ -373,6 +373,7 @@ _debug-setx-func() { else cmd="$BASH_COMMAND" fi + [[ $COLUMNS ]] || { _s=$(stty size); COLUMNS=${_s#* }; } if [[ $COLUMNS == *[0-9]* ]]; then # generally fill up 2 rows col=$(( COLUMNS * 2 - 20 )) diff --git a/machine_specific/frodo/filesystem/etc/mdadm/mdadm.conf b/machine_specific/frodo/filesystem/etc/mdadm/mdadm.conf index 52d5ab5..a4847ce 100644 --- a/machine_specific/frodo/filesystem/etc/mdadm/mdadm.conf +++ b/machine_specific/frodo/filesystem/etc/mdadm/mdadm.conf @@ -1,4 +1,2 @@ ARRAY /dev/md/pg1 level=raid0 num-devices=4 metadata=1.2 UUID=3bab0b4d:ad7a3136:c75fde32:f4373de1 - devices=/dev/dm-16,/dev/dm-22,/dev/dm-5,/dev/dm-7 ARRAY /dev/md/ndi level=raid0 num-devices=4 metadata=1.2 UUID=693bf056:3875b2bb:7794738b:98914a2c - #devices=/dev/mapper/int-vgnvme-WD_BLACK_SN850P_for_PS5_8000GB_24517P800200-ndi,/dev/mapper/int-vgnvme-WD_BLACK_SN850X_8000GB_245244802091-ndi,/dev/mapper/int-vgnvme-WD_BLACK_SN850X_8000GB_245244802317-ndi,/dev/mapper/int-vgnvme-WD_BLACK_SN850X_8000GB_25026Y802189-ndi diff --git a/machine_specific/frodo/subdir_files/.config/systemd/user/profanity.service.d/frodo.conf b/machine_specific/frodo/filesystem/etc/systemd/system/profanity.service.d/frodo.conf similarity index 73% rename from machine_specific/frodo/subdir_files/.config/systemd/user/profanity.service.d/frodo.conf rename to machine_specific/frodo/filesystem/etc/systemd/system/profanity.service.d/frodo.conf index 1c9c2a4..977f1d4 100644 --- a/machine_specific/frodo/subdir_files/.config/systemd/user/profanity.service.d/frodo.conf +++ b/machine_specific/frodo/filesystem/etc/systemd/system/profanity.service.d/frodo.conf @@ -1,2 +1,3 @@ [Unit] AssertPathExists=/d/p/profanity +After=d.mount diff --git a/machine_specific/frodo/filesystem/etc/systemd/system/transmission-daemon-nn.service.d/frodo.conf b/machine_specific/frodo/filesystem/etc/systemd/system/transmission-daemon-nn.service.d/frodo.conf new file mode 100644 index 0000000..d6eee90 --- /dev/null +++ b/machine_specific/frodo/filesystem/etc/systemd/system/transmission-daemon-nn.service.d/frodo.conf @@ -0,0 +1,4 @@ +[Unit] +AssertPathExists=/d/tor/.config/transmission-daemon/settings.json +After=d.mount +Requires=d.mount diff --git a/mailtest-check b/mailtest-check index eef5e8c..fd51a0f 100755 --- a/mailtest-check +++ b/mailtest-check @@ -439,7 +439,8 @@ EOF dir=/var/lib/prometheus/node-exporter path=$dir/mailtest-check.prom.$$ - if $doprom && [[ -e $dir ]]; then + if $doprom && [[ -d $dir ]]; then + find $dir -type f -mmin +1080 -name 'mailtest-check.prom.*' -delete for l in "${p_unexpected_spamd_results[@]}"; do printf "%s\n" "$l" >>$path done @@ -449,7 +450,9 @@ EOF for l in "${p_last_usec[@]}"; do printf "%s\n" "$l" >>$path done - mv $path $dir/mailtest-check.prom + if [[ -s $path ]]; then + mv $path $dir/mailtest-check.prom + fi # note: node_textfile_mtime_seconds will tell us when this last happened. useful for debugging. fi } diff --git a/subdir_files/.config/konsolerc b/subdir_files/.config/konsolerc index 32bf4aa..6a1f4e9 100644 --- a/subdir_files/.config/konsolerc +++ b/subdir_files/.config/konsolerc @@ -23,10 +23,10 @@ ShowMenuBarByDefault=false 2 screens: Width=1916 2 screens: XPosition=2 2 screens: YPosition=2 -3840x2160 screen: Height=2156 -3840x2160 screen: Width=956 -3840x2160 screen: XPosition=1922 -3840x2160 screen: YPosition=2 +3840x2160 screen: Height=1718 +3840x2160 screen: Width=1276 +3840x2160 screen: XPosition=2562 +3840x2160 screen: YPosition=440 DP-0=DP-0 DP-1 eDP-1=DP-1 DP-1-1 eDP-1=DP-1-1 diff --git a/subdir_files/.config/systemd/user/profanity.service b/subdir_files/.config/systemd/user/profanity.service deleted file mode 100644 index c90c02d..0000000 --- a/subdir_files/.config/systemd/user/profanity.service +++ /dev/null @@ -1,33 +0,0 @@ -[Unit] -Description=profanity -# background: i originally started profanity as a system service after -# networking-online.target but strangely, it had a hidden lock on /p -# preventing it from unmounting, and the only thing in /p i can see it -# using is gpg. I could try to get this to run after the last target, -# which is default.target, but all I can find documented on how to do -# this is to do this strange unexplained thing of making a new target, -# aliasing it to the default target and also make it -# After=default.target. I figured this probably works and is simpler. -After=gpg-agent.service -After=local-fs.target -# on desktop, we need /d to mount, and based on logs, this is the next target after it mounts. -# However, this does nothing since a user service is blind to system targets. -After=multi-user.target - -Restart=always -RestartSec=30 -TimeoutStartSec=300 - -[Service] -# tmux requirement -Type=forking -# new-session is a tmux command which allows launching profanity. -ExecStart=/usr/bin/tmux -L profanity new-session -d profanity - - -# if we have to move this to a system service: -#User=iank -#Group=iank - -[Install] -WantedBy=default.target