X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=brc2;h=15f953909b6e2f790c28761d9053400c6a82260a;hb=2ff8740f1061a31683152a4447340921de82b1b9;hp=f291a8adef43dda09e0b0a4f829062f5b750e663;hpb=8796be333861fd2edc6c8b9b4c22307c11fce409;p=distro-setup diff --git a/brc2 b/brc2 index f291a8a..15f9539 100644 --- a/brc2 +++ b/brc2 @@ -71,6 +71,8 @@ source /a/bin/ds/beet-data # * functions + + multimic() { local i local -a sources @@ -289,14 +291,41 @@ tback() { # sshfs example: # s sshfs bu@$host:/bu/home/md /bu/mnt -o reconnect,ServerAliveInterval=20,ServerAliveCountMax=30 -o allow_other +edelayoff() { + echo all >/etc/exim4/no-delay-eximids +} +edelayon() { + echo >/etc/exim4/no-delay-eximids +} + eqgo() { - local -a array tmpstr + local -a array tmpstr delayon + delayon=true + if grep -qFx all /etc/exim4/no-delay-eximids; then + delayon=false + fi + if $delayon; then + echo all >/etc/exim4/no-delay-eximids + fi tmpstr=$(exiqgrep -i -r.\*) mapfile -t array <<<"$tmpstr" enn -M "${array[@]}" + if $delayon; then + echo >/etc/exim4/no-delay-eximids + fi } eqgo1() { - enn -M "$(exipick -i -r.\*|h1)" + local eid + eid="$(exipick -i -r.\*|h1)" + sed -n "/^all$/p;\$a $eid" /etc/exim4/no-delay-eximids + enn -M "$eid" +} +ennm() { + local eid + for eid; do + printf "%s\n" "$eid" >>/etc/exim4/no-delay-eximids + done + enn -M "$@" } @@ -393,7 +422,7 @@ astudio() { # Convert brains file path to url and vice versa # usage: brains [URL_OR_PATH] brains() { - _iki-convert '(/a)?/f/brains' brains.fsf.org "$@" + _iki-convert '(/a)?/f/brains' brains.fsf.org/wiki "$@" } glue() { _iki-convert '(/a)?/f/gluestick' gluestick.office.fsf.org "$@" @@ -401,9 +430,9 @@ glue() { # usage: $0 REPO_PATH [URL_OR_PATH] _iki-convert() { - local url domain path input err repo_dir dir url_dir url + local url prefix path input err repo_dir dir url_dir url repo_dir="$1" - domain="$2" + prefix="$2" shift 2 err=false if $err; then @@ -416,7 +445,7 @@ _iki-convert() { fi case $input in http*) - path="$repo_dir/${input##http*://"$domain"/wiki/}" + path="$repo_dir/${input##http*://"$prefix"/}" if [[ $path == */ ]]; then path=${path%/}.mdwn fi @@ -425,7 +454,7 @@ _iki-convert() { *) path=$(fp "$input") url_dir=$(echo "$path" | sed -r "s,^$repo_dir/,,") - url="https://$domain/wiki/$url_dir" + url="https://$prefix/$url_dir" url="${url%.mdwn}/" j echo "$url" ;; @@ -647,6 +676,7 @@ beetag-nostatus() { fi if $erasable_line; then # https://stackoverflow.com/a/71286261 + # erase line / delete line in terminal printf '\033[1A\033[K' fi erasable_line=false @@ -1162,7 +1192,7 @@ beet2nav() { # pull in beets library locally beetpull() { - local sshfs_host + local sshfs_host sshfs_cmd sshfs_host=b8.nz if [[ $HOSTNAME == kd ]]; then return 0 @@ -1171,8 +1201,9 @@ beetpull() { s mkdir /i s chown iank:iank /i fi - if ! mountpoint /i &>/dev/null; then - m sshfs $sshfs_host:/i /i + sshfs_cmd="sshfs -o ServerAliveInterval=15,reconnect $sshfs_host:/i /i" + if ! pgrep -f "^$sshfs_cmd$" >/dev/null; then + m $sshfs_cmd fi } @@ -1646,7 +1677,7 @@ bindpush() { dsign iankelling.org expertpathologyreview.com zroe.org amnimal.ninja lipush for h in li bk; do - m sl $h <<'EOF' + m sl $h.b8.nz <<'EOF' source ~/.bashrc m dnsup EOF @@ -2114,7 +2145,7 @@ gpg() { } gse() { - local email=ian@iankelling.org + local email=iank@fsf.org git send-email --notes "--envelope-sender=<$email>" \ --suppress-cc=self "$@" } @@ -2142,7 +2173,7 @@ hstatus() { wlog() { local day i days_back days_back=${1:-16} - for (( i=0; i=0; i-- )); do day=$( date +%F -d @$((EPOCHSECONDS - 86400*i )) ) date "+%a %b %d" -d @$((EPOCHSECONDS - 86400*i )) | tr '\n' ' ' /a/opt/timetrap/bin/t d -ftotal -s $day -e $day all -m '^w|lunch$' @@ -2751,6 +2782,22 @@ myirc() { # use * instead of -r since that does sorted order ssh root@iankelling.org "for f in ${d[*]}; do cd \$f/#$1; grep '\ 15 )); then + i=$(( logcount - 15 )) + else + i=0 + fi + # usually do this on monday, sometimes later + if [[ $(date +%A) == Monday ]]; then + min_date=$(date -d 'monday 2 weeks ago' +%s) + else + min_date=$(date -d 'monday 3 weeks ago' +%s) + fi + for (( ; i < logcount; i++ )); do + log=${logs[$i]} + d=$(date -d "$(head -n1 $log|awk '{print $1}')" +%s) + if (( d < min_date )); then + continue + fi + if awk '$3 == "iank:"' $log | sed -r 's/^(.{10}).(.{8})[^ ]+(.*)/\1_\2\3/' | grep .; then + hr + fi + done + popd } +# Tail pms in the last day, for the case where we restart profanity and +# didn't check for pms beforehand. Assume the most recent logs are on kd. +# If that isn't the case, use prof-recent-local +prof-recent() { + case $HOSTNAME in + kd) + prof-recent-local + ;; + *) + ssh b8.nz prof-recent-local + ;; + esac +} + +prof-recent-local() { + local d dates date files f + # consider making the day count passed by parameter. note: this works: $(date -d '2 day ago' +%Y_%m_%d) + dates=("$(date +%Y_%m_%d)" "$(date -d '1 day ago' +%Y_%m_%d)" ) + for d in /d/p/profanity/chatlogs/iank_at_fsf.org/!(rooms); do + files=() + for date in ${dates[@]}; do + f=$d/$date.log + if [[ -e $f ]]; then + files+=($f) + fi + done + if (( ${#files[@]} >= 1 )); then + cat ${files[@]} | tail + hr + fi + done +} + + # usage: debvm DEBIAN_VERSION RAM_MB debvm() { local ver ram fname src @@ -3204,9 +3310,12 @@ testexim() { # # -t = get recipient from header exim -d -t </dev/null | grep -iP --color=auto -- "$*" ||: + rgv -- "$*" $paths /a/t.org /p/w.org /a/work.org ||: +} +reml() { # with limit to 5 matches per file local paths paths="/p/c /b" find $paths -not \( -name .svn -prune -o -name .git -prune \ -o -name .hg -prune -o -name .editor-backups -prune \ - -o -name .undo-tree-history -prune \) 2>/dev/null | grep -iP --color=auto "$*" ||: - rgv -m 5 "$*" $paths /a/t.org /p/w.org /a/work.org ||: + -o -name .undo-tree-history -prune \) 2>/dev/null | grep -iP --color=auto -- "$*" ||: + rgv -m 5 -- "$*" $paths /a/t.org /p/w.org /a/work.org ||: } # setup: @@ -3817,16 +3934,24 @@ amallq() { # amall quiet amoffice "$@" } amfsf() { - sedi -r '/alertmanager.url/s/@office//' ~/.config/amtool/config.yml + sedi -r '/alertmanager.url/s/@prom.office/@prom/' ~/.config/amtool/config.yml amtool "$@" } amoffice() { - sedi -r '/alertmanager.url/s/@fsf/@office.fsf/' ~/.config/amtool/config.yml + sedi -r '/alertmanager.url/s/@prom.fsf/@prom.office.fsf/' ~/.config/amtool/config.yml amtool "$@" } amls() { amall silence query "$@" } +# amtool silence add +amsa() { + amall silence add "$@" +} +# amtool silence force +amsf() { + amall silence add x!="1" +} amrmall() { # note: not sure if quoting of this arg is correct amfsf silence expire "$(amfsf silence query -q)" @@ -3842,12 +3967,12 @@ youtube-dl-update() { # https://github.com/yt-dlp/yt-dlp/wiki/Installation yt-dlp-update() { sudo curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp -sudo chmod a+rx /usr/local/bin/yt-dlp # Make executable - } + sudo chmod a+rx /usr/local/bin/yt-dlp # Make executable +} mpvyt() { mpv --ytdl ytdl_path=/usr/local/bin/yt-dlp "$@" - } +} # taken from default changes to bashrc and bash_profile path-add --end --ifexists $HOME/.rvm/bin @@ -3855,6 +3980,34 @@ path-add --end --ifexists $HOME/.rvm/bin # so its included in overall env +# ya, hacky hardcoded hostnames in 2023. we could do better +hssh-update() { + local -a failed_hosts hosts + case $HOSTNAME in + sy|kd) + hosts=( + kd x3.office.fsf.org syw + ) + ;; + x3) + hosts=( + b8.nz sywg.b8.nz + ) + ;; + esac + for host in ${hosts[@]}; do + e $host + if ! scp /b/fai/fai/config/files/usr/local/bin/hssh/IANK root@$host:/usr/local/bin/hssh; then + failed_hosts+=($host) + fi + done + if (( ${#failed_hosts[@]} >= 1 )); then + echo failed_hosts=${failed_hosts[*]} + return 1 + fi +} + + export BASEFILE_DIR=/a/bin/fai-basefiles #export ANDROID_HOME=/a/opt/android-home