X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=brc2;h=891e0953b668e7e69d847f54e5f4ad24f768fff5;hb=165008e5b82c81ebff1061c8f8294c3bc6e9dced;hp=75ed2bcc5ead91e501b91d49a13c6bc9a6ae0899;hpb=4d0dc703ef2e62cd16ea84f27456f6f50f74baa3;p=distro-setup diff --git a/brc2 b/brc2 index 75ed2bc..891e095 100644 --- a/brc2 +++ b/brc2 @@ -29,7 +29,6 @@ export WCDHOME=/a source /a/bin/distro-functions/src/identify-distros source /a/bin/distro-functions/src/package-manager-abstractions source /a/bin/log-quiet/logq-function -source /a/bin/small-misc-bash/psg-function # for x in /a/bin/bash_unpublished/source-!(.#*); do echo source $x; done source /a/bin/bash_unpublished/source-semi-priv source /a/bin/bash_unpublished/source-state @@ -101,14 +100,16 @@ set -e conflink f=/var/lib/bind/db.b8.nz ser stop bind9 -s rm -fv $f.jnl -s install -m 644 -o bind -g bind /p/c/machine_specific/linode/bind-initial/db.b8.nz $f +sudo rm -fv $f.jnl +sudo install -m 644 -o bind -g bind /p/c/machine_specific/linode/bind-initial/db.b8.nz $f ser restart bind9 EOF done } bbk() { # btrbk wrapper + + local pid c / local active=true systemctl is-active btrbk.timer || active=false @@ -122,8 +123,15 @@ bbk() { # btrbk wrapper fi # run latest install-my-scripts - btrbk-run "$@" | pee cat "systemd-cat -t btrbk-run" - $active && ser enable btrbk.timer + jrun -p btrbk btrbk-run "$@" + if $active; then + if (( $ret )); then + echo bbk: WARNING: btrbk.timer not reenabled due to failure + else + ser enable btrbk.timer + fi + fi + return $ret } bfg() { java -jar /a/opt/bfg-1.12.14.jar "$@"; } @@ -132,34 +140,76 @@ bigclock() { xclock -digital -update 1 -face 'arial black-80:bold' } -bpull() { - [[ $1 ]] || return 1 - c / - # run latest - install-my-scripts - switch-mail-host $1 $HOSTNAME | pee cat "systemd-cat -t switch-mail-host" +_jrun() { # journal run. run args, log to journal, tail and grep the journal. + local pid pattern jr_pid sedscript cmd_name ended + ret=0 + case $1 in + -p) + pattern="$2\|" + shift 2 + ;; + esac + cmd_name=${1##*/} + systemd-cat -t "$cmd_name" "$@" 2>&1 & + pid=$! + sedscript="/$pattern$cmd_name/p;/^.{16}[^ ]+ $cmd_name\[$pid]: ([^ ]+ +)?exiting with status [0-9]+\$/q" + journalctl -S "4 seconds ago" -f |& sed -nr "$sedscript" 2>&1 & + jr_pid=$! + wait $pid 2>&1 || ret=$? + if (( $ret )); then + echo "$0: ERROR: $* returned $ret" + fi + jobs %'journalctl -S "4 seconds ago" -f' &>/dev/null + ended=false + # give it about 5 seconds to find the end of the log + for (( i=0; i<20; i++ )); do + if jobs %'journalctl -S "4 seconds ago" -f' &>/dev/null; then + sleep .3 2>&1 + else + ended=true + break + fi + done + if ! $ended; then + kill $jr_pid 2>&1 + fi +} +jrun() { + # ditching stderr avoids the jobs status change output. + _jrun "$@" 2>/dev/null } -bpush() { - [[ $1 ]] || return 1 + +sm() { + (( $# == 2 )) || return 1 + action=$1 + shift + host=$1 + shift + case $action in + pull|push) : ;; + *) return 1 ;; + esac c / # run latest install-my-scripts - switch-mail-host $HOSTNAME $1 | pee cat "systemd-cat -t switch-mail-host" + jrun -p btrbk switch-mail-host $action $host + return $ret } + lipush() { # note, i had --delete-excluded, but that deletes all files in --exclude-from on # the remote site, which doesn't make sense, so not sure why i had it. local p a - p=(/a/bin /a/exe /a/h /a/c /p/c/machine_specific/linode{,.hosts} /a/opt/{emacs,emacs-debianstable,mu}) + p=(/a/bin /a/exe /a/h /a/c /p/c/machine_specific/linode{,.hosts} /a/opt/{emacs-debianstable,mu}) a="-ahviSAXPH --specials --devices --delete --relative --exclude-from=/p/c/li-rsync-excludes" ret=0 - m rsync $@ $a ${p[@]} /p/c/machine_specific/l2 root@l2.b8.nz:/ || ret=$? - m rsync $@ $a ${p[@]} /p/c/machine_specific/li root@li.b8.nz:/ || ret=$? - m rsync $@ -ahviSAXPH root@iankelling.org:/a/h/proposed-comments/ /a/h/proposed-comments || ret=$? + m rsync "$@" $a ${p[@]} /p/c/machine_specific/l2 root@l2.b8.nz:/ || ret=$? + m rsync "$@" $a ${p[@]} /p/c/machine_specific/li root@li.b8.nz:/ || ret=$? + m rsync "$@" -ahviSAXPH root@iankelling.org:/a/h/proposed-comments/ /a/h/proposed-comments || ret=$? return $ret } lipushnoe() { # noe = noemacs. for running faster. - rsync $@ --delete-excluded -ahviSAXPH --specials --devices --delete --relative \ + rsync "$@" --delete-excluded -ahviSAXPH --specials --devices --delete --relative \ --exclude-from=/p/c/li-rsync-excludes /a/bin /a/exe /a/h /a/c /p/c/machine_specific/li root@li:/ } @@ -234,8 +284,9 @@ chrome() { # do all tee. # pipe to this, or just type like a shell +# todo: test this dat() { - tee >(ssh frodo.b8.nz bash -l) >(ssh x2 bash -l) >(ssh tp.b8.nz bash -l) >(ssh kw bash -l) >(ssh tp.b8.nz bash -l) + tee >(ssh frodo.b8.nz) >(ssh x2) >(ssh tp.b8.nz) >(ssh kw) >(ssh tp.b8.nz) } da() { # do all local host @@ -272,13 +323,18 @@ digme() { dup() { local ran_d ran_d=false + system-status _ case $PS1 in *DISTRO-BEGIN!*|*DISTRO!*) + pushd / /b/ds/distro-begin || return $? + popd ran_d=true ;;& *DISTRO-END!*|*DISTRO!*) + pushd / /b/ds/distro-end || return $? + popd ran_d=true ;;& *CONFLINK*) @@ -512,12 +568,10 @@ fw() { firefox -P default "$@" >/dev/null 2>&1 } - gitian() { git config user.email ian@iankelling.org } - # at least in flidas, things rely on gpg being gpg1 gpg() { command gpg2 "$@" @@ -532,7 +586,6 @@ gse() { --suppress-cc=self "$@" } - hstatus() { # do git status on published repos. c /a/bin/githtml @@ -548,11 +601,16 @@ hstatus() { done } - idea() { /a/opt/idea-IC-163.7743.44/bin/idea.sh "$@" &r } +ilog() { + chan=${1:-#fsfsys} + # use * instead of -r since that does sorted order + ssh root@iankelling.org "cd /var/lib/znc/moddata/log/iank/freenode/$chan && hr && for x in *; do echo \$x; cat \$x; hr; done" | less +G +} + o() { if type gvfs-open &> /dev/null ; then gvfs-open "$@" @@ -570,7 +628,7 @@ jtail() { journalctl -n 10000 -f "$@" | jfilter } jr() { journalctl "$@" | jfilter | less ; } -jrf() { journalctl -f "$@" | jfilter; } +jrf() { journalctl -n 200 -f "$@" | jfilter; } kff() { # keyboardio firmware flash @@ -636,32 +694,35 @@ mdt() { firefox /tmp/mdtest.html } - - mo() { xset dpms force off; } # monitor off +myirc() { + chan=${1:-fsf-office} + # use * instead of -r since that does sorted order + ssh root@iankelling.org "cd /var/lib/znc/moddata/log/iank/freenode/#$chan; grep '\