X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=brc2;h=75ed2bcc5ead91e501b91d49a13c6bc9a6ae0899;hb=4d0dc703ef2e62cd16ea84f27456f6f50f74baa3;hp=220f1241890f111bbf114f9fc5e1685342f2a768;hpb=95a4248e98e118024f5065636288406e8e8c9a30;p=distro-setup diff --git a/brc2 b/brc2 index 220f124..75ed2bc 100644 --- a/brc2 +++ b/brc2 @@ -232,14 +232,15 @@ chrome() { } -dat() { # do all tee, for more complex scripts - tee >(ssh frodo bash -l) >(bash -l) >(ssh x2 bash -l) >(ssh tp bash -l) +# do all tee. +# pipe to this, or just type like a shell +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) } da() { # do all local host - "$@" - for host in x2 tp kd; do - ssh $host $(printf "") + for host in x2 kw tp.b8.nz x3.b8.nz frodo.b8.nz; do + ssh $host "$@" done } @@ -263,31 +264,8 @@ debian_pick_mirror () { sudo sed -ri "/http.us.debian.org/ s@( *[^ #]+ +)[^ ]+([^#]+).*@\1$url\2# http.us.debian.org@" /etc/apt/sources.list sudo apt-get update } -dig() { - command dig +nostats +nocmd "$@" -} -# Output with sections sorted, and removal of query id, so 2 dig outputs can be diffed. -digsort() { - local sec - sec= - dig +nordflag "$@" | sed -r 's/^(;; ->>HEADER<<-.*), id: .*/\1/' | while read -r l; do - if [[ $l == [^\;]* ]]; then - sec+="$l"$'\n' - else - if [[ $sec ]]; then - printf "%s" "$sec" | sort - sec= - fi - printf "%s\n" "$l" - fi - done -} -# note: only the soa master nameserver will respond with -# ra "recursive answer" flag. That difference is meaningless afaik. -# Same thing happens with gnu nameservers. digme() { - digsort "$@" @ns1.iankelling.org | tee /tmp/digme - diff -u /tmp/digme <(digsort "$@" @ns2.iankelling.org) + digdiff @ns{1,2}.iankelling.org "$@" } @@ -295,11 +273,11 @@ dup() { local ran_d ran_d=false case $PS1 in - *DISTRO-BEGIN*) + *DISTRO-BEGIN!*|*DISTRO!*) /b/ds/distro-begin || return $? ran_d=true ;;& - *DISTRO-END*) + *DISTRO-END!*|*DISTRO!*) /b/ds/distro-end || return $? ran_d=true ;;& @@ -399,11 +377,15 @@ fdroid_pkgs=( fdup() { local -A installed updated local p - fdroidcl update + # tried putting this in go buildscript cronjob, + # but it failed with undefined: os.UserCacheDir. I expect its due to + # an environment variable missing, but its easier just to stick it here. + m go get -u mvdan.cc/fdroidcl || return 1 + m fdroidcl update if fdroidcl search -u | grep ^org.fdroid.fdroid; then fdroidcl install org.fdroid.fdroid sleep 5 - fdroidcl update + m fdroidcl update fi for p in $(fdroidcl search -i| grep -o "^\S\+"); do installed[$p]=true @@ -413,14 +395,14 @@ fdup() { done for p in ${fdroid_pkgs[@]}; do if ! ${installed[$p]:-false}; then - fdroidcl install $p + m fdroidcl install $p # sleeps are just me being paranoid since replicant has a history of crashing when certain apps are installed sleep 5 fi done for p in ${!installed[@]}; do if ! ${updated[$p]:-true}; then - fdroidcl install $p + m fdroidcl install $p sleep 5 fi done @@ -960,27 +942,30 @@ sl() { # Theres a couple ways to do this. im not sure whats best, # but relying on bash 4.4+ escape quoting seems most reliable. command ssh "${args[@]}" "$remote" \ - BRC=t bash -c '"\"\$@\""' bash ${@@Q} + BRC=t bash -c '.\ .iank/.bashrc\;"\"\$@\""' bash ${@@Q} + elif [[ ! -t 0 ]]; then + # This case is when commands are being piped to ssh. + # Normally, no bashrc gets sourced. + # But, since we are doing all this, lets source it because we can. + cat <(echo . .iank/.bashrc) - | command ssh "${args[@]}" "$remote" BRC=t bash else - # -t gives us an interactive shell for normal ssh. -l makes us use the rcfile when piping commands. - command ssh -t "${args[@]}" "$remote" BRC=t INPUTRC=.iank/.inputrc bash --rcfile .iank/.bashrc -l + command ssh -t "${args[@]}" "$remote" BRC=t INPUTRC=.iank/.inputrc bash --rcfile .iank/.bashrc fi else - BRC=t command ssh "$remote" "$@" + if [[ -t 0 ]]; then + BRC=t command ssh "${args[@]}" "$remote" ${@@Q} + else + command ssh "${args[@]}" "$remote" BRC=t bash -l + fi fi } sss() { # ssh solo - ssh -oControlMaster=no -oControlPath=/ "$@" + sl -oControlMaster=no -oControlPath=/ "$@" } # kill off old shared socket then ssh ssk() { - local -a opts=() - while [[ $1 == -* ]]; do - opts+=("$1") - shift - done - m pkill -f "^ssh: /tmp/ssh_mux_${USER}_${1#*@}_22_" - m ssh "${opts[@]}" "$@" + m ssh -O exit "$@" + m sl "$@" } # plain limited ssh ssh() {