X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=brc2;h=bad1194baf610135693989e4eb8da56efee403de;hb=768363d8771edb9d9ed82425fa772d77b90139c0;hp=1be253a6151eab4f2b735a557c67d026c5fa5b73;hpb=8d29de95be2b44cac6e2cc3d0643f542be05e4bd;p=distro-setup diff --git a/brc2 b/brc2 index 1be253a..bad1194 100644 --- a/brc2 +++ b/brc2 @@ -289,14 +289,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 +420,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 +428,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 +443,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 +452,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" ;; @@ -1283,7 +1310,7 @@ btrbk-date-sed() { done } jrbtrbk() { - jr -u btrbk-run -u btrbk -u switch-mail-host -u btrbk-spread "$@" + jr -u btrbk-run -u btrbk -u switch-mail-host "$@" } # internal function @@ -1327,7 +1354,7 @@ btrbk-host-debug() { ## this takes a while, we only want to do it on 1st run # if [[ -s /tmp/b/$host.log ]]; then continue; fi - # ssh $host journalctl -u btrbk-run -u btrbk -u switch-mail-host -u btrbk-spread >/tmp/b/$host.log + # ssh $host journalctl -u btrbk-run -u btrbk -u switch-mail-host >/tmp/b/$host.log done gr '\bsnapshot success' /var/log/btrbk/*.log >/tmp/b/local.log cd /tmp/b @@ -1385,8 +1412,6 @@ bbk() { # btrbk wrapper return 1 ;; esac - # run latest - 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 jdo btrbk-run "$@" @@ -1593,7 +1618,6 @@ sm() { # switch mail host if [[ ! $tmp ]]; then s ssh-add /root/.ssh/home fi - install-my-scripts s jdo switch-mail-host "$@" return $ret } @@ -1618,7 +1642,7 @@ lipush() { local p a # excluding emacs for now #p=(/a/opt/{emacs-debian11{,-nox},mu,emacs} /a/bin /a/exe /a/h /a/c /p/c/machine_specific/vps{,.hosts}) - p=(/a/bin /a/exe /a/h /a/c /p/c/machine_specific/vps{,.hosts}) + p=(/a/bin /a/exe /a/h /a/c /p/c/machine_specific/vps{,.hosts} /c/roles/prom_export/files/simple/usr/local/bin/fsf-install-node-exporter) a="-ahviSAXPH --specials --devices --delete --relative --exclude-from=/p/c/li-rsync-excludes" ret=0 for h in li je bk; do @@ -1631,14 +1655,14 @@ lipush() { return $ret } bkpush() { # no emacs. for running faster. - p=(/a/bin /a/exe /a/h /a/c /p/c/machine_specific/vps{,.hosts}) + p=(/a/bin /a/exe /a/h /a/c /p/c/machine_specific/vps{,.hosts} /c/roles/prom_export/files/simple/usr/local/bin/fsf-install-node-exporter) a="-ahviSAXPH --specials --devices --delete --relative --exclude-from=/p/c/li-rsync-excludes" ret=0 m rsync "$@" $a ${p[@]} /p/c/machine_specific/bk root@bk.b8.nz:/ || ret=$? return $ret } jepush() { # no emacs. for running faster. - p=(/a/bin /a/exe /a/h /a/c /p/c/machine_specific/vps{,.hosts}) + p=(/a/bin /a/exe /a/h /a/c /p/c/machine_specific/vps{,.hosts} /c/roles/prom_export/files/simple/usr/local/bin/fsf-install-node-exporter) a="-ahviSAXPH --specials --devices --delete --relative --exclude-from=/p/c/li-rsync-excludes" ret=0 m rsync "$@" $a ${p[@]} /p/c/machine_specific/je root@je.b8.nz:/ || ret=$? @@ -1649,7 +1673,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 @@ -2145,7 +2169,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$' @@ -2295,11 +2319,6 @@ ccomp xdg-open o # jr() { journalctl "$@" | jfilter | less ; } # jrf() { journalctl -n 200 -f "$@" | jfilter; } -jr() { journalctl "$@" ; } -jrf() { journalctl -n 200 -f "$@" ; } - - -ccomp journalctl jtail jr jrf ## old version for model01. i need to get that firmware working again. # kff() { # keyboardio firmware flash. you must hold down the tilde key @@ -2448,7 +2467,7 @@ wghole() { e expected 2-3 arg of hostname, ip suffix, and extrahost >&2 return 1 fi - local host ipsuf umask_orig + local host ipsuf umask_orig vpn_allowed host=$1 ipsuf=$2 if [[ $3 ]]; then @@ -2534,6 +2553,10 @@ mnsnonet() { lom() { # l = the loopback device local l base + # get sudo pass cached right away + if ! sudo -nv 2>/dev/null; then + sudo -v + fi if [[ $1 == /* ]]; then base=${1##*/} fs_file=$1 @@ -2755,6 +2778,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 + min_date=$(date -d 'monday 2 weeks ago' +%s) + 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. +profrecent() { + 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 -d +%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 @@ -3296,7 +3377,7 @@ enn() { s $ecmd "$@" return fi - pid=$(pgrep -f "/usr/sbin/exim4 -bd -q30m -C /etc/exim4/my.conf"|h1) + pid=$(pgrep -f "/usr/sbin/exim4 -bd -q10m -C /etc/exim4/my.conf"|h1) m s nsenter -t $pid -n -m $ecmd "$@" } @@ -3375,7 +3456,7 @@ mailnnbash() { eximbash() { local pid - pid=$(pgrep -f "/usr/sbin/exim4 -bd -q30m -C /etc/exim4/my.conf"|h1) + pid=$(pgrep -f "/usr/sbin/exim4 -bd -q10m -C /etc/exim4/my.conf"|h1) if [[ ! $pid ]]; then echo "eximbash: failed to find exim pid. systemctl -n 30 status exim4:" systemctl status exim4 @@ -3634,8 +3715,8 @@ rem() { 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 ||: + -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: @@ -3801,10 +3882,65 @@ fi # rg with respecting vcs ignore files rgv() { ret=0 - command rg -. -z --no-messages -L -i -M 900 -g '!auto-save-list' -g '!.savehist' "$@" || ret=$? + # -. = search dotfiles + # -z = search zipped files + # -i = case insensitive + # -M = max columns + # --no-messages because of annoying errors on broken symlinks + command rg -. -z --no-messages -i -M 900 -g '!.git' -g '!auto-save-list' -g '!.savehist' "$@" || ret=$? return $ret } +amall() { + echo "$(tput setaf 5 2>/dev/null ||:)█ coresite █$(tput sgr0 2>/dev/null||:)" + amfsf "$@" + echo "$(tput setaf 5 2>/dev/null ||:)█ office █$(tput sgr0 2>/dev/null||:)" + amoffice "$@" +} +amallq() { # amall quiet + amfsf "$@" + amoffice "$@" +} +amfsf() { + sedi -r '/alertmanager.url/s/@prom.office/@prom/' ~/.config/amtool/config.yml + amtool "$@" +} +amoffice() { + 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)" + amoffice silence expire "$(amoffice silence query -q)" +} + + +youtube-dl-update() { + sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl + sudo chmod a+rx /usr/local/bin/youtube-dl +} + +# 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 +} + +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