From: Ian Kelling Date: Sun, 25 Dec 2022 21:06:26 +0000 (-0500) Subject: fixes and some improvements X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=d6def754cd241538c61456536b52ee51cbd85b42;p=distro-setup fixes and some improvements --- diff --git a/.bashrc b/.bashrc index e4a6fda..a8ee067 100644 --- a/.bashrc +++ b/.bashrc @@ -51,9 +51,8 @@ else ###### Begin sourcing of files ##### # The distinction between login and non-login shells is super lame - # and pretty random. get rid of that distinction. The var check is - # just a random variable i set there and no where else. - if ! shopt -q login_shell && [[ ! $PITHOSFLY_SAVE_DIR ]]; then + # and pretty random. get rid of that distinction. + if ! shopt -q login_shell; then if [[ -r /etc/profile ]]; then source /etc/profile fi diff --git a/.gitconfig b/.gitconfig index d15ab89..0c27adc 100644 --- a/.gitconfig +++ b/.gitconfig @@ -3,8 +3,6 @@ name = Ian Kelling email = iank@fsf.org #email = ian@iankelling.org [alias] -# Always use the git lg alias instead of git log. It's too easy to get -# confused by not seeing branches in git log output. lg = log --graph lgstat = log --stat --graph --pretty=format:'%h %ad- %s [%an]' co = checkout diff --git a/.screenrc b/.screenrc index 2451e9d..27e5cd4 100644 --- a/.screenrc +++ b/.screenrc @@ -43,4 +43,8 @@ termcapinfo xterm|xterm-256color ti@:te=\E[2J # hardstatus string "SCREEN @ %H: %-n - %t" # the default scrollback is way too small -defscrollback 1000000 \ No newline at end of file +defscrollback 1000000 + +# avoid annoying "New screen..." prompt +# https://serverfault.com/questions/377479/can-i-disable-the-message-line-when-launching-screen-rr +msgwait 0 diff --git a/brc b/brc index 5f43270..470c143 100644 --- a/brc +++ b/brc @@ -278,9 +278,21 @@ mysrc /a/bin/distro-functions/src/package-manager-abstractions # * functions -ccomp() { # copy completion - local src=$1 - local c + +### begin FSF section ### + +# Comments before functions are meant to be good useful +# documentation. If they fail at that, please improve them or send Ian a +# note. + +## copy bash completion +# Usage: ORIGINAL_COMMAND TARGET_COMMAND... +# +# It copies how the bash completion works from one command to other +# commands. +ccomp() { + local c src + src=$1 shift if ! c=$(complete -p $src 2>/dev/null); then _completion_loader $src &>/dev/null ||: @@ -292,6 +304,277 @@ ccomp() { # copy completion eval $c $* } +## directory history tracking and navigation. +# +# cd becomes a function, also aliased to c. b to go back, f to go +# forward, cl to list recent directories and choose one. +# +# The finer details you may want to skip: +# +# We also define bl to print the list of back and forward directories. +# +# We keep 2 stacks, forward and back. Unlike with a web browser, the +# forward stack is not erased when going somewhere new. +# +# Recent directories are stored in ~/.cdirs. +# +declare -a _dir_forward _dir_back +c() { + # normally, the top of _dir_back is our current dir. if it isn't, + # put it on there, except we don't want to do that when we + # just launched a shell + if [[ $OLDPWD ]]; then + if (( ${#_dir_back[@]} == 0 )) || [[ ${_dir_back[-1]} != "$PWD" ]]; then + _dir_back+=("$PWD") + fi + fi + command cd "$@" + if (( ${#_dir_back[@]} == 0 )) || [[ ${_dir_back[-1]} != "$PWD" ]]; then + _dir_back+=("$PWD") + fi + echo "$PWD" >> ~/.cdirs +} +ccomp cd c + +# back +b() { + local top_back + if (( ${#_dir_back[@]} == 0 )); then + echo "nothing left to go back to" >&2 + return 0 + fi + top_back="${_dir_back[-1]}" + + if [[ $top_back == "$PWD" ]] && (( ${#_dir_back[@]} == 1 )); then + echo "already on last back entry" >&2 + return 0 + fi + + + if [[ $top_back == "$PWD" ]]; then + # add to dirf if not already there + if (( ${#_dir_forward[@]} == 0 )) || [[ ${_dir_forward[-1]} != "$top_back" ]]; then + _dir_forward+=("$top_back") + fi + unset "_dir_back[-1]" + command cd "${_dir_back[-1]}" + else + if (( ${#_dir_forward[@]} == 0 )) || [[ ${_dir_forward[-1]} != "$PWD" ]]; then + _dir_forward+=("$PWD") + fi + command cd "$top_back" + fi + + # Interesting feature, not sure I want it. + # give us a peek at what is next in the list + # if (( ${#_dir_back[@]} >= 2 )); then + # printf "%s\n" "${_dir_back[-2]}" + # fi + # + + # c/b/f Implementation notes: + # + # The top of the back is $PWD + # as long as the last directory change was due to c,b,or cl. + # + # Example of stack changes: + # + # a b c (d) + ## back + # a b (c) + # d + #back + #a (b) + #d c + #back + #(a) + #d c b + #forward + #a (b) + #d c + # + # a b c + ## back + # a b + # (c) + ## forward + +} +# forward +f() { + local top_forward + if (( ${#_dir_forward[@]} == 0 )); then + echo "no forward dir left" >&2 + return 0 + fi + top_forward="${_dir_forward[-1]}" + unset "_dir_forward[-1]" + c "$top_forward" + + # give us a peek at what is next in the list + # if (( ${#_dir_forward[@]} )); then + # printf "%s\n" "${_dir_forward[-1]}" + # fi +} +# cd list +cl() { + local i line input start + local -A buttondirs alines + local -a buttons dirs lines + buttons=( {a..z} {2..9} ) + if [[ ! -s ~/.cdirs ]]; then + echo nothing in ~/.cdirs + return 0 + fi + + i=0 + + mapfile -t lines <~/.cdirs + start=$(( ${#lines[@]} - 1 )) + + # we have ~33 buttons as of this writing, so lets + # prune down the history every once in a while. + if (( start > 500 )); then + tac ~/.cdirs | awk '!seen[$0]++' | head -n 200 | sponge ~/.cdirs + fi + + for (( j=$start; j >= 0; j-- )); do + line="${lines[$j]}" + if [[ ! $line || ${alines[$line]} || ! -d "$line" || $line == "$PWD" || line == "$HOME" ]]; then + continue + fi + alines[$line]=t + buttondirs[${buttons[i]}]="$line" + printf "%s %s\n" ${buttons[i]} "$line" + if (( i == ${#buttons[@]} - 1 )); then + break + fi + i=$(( i + 1 )) + done + + if (( i == 0 )); then + echo "no dirs in ~/.cdirs" + return 0 + fi + read -r -N 1 input + if [[ $input != $'\n' ]]; then + c ${buttondirs[$input]} + fi +} +# back list +bl() { + local start i j max + max=10 + start=$(( ${#_dir_back[@]} - 1 )) + + # cleanup possible repeating of pwd + if (( start >= 0 )) && [[ ${_dir_back[$start]} == "$PWD" ]]; then + start=$(( start - 1 )) + fi + j=1 + if (( start >= 0 )); then + for (( i=$start; i >= 0 ; i-- )); do + printf "%s %s\n" $j ${_dir_back[i]} + j=$(( j + 1 )) + if (( j >= max )); then + break + fi + done + fi + + max=10 + start=$(( ${#_dir_forward[@]} - 1 )) + + # cleanup possible repeating of pwd + if (( start >= 0 )) && [[ ${_dir_forward[$start]} == "$PWD" ]]; then + start=$(( start - 1 )) + fi + if (( start < 0 )); then + return 0 + fi + echo -- + j=1 + for (( i=$start; i >= 0 ; i-- )); do + printf "%s %s\n" $j ${_dir_forward[i]} + j=$(( j + 1 )) + if (( j >= max )); then + break + fi + done +} + +# pee do. run args as a command with output copied to syslog. +# +# Usage: pd [-t TAG] COMMAND... +# +# -t TAG Override the tag in the syslog. The default is COMMAND with +# any path part is removed, eg. for /bin/cat the tag is cat. +# +# You can view the log via "journalctl -t TAG" +pd() { + local tag ret + ret=0 + tag=${1##*/} + case $1 in + -t) tag="$2"; shift 2 ;; + esac + echo "PWD=$PWD command: $*" | logger -t $tag + "$@" |& pee cat "logger -t $tag" || ret=$? + echo "exited with status=$ret" | pee cat "logger -t $tag" + # this avoids any err-catch + (( $ret == 0 )) || return $ret +} +ccomp time pd + +# jdo = journal do. Run command as transient systemd service, tailing +# its output in the journal until it completes. +# +# Usage: jdo COMMAND... +# +# Compared to pd: commands recognize this is a non-interactive shell. +# The service is unaffected if our ssh connection dies, no need to run +# in screen or tmux. +# +# Note: The last few lines of any existing entries for a unit by that +# name will be output first, and there will be a few second delay at the +# start of the command, and a second or so at the end. +# +# Note: Functions and aliases obviously won't work, we resolve the +# command to a file. +# +# Note: requires running as root. +jdo() { + local cmd cmd_name jr_pid ret + ret=0 + cmd="$1" + shift + if [[ $EUID != 0 ]]; then + echo "jdo: error: rerun as root" + return 1 + fi + cmd_name=${cmd##*/} + if [[ $cmd != /* ]]; then + cmd=$(type -P "$cmd") + fi + # -q = quiet + journalctl -qn2 -f -u "$cmd_name" & + # Trial and error of time needed to avoid missing initial lines. + # .5 was not reliable. 1 was not reliable. 2 was not reliable + sleep 4 + jr_pid=$! + systemd-run --unit "$cmd_name" --wait --collect "$cmd" "$@" || ret=$? + # The sleep lets the journal output its last line + # before the prompt comes up. + sleep .5 + kill $jr_pid &>/dev/null ||: + unset jr_pid + fg &>/dev/null ||: + # this avoids any err-catch + (( $ret == 0 )) || return $ret +} +ccomp time jdo +#### end fsf section + ..() { c ..; } ...() { c ../..; } @@ -415,223 +698,26 @@ utcl() { # utc 24 hour time to local hour 24 hour time echo "print( ($1 $(date +%z | sed -r 's/..$//;s/^(-?)0*/\1/')) % 24)"|python3 } -declare -a _iankdirf _iankdirb - - -# ## old wcd, to be deleted -# b() { -# # backwards -# c - -# } -# # shellcheck disable=SC2032 -# f() { -# # cd forward -# c + -# } -# cl() { -# # choose recent directory. cl = cd list -# c = -# } -# # c. better cd -# if ! type -t c &>/dev/null; then -# if type -p wcd &>/dev/null; then -# if [[ $LC_INSIDE_EMACS ]]; then -# c() { wcd -c -z 50 -o "$@"; } -# else -# # lets see what the fancy terminal does from time to time -# c() { wcd -c -z 50 "$@"; } -# fi -# else -# c() { cd "$@"; } -# fi -# fi - -# c. better cd. -# keep 2 stacks, forward and back. the top of the back is $PWD -# as long as the last directory change was due to c,b,or cl. -c() { - # normally, the top of dirb is our current dir. if it isn't, - # put it on there, except we don't want to do that when we - # just launched a shell - if [[ $OLDPWD ]]; then - if (( ${#_iankdirb[@]} == 0 )) || [[ ${_iankdirb[-1]} != "$PWD" ]]; then - _iankdirb+=("$PWD") - fi - fi - cd "$@" - if (( ${#_iankdirb[@]} == 0 )) || [[ ${_iankdirb[-1]} != "$PWD" ]]; then - _iankdirb+=("$PWD") - fi - echo "$PWD" >> ~/.iankdirs -} -ccomp cd c - bwm() { s bwm-ng -T avg -d } -b() { - local topb - if (( ${#_iankdirb[@]} == 0 )); then - echo "nothing left to go back to" >&2 - return 0 - fi - topb="${_iankdirb[-1]}" - if [[ $topb == "$PWD" ]] && (( ${#_iankdirb[@]} == 1 )); then - echo "already on last back entry" >&2 - return 0 - fi - - - if [[ $topb == "$PWD" ]]; then - # add to dirf if not already there - if (( ${#_iankdirf[@]} == 0 )) || [[ ${_iankdirf[-1]} != "$topb" ]]; then - _iankdirf+=("$topb") - fi - unset "_iankdirb[-1]" - cd "${_iankdirb[-1]}" - else - if (( ${#_iankdirf[@]} == 0 )) || [[ ${_iankdirf[-1]} != "$PWD" ]]; then - _iankdirf+=("$PWD") - fi - cd "$topb" - fi - - # give us a peek at what is next in the list - # if (( ${#_iankdirb[@]} >= 2 )); then - # printf "%s\n" "${_iankdirb[-2]}" - # fi -} - -f() { - local topf - if (( ${#_iankdirf[@]} == 0 )); then - echo "no forward dir left" >&2 - return 0 - fi - topf="${_iankdirf[-1]}" - unset "_iankdirf[-1]" - c "$topf" - - # give us a peek at what is next in the list - # if (( ${#_iankdirf[@]} )); then - # printf "%s\n" "${_iankdirf[-1]}" - # fi -} - -# a b c (d) -## back -# a b (c) -# d -#back -#a (b) -#d c -#back -#(a) -#d c b -#forward -#a (b) -#d c -# -# a b c -## back -# a b -# (c) -## forward - -cl() { - local i line input start tmpfile - local -A buttondirs alines - local -a buttons dirs lines - buttons=( {a..z} {2..9} ) - if [[ ! -s ~/.iankdirs ]]; then - echo nothing in ~/.iankdirs - return 0 - fi - - i=0 - - # note, alternate approach like this, made the following read fail - # done < <(tac ~/.iankdirs | awk '!seen[$0]++') - # bash: read: read error: 0: Input/output error - # which went away by adding a sleep 1 after it. - - mapfile -t lines <~/.iankdirs - start=$(( ${#lines[@]} - 1 )) - - # we have ~33 buttons as of this writing, so lets - # prune down the history every once in a while. - if (( start > 500 )); then - tmpfile=$(mktemp) - tac ~/.iankdirs | awk '!seen[$0]++' | head -n 200 >$tmpfile - cat $tmpfile > ~/.iankdirs - fi - - for (( j=$start; j >= 0; j-- )); do - line="${lines[$j]}" - if [[ ! $line || ${alines[$line]} || ! -d "$line" || $line == "$PWD" || line == "$HOME" ]]; then - continue - fi - alines[$line]=t - buttondirs[${buttons[i]}]="$line" - printf "%s %s\n" ${buttons[i]} "$line" - if (( i == ${#buttons[@]} - 1 )); then - break - fi - i=$(( i + 1 )) +# for running in a fai rescue +kdrescue() { + d=vgata-Samsung_SSD_850_EVO_2TB_S2RLNX0J502123D + for f in $d vgata-Samsung_SSD_870_QVO_8TB_S5VUNG0N900656V; do + cryptsetup luksOpen --key-file /p /dev/$f/root crypt-$f-root + cryptsetup luksOpen --key-file /p /dev/$f/o crypt-$f-o done - - if (( i == 0 )); then - echo "no dirs in ~/.iankdirs" - return 0 - fi - read -r -N 1 input - if [[ $input != $'\n' ]]; then - c ${buttondirs[$input]} - fi + mount -o subvol=root_trisquelaramo /dev/mapper/crypt-$d-root /mnt + mount -o subvol=a /dev/mapper/crypt-$d-root /mnt/a + mount -o subvol=o /dev/mapper/crypt-$d-o /mnt/o + mount -o subvol=boot_trisquelaramo /dev/sda2 /mnt/boot + cd /mnt + chrbind } -bl() { - local start i j max - max=10 - start=$(( ${#_iankdirb[@]} - 1 )) - # cleanup possible repeating of pwd - if (( start >= 0 )) && [[ ${_iankdirb[$start]} == "$PWD" ]]; then - start=$(( start - 1 )) - fi - j=1 - if (( start >= 0 )); then - for (( i=$start; i >= 0 ; i-- )); do - printf "%s %s\n" $j ${_iankdirb[i]} - j=$(( j + 1 )) - if (( j >= max )); then - break - fi - done - fi - - max=10 - - start=$(( ${#_iankdirf[@]} - 1 )) - - # cleanup possible repeating of pwd - if (( start >= 0 )) && [[ ${_iankdirf[$start]} == "$PWD" ]]; then - start=$(( start - 1 )) - fi - if (( start < 0 )); then - return 0 - fi - echo -- - j=1 - for (( i=$start; i >= 0 ; i-- )); do - printf "%s %s\n" $j ${_iankdirf[i]} - j=$(( j + 1 )) - if (( j >= max )); then - break - fi - done -} @@ -1200,9 +1286,13 @@ hrcat() { local f; for f; do [[ -f $f ]] || continue; hr; echo "$f"; cat "$f"; d # On first use, you input username/pass and it gets an oath token so you dont have to repeat # it\'s at ~/.config/hub hub() { - local up uptar updir p - p=/github/hub/releases/ - up=https://github.com/$(curl -s https://github.com$p| grep -o $p'download/[^/]*/hub-linux-amd64[^"]*' | head -n1) + local up uptar updir p v + # example https://github.com/github/hub/releases/download/v2.14.2/hub-linux-amd64-2.14.2.tgz + up=$(wget -q -O- https://api.github.com/repos/github/hub/releases/latest | jq -r .assets[].browser_download_url | grep linux-amd64) + re='[[:space:]]' + if [[ ! $up || $up == $re ]]; then + echo "failed to get good update url. got: $up" + fi uptar=${up##*/} updir=${uptar%.tgz} if [[ ! -e /a/opt/$updir ]]; then @@ -1230,6 +1320,21 @@ hub() { i() { git "$@"; } ccomp git i +# git status: +# cvs -qn update + +# git checkout FILE +# cvs update -C FILE + +# git pull +# cvs up[date] + +# potentially useful command translation +# https://fling.seas.upenn.edu/~giesen/dynamic/wordpress/equivalent-commands-for-git-svn-and-cvs/ + +# importing cvs repo into git using git-cvs package: +# /f/www $ /usr/lib/git-core/git-cvsimport -C /f/www-git + ic() { # fast commit all git commit -am "$*" @@ -1266,6 +1371,10 @@ istext() { grep -Il "" "$@" &>/dev/null } +pst() { + pstree -apnA +} + jtail() { journalctl -n 10000 -f "$@" } @@ -1275,6 +1384,8 @@ jru() { journalctl -u exim4 _SYSTEMD_INVOCATION_ID=$(systemctl show -p InvocationID --value $1) } + + l() { if [[ $PWD == /[iap] ]]; then command ls -A --color=auto -I lost+found "$@" @@ -1455,6 +1566,8 @@ nopanic() { ngreset } + +ping() { command ping -O "$@"; } p8() { ping "$@" 8.8.8.8; } p6() { ping6 "$@" 2001:4860:4860::8888; } @@ -1534,6 +1647,7 @@ r() { scp() { rsync --inplace "$@" } +ccomp rsync scp randport() { # available high ports are 1024-65535, @@ -1570,8 +1684,9 @@ rst() { # rl without preserving modification time. rsync -ahvic --delete --no-t "$@" } -rsu() { # [OPTS] HOST PATH - # eg. rlu -opts frodo /testpath +# [RSYNC_OPTS] HOST PATH +rsu() { + # eg. rsu -opts frodo /testpath # relative paths will expanded with readlink -f. opts=("${@:1:$#-2}") # 1 to last -2 path="${*:$#}" # last @@ -1579,10 +1694,7 @@ rsu() { # [OPTS] HOST PATH if [[ $path == .* ]]; then path=$(readlink -f $path) fi - # rync here uses checksum instead of time so we dont mess with - # unison relying on time as much. g is for group, same reason - # to keep up with unison. - m s rsync -rlpchviog --relative "${opts[@]}" "$path" "root@$host:/"; + m rsync -ahvi --relative --no-implied-dirs "${opts[@]}" "$path" "root@$host:/"; } ccomp rsync rsd rsa rst rsu @@ -1644,6 +1756,11 @@ rmstrips() { ssh fencepost head -n 300 /gd/gnuorg/EventAndTravelInfo/rms-current-trips.txt | less } +urun () { + umask $1 + shift + "$@" +} sudo () { command sudo "$@" || return $? DID_SUDO=true @@ -1672,7 +1789,9 @@ sb() { # sudo bash -c local SUDOD="$PWD" sudo -i bash -c "$@" } -ccomp sudo s sb +# secret sudo +se() { s urun 0077 "$@"; } +ccomp sudo s sb se safe_rename() { # warn and dont rename if file exists. # mv -n exists, but it\'s silent @@ -2380,15 +2499,6 @@ if [[ $- == *i* ]]; then history -a # save history fi - # assigned in brc2 - # shellcheck disable=SC1303 - if [[ $jr_pid ]]; then - if [[ -e /proc/$jr_pid ]]; then - kill $jr_pid - fi - unset jr_pid - fi - case $return in 0) ps_color="$term_purple" ps_char='\$' diff --git a/brc2 b/brc2 index 6ee207c..61bd931 100644 --- a/brc2 +++ b/brc2 @@ -364,7 +364,7 @@ ap() { } aw() { pushd /a/work/ans >/dev/null - time ansible-playbook -v -i inventory adhoc.yml "$@" + time ansible-playbook -i inventory adhoc.yml "$@" popd >/dev/null } ad() { @@ -414,7 +414,7 @@ bbk() { # btrbk wrapper install-my-scripts # todo: consider changing this to srun and having the args come # from a file like /etc/default/btrbk, like is done in exim - s jrun btrbk-run "$@" + s jdo btrbk-run "$@" if $active; then if (( ret )); then echo bbk: WARNING: btrbk.timer not restarted due to failure @@ -454,40 +454,90 @@ locat() { # log-once cat ngreset } -# duplicated somewhat below. -jrun() { # journal run. run args, log to journal, tail and grep the journal. - # Note, an alternative without systemd would be something like ts. - # Note, I tried using systemd-cat, but this seems obviously better, - # and that seemed to have a problem exiting during a systemctl daemon-reload - local cmd_name jr_pid s +scr() { + screen -RD "$@" +} + + +# version of jdo for my non-root user +jdo() { + # comparison of alternative logging methods: + # + # systemd-run command (what this function does) + # + # If there is a user prompt, the program will detect that it is not + # connected to a terminal and act in a non-interactive way, skipping + # the prompt. This has the benefit that you know exactly how the + # program will act if you want to move it into a service that runs + # automatically. + # + # If run with sudo and command is a shell script which does a sleep, + # it can (sometimes?) output some extra whitespace in front of + # messages, more for each subsequent message. This can be avoided by + # becoming root first. + # + # It logs the command's pid and exit code, which is nice. + # + # + ### command |& ts | tee file.log + # + # If there is a user prompt, like "read -p prompt var", it will hang + # without outputting the prompt. + # + # I've had a few times where ts had an error and I wasn't totally sure + # if it was really the command or ts having the problem. + # + # Sometimes some output will get hidden until you hit enter. + # + # + ### command |& pee cat logger + # + # This seems to work. I need to test more. + # + # + ### command |& logger -s + # + # User prompts get confusingly prefixed to earlier output, and all log + # entries get prefixed with annoying priority level. + # + # + ### systemd-cat + # + # Had a few problems. One major one is that it exited in the middle of + # a command on systemctl daemon-reload + # + # Related commands which can log a whole session: script, sudo, screen + local cmd cmd_name jr_pid ret ret=0 - cmd_name=${1##*/} - cmd=$1 + cmd="$1" + shift + cmd_name=${cmd##*/} if [[ $cmd != /* ]]; then - cmd=$(which $1) + cmd=$(type -P "$cmd") fi + # -q = quiet journalctl -qn2 -f -u "$cmd_name" & - # Guess of time needed to avoid missing initial lines. + # Trial and error of time needed to avoid missing initial lines. # .5 was not reliable. 1 was not reliable. 2 was not reliable sleep 4 - # We kill this in prompt-command for the case that we ctrl-c the - # systemd-cat. i dont know any way to trap ctrl-c and still run the - # normal action for it. There might be a way, unsure. jr_pid=$! # note, we could have a version that does system --user, but if for example # it does sudo ssh, that will leave a process around that we can't kill # and it will leave the unit hanging around in a failed state needing manual # killing of the process. - m s systemd-run --uid $(id -u) --gid $(id -g) \ + s systemd-run --uid $(id -u) --gid $(id -g) \ -E SSH_AUTH_SOCK=/run/openssh_agent \ - --unit "$cmd_name" --wait --collect "$cmd" "${@:2}" || ret=$? - # This justs lets the journal output its last line + --unit "$cmd_name" --wait --collect "$cmd" "$@" || ret=$? + # The sleep lets the journal output its last line # before the prompt comes up. sleep .5 kill $jr_pid &>/dev/null ||: unset jr_pid fg &>/dev/null ||: + # this avoids any err-catch + (( $ret == 0 )) || return $ret } + # service run, and watch the output srun() { local unit @@ -511,7 +561,7 @@ sm() { # switch mail host s ssh-add /root/.ssh/home fi install-my-scripts - s jrun switch-mail-host "$@" + s jdo switch-mail-host "$@" return $ret } sh2() { # switch host2 @@ -524,7 +574,7 @@ sh2() { # switch host2 s ssh-add /root/.ssh/home fi install-my-scripts - s jrun switch-host2 "$@" + s jdo switch-host2 "$@" return $ret } @@ -1435,6 +1485,35 @@ allmyirc() { ssh root@iankelling.org "cd $d; find . -mtime -60 -type f -exec grep '\/dev/null; then + home=b8.nz + else + home=i.b8.nz + fi fi ;;& x2) @@ -240,10 +252,12 @@ if [[ ! -v targets && ! $source ]]; then fi ;; kd) - if ping -q -c1 -w1 x2.office.fsf.org &>/dev/null; then - targets+=(x2.office.fsf.org) - else - targets+=(x2wg.b8.nz) + if ! $kd_spread; then + if ping -q -c1 -w1 x2.office.fsf.org &>/dev/null; then + targets+=(x2.office.fsf.org) + else + targets+=(x2wg.b8.nz) + fi fi if ping -q -c1 -w1 sy.b8.nz &>/dev/null; then targets+=(sy.b8.nz) @@ -463,7 +477,7 @@ ssh_identity /q/root/h transaction_syslog local7 # trying this out -stream_compress zstd +#stream_compress zstd # so we only run one at a time lockfile /var/lock/btrbk.lock @@ -542,16 +556,6 @@ EOF fi done -# if $amy; then -# # to manually backup amy, -# # bbk -e -s amy -m root_ubuntubionic -# cat >>/etc/btrbk.conf <<'EOF' -# volume ssh://amy/mnt/root -# subvolume root_ubuntubionic -# target send-receive /mnt/root/btrbk -# EOF -# fi - # todo: umount first to ensure we don't have any errors # todo: do some kill fuser stuff to make umount more reliable diff --git a/btrfsmaint b/btrfsmaint deleted file mode 120000 index 4de4b76..0000000 --- a/btrfsmaint +++ /dev/null @@ -1 +0,0 @@ -/a/f/ans/roles/btrfs/files/btrfsmaint \ No newline at end of file diff --git a/btrfsmaint b/btrfsmaint new file mode 100755 index 0000000..871a0d3 --- /dev/null +++ b/btrfsmaint @@ -0,0 +1,242 @@ +#!/bin/bash + + +[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@" + +f=/usr/local/lib/err;test -r $f || { echo "error: $0 no $f" >&2;exit 1;}; . $f + +# inspired from +# https://github.com/kdave/btrfsmaintenance + +if [[ $INVOCATION_ID ]]; then + err-cleanup() { + exim -odf -i root </dev/null || return 0 + export DISPLAY=:0 + # a hours, a movie could run that long. + idle_limit=$((1000 * 60 * 60 * 2)) + idle_time=$idle_limit + while read -r user; do + new_idle_time=$(sudo -u $user xprintidle 2>/dev/null) ||: + if [[ $new_idle_time && $new_idle_time -lt $idle_time ]]; then + idle_time=$new_idle_time + fi + done < <(users | tr " " "\n" | sort -u) + if (( idle_time < idle_limit )); then + idle=false + else + idle=true + fi +} + +usage() { + cat <&2; exit 1; } + +check=false +dryrun=false +force=false +stats=true + +temp=$(getopt -l help,check,dryrun,force,no-stats h "$@") || usage 1 +eval set -- "$temp" +while true; do + case $1 in + --check) check=true ;; + --dryrun) dryrun=true ;; + --force) force=true ;; + --no-stats) stats=false ;; + -h|--help) usage ;; + --) shift; break ;; + *) echo "$0: unexpected args: $*" >&2 ; usage 1 ;; + esac + shift +done +readonly check dryrun force stats +##### end command line parsing ######## + + +main() { + idle=true + if ! $force; then + check-idle + if ! $check; then + min=0 + max_min=300 + # When the cron kicks in, we may not be idle (physically sleeping) yet, so + # wait. + while ! $idle && (( min < max_min )); do + min=$(( min + 1 )) + sleep 60 + check-idle + done + # If we've waited a really long time for idle, just give up. + if (( min == max_min )); then + return + fi + fi + fi + + + fnd="findmnt --types btrfs --noheading" + for x in $($fnd --output "SOURCE" --nofsroot | sort -u); do + mnt=$($fnd --output "TARGET" --first-only --source $x) + [[ $mnt ]] || continue + + #### begin look for diff in stats, eg: increasing error count #### + if $stats; then + tmp=$(mktemp) + # ${mnt%/} so that if mnt is / we avoid making a buggy looking path + stats_path=${mnt%/}/btrfs-dev-stats + if [[ ! -e $stats_path ]]; then + btrfs dev stats -c $mnt >$stats_path ||: # populate initial reading + elif ! btrfs dev stats -c $mnt >$tmp; then + if ! diff -q $stats_path $tmp; then + mv $stats_path $stats_path.1 + cat $tmp >$stats_path + diff=$(diff -u $stats_path $tmp 2>&1 ||:) + printf "diff of: btrfs dev stats -c %s\n%s\n" "$mnt" "$diff" + exim -odf -i root </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 + e ionice -c 3 btrfs balance start -dusage=$usage -musage=$usage $mnt + done + else + e ionice -c 3 btrfs balance start -dusage=0 $mnt + for usage in $dusage; do + e ionice -c 3 btrfs balance start -dusage=$usage $mnt + done + e ionice -c 3 btrfs balance start -musage=0 $mnt + for usage in $musage; do + e 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 + date=$(printf "%s\n" "$scrub_status" | sed -rn 's/^Scrub started:[[:space:]]*(.*)/\1/p') + fi + if [[ ! $date ]]; then + # output from older versions, at least btrfs v4.15.1 + date=$( + printf "%s\n" "$scrub_status" | \ + sed -rn 's/^\s*scrub started at (.*) and finished.*/\1/p' + ) + fi + if ! $force && [[ $date ]]; then + if $dryrun; then + echo "$0: last scrub finish for $mnt: $date" + fi + date=$(date --date="$date" +%s) + # if date is sooner than 60 days ago + # 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 + 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 + + # 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. + if ! $force; then + return 0 + fi + done +} + +loop-main() { + while true; do + main + sleep 60 + done +} + +if $check; then + loop-main +else + main +fi diff --git a/check-radicale b/check-radicale new file mode 100755 index 0000000..bf0729c --- /dev/null +++ b/check-radicale @@ -0,0 +1,27 @@ +#!/bin/bash + +if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi +source /a/bin/errhandle/err + +source /a/bin/bash_unpublished/source-state +if [[ $HOSTNAME != "$MAIL_HOST" ]]; then + exit 0 +fi + +# i had a phone which deleted all my contacts in radicale, but kept them +# locally. then the phone died months later, and i had no backup of +# recent contacts. This checks that those files didnt get deleted or +# zerod out, by picking an amount that we dont expect to go below +# anytime soon as of 2022. + +count=$(find /o/radicale/collections -type f | grep -v cache | wc -l) + +if (( count < 220 )); then + echo "unexpected file count=$count < 220" +fi + +size=$(du -s /o/radicale | awk '{print $1}') + +if (( size < 2000 )); then + echo "unexpected kb size=$size < 2000" +fi diff --git a/conflink b/conflink index f798204..b44c4c3 100755 --- a/conflink +++ b/conflink @@ -213,6 +213,10 @@ case $user in #### begin special extra stuff #### install -d -m700 ~/gpg-agent-socket + if [[ -e /etc/bitcoin ]] && getent group bitcoin &>/dev/null; then + s chown bitcoin:bitcoin /etc/bitcoin + fi + f=/var/lib/bind if [[ -e $f ]]; then # reset to the original permissions. diff --git a/distro-end b/distro-end index 61fec8a..32a4b0e 100755 --- a/distro-end +++ b/distro-end @@ -1831,6 +1831,11 @@ DEVICESCAN -a -o on -S on -n standby,q $sched \ ########### misc stuff +# pressing tab after sdf here: +# scp sdfbash: set +o noglob: command not found +# in t11, bash 5.1.16. this fixes it. +sudo sed -ri 's/([[:space:]]*)(\$reset)$/\1set +o noglob #$reset/' /usr/share/bash-completion/bash_completion + rm -fv /home/iank/.mpv/watch_later rm -rf /home/iank/.mpv @@ -1847,6 +1852,20 @@ if [[ ! -e ~/.local/bin/pip ]]; then hash -r fi +# notes about barrier +# run barrier, do the gui config, +# setup the 2 screens, using hostnames for the new screen. +# save the server config +# $HOME/.local/share/barrier/.barrier.conf +# per the man page. +# +# ssl errors, resolved via advice here: https://github.com/debauchee/barrier/issues/231 +# BARRIER_SSL_PATH=~/.local/share/barrier/SSL/ +# mkdir -p "${BARRIER_SSL_PATH}" +# openssl req -x509 -nodes -days 365 -subj /CN=Barrier -newkey rsa:4096 -keyout ${BARRIER_SSL_PATH}/Barrier.pem -out ${BARRIER_SSL_PATH}/Barrier.pem +# ran on both machines. +# When pressing start in the gui, the cli options used are printed to the console, +# they are useful. So on server, just run barriers, client run barrierc SERVER_IP ### begin timetrap setup if mountpoint /p &>/dev/null; then @@ -2047,16 +2066,18 @@ esac ### begin nagios ### -pi nagios4 -s rm -fv /etc/apache2/conf-enabled/nagios4-cgi.conf +case $HOSTNAME in + kd) + pi nagios4 + s rm -fv /etc/apache2/conf-enabled/nagios4-cgi.conf -# to add a password for admin: -# htdigest /etc/nagios4/htdigest.users Nagios4 iank -# now using the same pass as prometheus + # to add a password for admin: + # htdigest /etc/nagios4/htdigest.users Nagios4 iank + # now using the same pass as prometheus -# nagstamon auth settings, set to digest instead of basic. + # nagstamon auth settings, set to digest instead of basic. -web-conf -p 3005 - apache2 i.b8.nz <<'EOF' + web-conf -p 3005 - apache2 i.b8.nz <<'EOF' # adapted from /etc/apache2/conf-enabled/nagios4-cgi.conf ScriptAlias /cgi-bin/nagios4 /usr/lib/cgi-bin/nagios4 @@ -2104,7 +2125,8 @@ Alias /nagios4 /usr/share/nagios4/htdocs Options +ExecCGI EOF - + ;; +esac # when you alter a service through the web, it changes vars in /var/lib/nagios4/status.dat. for example: # notifications_enabled=1 @@ -2137,6 +2159,21 @@ EOF ### end nagios ### +### begin bitcoin ### + +case $HOSTNAME in + sy) + f=$dir/bitcoin.conf + sudo install -m 0755 -o root -g root -t /usr/bin /a/opt/bitcoin-23.0/bin/* + sgo bitcoind + sudo usermod -a -G bitcoin iank + # todo, link in wallet. see + # /a/bin/ds/disabled/bitcoin + ;; +esac + +### end bitcoin + end_msg <<'EOF' In mate settings settings, change scrolling to two-finger, diff --git a/filesystem/etc/cron.d/ian b/filesystem/etc/cron.d/ian index 24fc23c..5ec9e83 100644 --- a/filesystem/etc/cron.d/ian +++ b/filesystem/etc/cron.d/ian @@ -7,6 +7,7 @@ MAILTO=root # If theres any logged errors we didnt handle in 4 days, maybe we accidentally missed them, # so report if we did 4 9 * * 5 root /a/bin/ds/check-stale-alerts +4 10 * * 5 root /a/bin/ds/check-radicale 4 15 * * 5 iank /a/bin/ds/mailclean 14 * * * * root /a/bin/ds/bk-backup |& log-once -24 bk-backup 0 7 * * * iank failmail myupgrade-iank diff --git a/filesystem/etc/systemd/logind.conf.d/iank.conf b/filesystem/etc/systemd/logind.conf.d/iank.conf index 6c4b2ee..6cbf33b 100644 --- a/filesystem/etc/systemd/logind.conf.d/iank.conf +++ b/filesystem/etc/systemd/logind.conf.d/iank.conf @@ -1 +1,2 @@ -HandleLidSwitch= +[Login] +HandleLidSwitch=ignore diff --git a/filesystem/etc/systemd/system/bitcoind.service b/filesystem/etc/systemd/system/bitcoind.service new file mode 100644 index 0000000..6697933 --- /dev/null +++ b/filesystem/etc/systemd/system/bitcoind.service @@ -0,0 +1,85 @@ +# iank: copied from /a/opt/bitcoin/contrib/init/bitcoind.service +# for sources as of 2022-11-14 + +# It is not recommended to modify this file in-place, because it will +# be overwritten during package upgrades. If you want to add further +# options or overwrite existing ones then use +# $ systemctl edit bitcoind.service +# See "man systemd.service" for details. + +# Note that almost all daemon options could be specified in +# /etc/bitcoin/bitcoin.conf, but keep in mind those explicitly +# specified as arguments in ExecStart= will override those in the +# config file. + +[Unit] +Description=Bitcoin daemon +Documentation=https://github.com/bitcoin/bitcoin/blob/master/doc/init.md + +# https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/ +After=network-online.target +Wants=network-online.target + +[Service] +ExecStart=/usr/bin/bitcoind -daemonwait \ + -pid=/run/bitcoind/bitcoind.pid \ + -conf=/etc/bitcoin/bitcoin.conf \ + -datadir=/var/lib/bitcoind + +# Make sure the config directory is readable by the service user +PermissionsStartOnly=true +ExecStartPre=/bin/chgrp bitcoin /etc/bitcoin + +# Process management +#################### + +Type=forking +PIDFile=/run/bitcoind/bitcoind.pid +Restart=on-failure +TimeoutStartSec=infinity +TimeoutStopSec=600 + +# Directory creation and permissions +#################################### + +# Run as bitcoin:bitcoin +User=bitcoin +Group=bitcoin + +# /run/bitcoind +RuntimeDirectory=bitcoind +RuntimeDirectoryMode=0710 + +# /etc/bitcoin +ConfigurationDirectory=bitcoin +ConfigurationDirectoryMode=0710 + +# /var/lib/bitcoind +StateDirectory=bitcoind +StateDirectoryMode=0710 + +# Hardening measures +#################### + +# Provide a private /tmp and /var/tmp. +PrivateTmp=true + +# Mount /usr, /boot/ and /etc read-only for the process. +ProtectSystem=full + +# Deny access to /home, /root and /run/user +ProtectHome=true + +# Disallow the process and all of its children to gain +# new privileges through execve(). +NoNewPrivileges=true + +# Use a new /dev namespace only populated with API pseudo devices +# such as /dev/null, /dev/zero and /dev/random. +PrivateDevices=true + +# Deny the creation of writable and executable memory mappings. +MemoryDenyWriteExecute=true + +[Install] +WantedBy=multi-user.target diff --git a/filesystem/etc/systemd/system/btrfsmaint.service b/filesystem/etc/systemd/system/btrfsmaint.service index 04f8f25..73fb294 100644 --- a/filesystem/etc/systemd/system/btrfsmaint.service +++ b/filesystem/etc/systemd/system/btrfsmaint.service @@ -4,6 +4,7 @@ After=multi-user.target [Service] Type=simple +# note, btrfs maint is hardlinked into fsf ansible repo ExecStart=/usr/local/bin/btrfsmaint --no-stats IOSchedulingClass=idle CPUSchedulingPolicy=idle diff --git a/filesystem/etc/systemd/system/btrfsmaintstop.service b/filesystem/etc/systemd/system/btrfsmaintstop.service index 5ddec17..88f90a9 100644 --- a/filesystem/etc/systemd/system/btrfsmaintstop.service +++ b/filesystem/etc/systemd/system/btrfsmaintstop.service @@ -5,7 +5,7 @@ StartLimitIntervalSec=0 [Service] Type=simple -ExecStart=/usr/local/bin/btrfsmaint check +ExecStart=/usr/local/bin/btrfsmaint --check Restart=always RestartSec=600 diff --git a/filesystem/etc/systemd/system/networking.service.d/timeout.conf b/filesystem/etc/systemd/system/networking.service.d/timeout.conf index e496ec0..6dd21f9 100644 --- a/filesystem/etc/systemd/system/networking.service.d/timeout.conf +++ b/filesystem/etc/systemd/system/networking.service.d/timeout.conf @@ -1,2 +1,3 @@ [Service] TimeoutStartSec=20 +TimeoutStopSec=7 diff --git a/filesystem/usr/local/bin/bitcoinoff b/filesystem/usr/local/bin/bitcoinoff new file mode 100755 index 0000000..d952873 --- /dev/null +++ b/filesystem/usr/local/bin/bitcoinoff @@ -0,0 +1,4 @@ +#!/bin/bash +[[ $EUID == 0 ]] || exec sudo "${BASH_SOURCE[0]}" + +systemctl stop bitcoind diff --git a/i3-sway/common.conf b/i3-sway/common.conf index 6c79c29..a47e6cf 100644 --- a/i3-sway/common.conf +++ b/i3-sway/common.conf @@ -7,8 +7,10 @@ set $mod Mod4 bindsym $mod+2 exec "pavucontrol" -bindsym $mod+3 exec "abroswer" -#bindsym $mod+3 exec "abrowser -no-remote -P sfw" +# ian: dunno why but i needed this version at some point, then +# it mysteriously stopped working, but works on the cli. 2022-12 +#bindsym $mod+3 exec "abroswer" +bindsym $mod+3 exec "abrowser -no-remote -P sfw" bindsym $mod+4 exec "abrowser -no-remote -P firefox-main-profile" bindsym $mod+5 exec "/usr/local/bin/start-tor-browser" bindsym $mod+6 exec "/a/bin/redshift.sh" @@ -30,7 +32,8 @@ bindsym $mod+e fullscreen toggle bindsym $mod+r exec "/a/bin/ds/xl" # todo, in newer i3, make this toggle split tabbed bindsym $mod+t layout toggle split -bindsym $mod+Shift+t move workspace to output right +bindsym $mod+Shift+t move workspace to output up +#bindsym $mod+Shift+t move workspace to output right bindsym $mod+g layout tabbed # Use Mouse+$mod to drag floating windows to their wanted position diff --git a/input-setup b/input-setup index 8f0d99b..8085d07 100755 --- a/input-setup +++ b/input-setup @@ -93,7 +93,7 @@ fi # slow down ploopy trackball, until we recompile firmware id=$(xinput list | grep -F 'Ploopy Corporation Trackball Mouse' | sed -rn 's/.*[[:space:]]id=([^[:space:]]*).*/\1/p' ||:) if [[ $id ]]; then - xinput --set-prop 'libinput Accel Speed' -0.9 + xinput --set-prop $id 'libinput Accel Speed' -0.9 fi set +x diff --git a/machine_specific/kd/filesystem/etc/cron.d/kd b/machine_specific/kd/filesystem/etc/cron.d/kd index d0f78b0..b2c2b45 100644 --- a/machine_specific/kd/filesystem/etc/cron.d/kd +++ b/machine_specific/kd/filesystem/etc/cron.d/kd @@ -9,8 +9,8 @@ MAILTO=root 0 17 * * 1,2,3,4,5 root failmail wrt-setup -z # weekends -0 6 * * 6,7 root failmail wrt-setup -y -0 17 * * 6,7 root failmail wrt-setup -z +#0 6 * * 6,7 root failmail wrt-setup -y +#0 17 * * 6,7 root failmail wrt-setup -z # saturday morning # old diff --git a/mail-setup b/mail-setup index 22d1e3d..f17b3af 100755 --- a/mail-setup +++ b/mail-setup @@ -3,6 +3,11 @@ # Copyright (C) 2019 Ian Kelling # SPDX-License-Identifier: AGPL-3.0-or-later +# perusing through /el/mainlog without test messages: +# &!testignore|jtuttle| +# +#&! testignore|jtuttle|eximbackup|/usr/sbin/exim4 -bpu + # todo: check new macro DKIM_TIMESTAMPS # todo: check if REMOTE_SMTP_INTERFACE or REMOTE_SMTP_TRANSPORTS_HEADERS_REMOVE can simplify my or fsfs config @@ -328,9 +333,19 @@ soff () { done } sre() { + local enabled for service; do m systemctl restart $service - m systemctl enable $service; + # Optimization for exim, + # is-enabled: 0m0.015s + # enable: 0m0.748s + # It is related to this message: + # exim4.service is not a native service, redirecting to systemd-sysv-install. + # Executing: /lib/systemd/systemd-sysv-install enable exim4 + enabled=$(systemctl is-enabled $service 2>/dev/null ||:) + if [[ $enabled != enabled ]]; then + m systemctl enable $service + fi done } mailhost() { @@ -1258,7 +1273,7 @@ delay_warning_condition = ${if or {\ # enable 587 in addition to the default 25, so that # i can send mail where port 25 is firewalled by isp -daemon_smtp_ports = 25 : 587 +daemon_smtp_ports = 25 : 587 : 10025 # default of 25, can get stuck when catching up on mail smtp_accept_max = 400 smtp_accept_reserve = 100 @@ -1318,7 +1333,7 @@ u /etc/exim4/conf.d/data_local_acl <<'EOF' # those docs are rather old and I see a 110k spam message # pretty quickly looking through my spam folder. -warn +#warn !hosts = +iank_trusted remove_header = X-Spam_score: X-Spam_score_int : X-Spam_bar : X-Spam_report @@ -1730,6 +1745,7 @@ if mailhost; then # # setup chgrp www-data in ./conflink pi-nostart radicale + m usermod -a -G radicale iank u /etc/systemd/system/radicale.service.d/override.conf < $try_limit seconds" break fi if (( try_left < timeout )); then @@ -145,10 +146,11 @@ EOF fi tmpfile=$(mktemp) declare -i unexpected=0 - declare -i missing_dnswl=0 - declare -i dnsfail=0 for folder in ${folders[@]}; do for from in ${froms[@]}; do + declare -i missing_dnswl=0 + declare -i dnsfail=0 + declare -i unexpected=0 latest= last_sec=0 @@ -217,8 +219,8 @@ EOF # eggs has RCVD_IN_DNSWL_MED keys+=(RCVD_IN_DNSWL_MED) elif [[ $from == *@gnu.org ]]; then - # eggs has these - keys+=(RCVD_IN_DNSWL_MED DKIMWL_WL_HIGH) + # eggs has this. it used to have DKIMWL_WL_HIGH sometime in 2022 + keys+=(RCVD_IN_DNSWL_MED) fi for t in ${keys[@]}; do @@ -289,6 +291,10 @@ EOF ;; esac done + pr </dev/null; then if [[ $HOSTNAME == "$MAIL_HOST" ]]; then # arbtt disabled for now #DISPLAY=:0 arbtt-capture --sample-rate=10 & m systemctl --now enable rss2email.timer - # off is in mail-setup. no reason for this to be in the rss2email block. - m systemctl --now enable btrbk.timer else files=(/sysd-mail-once/btrbk*) if (( ${#files[@]} )); then rm -f ${files[@]} fi - m systemctl --now disable btrbk.timer m systemctl stop rss2email.service m systemctl --now disable rss2email.timer diff --git a/subdir_files/sieve/lists.sieve b/subdir_files/sieve/lists.sieve index bd31574..263b963 100644 --- a/subdir_files/sieve/lists.sieve +++ b/subdir_files/sieve/lists.sieve @@ -93,6 +93,7 @@ if anyof ( header :contains "list-id" "", header :contains "list-id" "", header :contains "list-id" "", + header :contains "list-id" "", header :contains "list-id" "", header :contains "list-id" "") { if header :regex "list-id" "<([a-z_0-9-]+)[.@]" { diff --git a/subdir_files/sieve/liststest.sieve b/subdir_files/sieve/liststest.sieve index bd31574..263b963 100644 --- a/subdir_files/sieve/liststest.sieve +++ b/subdir_files/sieve/liststest.sieve @@ -93,6 +93,7 @@ if anyof ( header :contains "list-id" "", header :contains "list-id" "", header :contains "list-id" "", + header :contains "list-id" "", header :contains "list-id" "", header :contains "list-id" "") { if header :regex "list-id" "<([a-z_0-9-]+)[.@]" { diff --git a/switch-mail-host b/switch-mail-host index 08e74fc..4a7ce37 100644 --- a/switch-mail-host +++ b/switch-mail-host @@ -196,7 +196,7 @@ e "On $new_host: umounting /m and /o, checking emacs" cat <<'EOF' set -eE if pgrep -G iank -u iank -f 'emacs --daemon' &>/dev/null; then - bufs="$(sudo -u iank emacsclient --eval "$(cat /a/bin/ds/unsaved-buffers.el)"| sed '/^"nil"$/d;s/^"(/E: /;s/)"$//')" + bufs="$(sudo -u iank env XDG_RUNTIME_DIR=/run/user/1000 emacsclient --eval "$(cat /a/bin/ds/unsaved-buffers.el)"| sed '/^"nil"$/d;s/^"(/E: /;s/)"$//')" if [[ $bufs ]]; then echo "error: on $HOSTNAME, unsaved emacs files: $bufs" >&2 exit 1 @@ -217,7 +217,7 @@ EOF $old_shell bash -s <<'EOF' if pgrep -G iank -u iank -f 'emacs --daemon' &>/dev/null; then - bufs="$(sudo -u iank emacsclient --eval "$(cat /a/bin/ds/unsaved-buffers.el)"| sed '/^"nil"$/d;s/^"(/E: /;s/)"$//')" + bufs="$(sudo -u iank env XDG_RUNTIME_DIR=/run/user/1000 emacsclient --eval "$(cat /a/bin/ds/unsaved-buffers.el)"| sed '/^"nil"$/d;s/^"(/E: /;s/)"$//')" if [[ $bufs ]]; then echo "error: on $HOSTNAME, unsaved emacs files: $bufs" >&2 exit 1 @@ -253,7 +253,7 @@ if ! $mail_only; then fi if $host2_only; then - if [[ $old_hostname != "$MAIL_HOST" ]]; then + if [[ $old_hostname != "$MAIL_HOST" && $old_hostname != kd ]]; then m $old_shell systemctl --now disable btrbk.timer fi m $new_shell systemctl --now enable btrbk.timer diff --git a/system-status b/system-status index d6874e1..3513c90 100755 --- a/system-status +++ b/system-status @@ -381,6 +381,9 @@ main-loop() { fi wait=15 if ! $power; then + if systemctl -q is-active bitcoind; then + bitcoinoff + fi wait=60 fi