From 55b37c2dbe292fa1023c0c5376c2104fbe568011 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Thu, 13 Jun 2024 18:59:26 -0400 Subject: [PATCH] mainly minor fixes --- brc2 | 21 ++-- btrbk-run | 4 +- btrfsmaint | 2 +- dynamic-ip-update | 6 +- epanic-clean | 2 +- ffs | 45 +++++--- i3-abrowser | 2 +- i3-konsole | 3 +- i3-sway/common.conf | 5 +- keyscript-on | 2 +- mail-setup | 252 ++++++++++++++++++++++---------------------- mailtest-check | 20 +++- myi3status | 3 +- 13 files changed, 199 insertions(+), 168 deletions(-) diff --git a/brc2 b/brc2 index ff0d7a8..3b1d5ba 100644 --- a/brc2 +++ b/brc2 @@ -4854,19 +4854,24 @@ klease() { } # ffs and switch the bash history on this terminal. -ffs() { - local last - last="${*: -1}" - if [[ $last && $last != -* && $last != sysops ]]; then - his - fi - command ffs "$@" -} +# disabled because I don't really need this and +# the history switching is annoying for debugging. +# +# ffs() { +# local last +# last="${*: -1}" +# if [[ $last && $last != -* && $last != sysops ]]; then +# his +# fi +# command ffs "$@" +# } i3gen() { /b/ds/i3-sway/gen } + + export BASEFILE_DIR=/a/bin/fai-basefiles #export ANDROID_HOME=/a/opt/android-home diff --git a/btrbk-run b/btrbk-run index fc09657..0cdc625 100644 --- a/btrbk-run +++ b/btrbk-run @@ -194,8 +194,8 @@ dry_run=false # mostly for testing rate_limit=no verbose=true; verbose_arg="-l trace" force=false -if [[ $INVOCATION_ID ]]; then - # INVOCATION_ID means running as a systemd service. we cant show progress in this case, +if [[ $PPID == 1 ]]; then + # running as a service. we cant show progress in this case, # but if we pass the arg, it will insert mbuffer into the command. progress_arg= else diff --git a/btrfsmaint b/btrfsmaint index f50f549..3eb4759 100755 --- a/btrfsmaint +++ b/btrfsmaint @@ -29,7 +29,7 @@ set -e; . /usr/local/lib/bash-bear; set +e # inspired from # https://github.com/kdave/btrfsmaintenance -if [[ $INVOCATION_ID ]]; then +if [[ $PPID == 1 ]]; then err-cleanup() { exim -odf -i root </dev/null); then # our internet is down - if [[ $INVOCATION_ID ]]; then + if [[ $PPID == 1 ]]; then return 0 else echo $0: failed to get route, giving up @@ -121,7 +121,7 @@ main() { if $athome; then if ! cur4="$(dig +short $dyndomain @iankelling.org | tail -1)"; then - if [[ ! $INVOCATION_ID ]]; then + if [[ $PPID != 1 ]]; then echo "$0: dig failed. internet looks down. giving up" fi return 0 @@ -224,7 +224,7 @@ loop-main() { } nsupdate_fails=0 -if [[ $INVOCATION_ID ]]; then +if [[ $PPID == 1 ]]; then nsupdate_fail_limit=10 loop-main else diff --git a/epanic-clean b/epanic-clean index c9739ba..f6328c2 100755 --- a/epanic-clean +++ b/epanic-clean @@ -202,7 +202,7 @@ if [[ ! -w $pl-archive ]]; then chmod 664 $pl-archive fi -if [[ $INVOCATION_ID ]]; then +if [[ $PPID == 1 ]]; then loop-main else main diff --git a/ffs b/ffs index 4ffb0a0..fe42908 100755 --- a/ffs +++ b/ffs @@ -37,14 +37,16 @@ trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" exit status: $?, PIPESTATUS: ${P usage() { cat <&2 + exit 1 + ;; + esac + ffp_args+=($1) +fi if $delay; then # 2500 gets us around a 4 second delay, up from 1.5s. @@ -230,7 +243,7 @@ opts=( # # man page say zmq url default includes "localhost", but specifying a # localhost url caused an error for me. - -filter_complex "[0]azmq,volume=precision=fixed: volume=0 [vol0]; + -filter_complex "[0]azmq,volume=precision=fixed: volume=$volume [vol0]; [1]azmq='b=tcp\://127.0.0.1\:5556',volume=precision=fixed: volume=0 [vol1]; [vol0][vol1] amerge=inputs=2; [2]zmq='b=tcp\://127.0.0.1\:5557',drawbox=color=0x262626,drawtext=fontsize=90: fontcolor=beige: x=40: y=40: text=''${delay_arg}[out]" @@ -333,7 +346,7 @@ if [[ $mount_suffix == -sysops ]]; then touch $HOME/.iank-stream-on fi -echo true >$HOME/.iank-stream-muted +echo $volume >$HOME/.iank-stream-muted ffmpeg "${opts[@]}" & if $watch; then diff --git a/i3-abrowser b/i3-abrowser index eb2d47c..55246ee 100755 --- a/i3-abrowser +++ b/i3-abrowser @@ -50,6 +50,6 @@ else abrowser & # on a fast computer, .5 is too fast, 1 is ok. on x200, 1 is too fast, 2 is ok. sleep 2 - i3-msg "[workspace=__focused__ class=\"$b\"] mark abrowser" + i3-msg "[workspace=__focused__ class=\"$b\" instance=\"Navigator\" window_role=\"browser\"] mark abrowser" wait fi diff --git a/i3-konsole b/i3-konsole index c4b5182..9aa27d5 100755 --- a/i3-konsole +++ b/i3-konsole @@ -39,7 +39,8 @@ if i3-msg -t get_tree | jq --stream -r 'select(.[1]|scalars!=null) | "\(.[0]|joi fi else i3-split-maybe - konsole + konsole & sleep 1 i3-msg "[workspace=__focused__ class=\"konsole\"] mark term" + wait fi diff --git a/i3-sway/common.conf b/i3-sway/common.conf index d0ce973..fe09e67 100644 --- a/i3-sway/common.conf +++ b/i3-sway/common.conf @@ -64,8 +64,7 @@ bindsym $mod+e $ex "/a/exe/i3-emacs" bindsym $mod+r $ex "/a/bin/ds/xl" bindsym $mod+t $ex "i3-set-layout splitv" -#bindsym $mod+Shift+t move workspace to output up -bindsym $mod+Shift+t move workspace to output BIG-RIGHT eDP-1 +bindsym $mod+Shift+t move workspace to output BIG-RIGHT primary bindsym $mod+g $ex "i3-set-layout tabbed" @@ -187,6 +186,8 @@ bindsym $mod+shift+semicolon $ex /b/ds/stream-clip sad bindsym XF86MonBrightnessUp $ex brightnessctl s +5% bindsym XF86MonBrightnessDown $ex brightnessctl s 5%- for_window [class="copyq" instance="copyq" window_type="normal"] floating enable +# eh, dont really like web page titles + a long browser name string. +for_window [class="firefox" instance="Navigator" window_role="browser"] title_format "b" bindsym $mod+y $ex copyq-restart # Font for window titles. Will also be used by the bar unless a different font diff --git a/keyscript-on b/keyscript-on index b86dd39..ef8f3e1 100755 --- a/keyscript-on +++ b/keyscript-on @@ -41,7 +41,7 @@ sed="sed --follow-symlinks" # /sbin/update-initramfs: 157: mkinitramfs: not found PATH="/sbin:$PATH" -if [[ $INVOCATION_ID ]]; then +if [[ $PPID == 1 ]]; then if [[ -e /b/bash_unpublished/source-state ]]; then # this is the canonical one source /b/bash_unpublished/source-state diff --git a/mail-setup b/mail-setup index f5553d3..d19fba0 100755 --- a/mail-setup +++ b/mail-setup @@ -3883,6 +3883,131 @@ fi # err debbugs exist but is not uid 610: investigate # fi +# * mail monitoring / testing + +# note, to test clamav, send an email with body that only contains +# https://en.wikipedia.org/wiki/EICAR_test_file +# which set malware_name to Eicar-Signature +case $HOSTNAME in + $MAIL_HOST|bk|je) + # note: cronjob "ian" also does some important monitoring + # todo: this will sometimes cause an alert because mailtest-check will run + # before we have setup network namespace and spamassassin + u /etc/cron.d/mailtest <>/etc/cron.d/mailtest </usr/local/bin/send-test-forward <<'EOF' +#!/bin/bash +# we remove from the queue older than 4.3 minutes since we send every 5 minutes. +olds=( +$(/usr/sbin/exiqgrep -o 260 -i -r '^(testignore@(iankelling\.org|zroe\.org|expertpathologyreview\.com|amnimal\.ninja|je\.b8\.nz)|jtuttle@gnu\.org)$') +) +if (( ${#olds[@]} )); then + /usr/sbin/exim -Mrm "${olds[@]}" >/dev/null +fi +EOF + for test_from in ${test_froms[@]}; do + + test_to=${test_tos[0]} + for t in ${test_tos[@]:1}; do + if [[ $test_from == *@gnu.org && $t == *@gnu.org ]]; then + continue + fi + test_to+=", $t" + done + case $test_from in + testignore@expertpathologyreview.com) + test_to=testignore@zroe.org + ;; + esac + + cat >>/usr/local/bin/send-test-forward <>/etc/cron.d/mailtest </usr/local/bin/send-test-forward <<'EOF' -#!/bin/bash -# we remove from the queue older than 4.3 minutes since we send every 5 minutes. -olds=( -$(/usr/sbin/exiqgrep -o 260 -i -r '^(testignore@(iankelling\.org|zroe\.org|expertpathologyreview\.com|amnimal\.ninja|je\.b8\.nz)|jtuttle@gnu\.org)$') -) -if (( ${#olds[@]} )); then - /usr/sbin/exim -Mrm "${olds[@]}" >/dev/null -fi -EOF - for test_from in ${test_froms[@]}; do - - test_to=${test_tos[0]} - for t in ${test_tos[@]:1}; do - if [[ $test_from == *@gnu.org && $t == *@gnu.org ]]; then - continue - fi - test_to+=", $t" - done - case $test_from in - testignore@expertpathologyreview.com) - test_to=testignore@zroe.org - ;; - esac - - cat >>/usr/local/bin/send-test-forward </dev/null; then spamd_ser=spamassassin @@ -114,7 +118,11 @@ main() { ;; *) folders=(/m/md/l/testignore) - froms=(testignore@je.b8.nz testignore@expertpathologyreview.com testignore@amnimal.ninja ian@iankelling.org z@zroe.org) + # save some cpu cycles + froms=(testignore@je.b8.nz ian@iankelling.org) + if (( maini % 10 == 0 )); then + froms=(testignore@je.b8.nz testignore@expertpathologyreview.com testignore@amnimal.ninja ian@iankelling.org z@zroe.org) + fi if ! $int; then ### begin rsyncing fencepost email ### # We dont want to exit if rsync fails, that will get caught by @@ -208,7 +216,8 @@ EOF # example line that sed is parsing: # (-0.1 / 5.0 requ) DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,SPF_HELO_PASS=-0.001,SPF_PASS=-0.001,TVD_SPACE_RATIO=0.001 autolearn=_AUTOLEARN resultfile=$(mktemp) - $spamcpre sudo -u Debian-exim spamassassin -D -t --cf='score PYZOR_CHECK 0' <"$latest" &>$resultfile + # add -D for debug info. usually it + $spamcpre sudo -u Debian-exim spamassassin -t --cf='score PYZOR_CHECK 0' <"$latest" &>$resultfile # note: on some mail, its 1 line after the send-test-forward, on others its 2 with a blank inbetween. # I use the sed -n to filter this. @@ -336,7 +345,7 @@ EOF if $doprom && [[ -e $dir ]]; then for l in "${p_unexpected_spamd_results[@]}"; do printf "%s\n" "$l" >>$path - done + done for l in "${p_missing_dnswl[@]}"; do printf "%s\n" "$l" >>$path done @@ -355,12 +364,13 @@ loop-main() { while true; do premain_sec=$EPOCHSECONDS main + maini=$((maini + 1)) sleep $(( 300 - ( EPOCHSECONDS - premain_sec ) )) done } -if [[ $INVOCATION_ID ]]; then +if [[ $PPID == 1 ]]; then loop-main else main diff --git a/myi3status b/myi3status index 53b6458..608c5ce 100755 --- a/myi3status +++ b/myi3status @@ -194,7 +194,8 @@ main() { case $muted in 0) : ;; 1) - if find $HOME/.iank-stream-muted -mmin +2 | grep . &>/dev/null; then + if find $HOME/.iank-stream-muted -mmin +2 | grep . &>/dev/null && \ + ! pgrep -fc '^ffmpeg.*icecast://source.*/fsf-test'; then toggle-mute mute notify else ps_char="# UNMUTED # $ps_char" -- 2.30.2