X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=brc2;h=a3ab32a872c189c09056f02703bf9f22b5d65642;hb=2df710615e0dd7243d8a05a8a58a9f8ec810433f;hp=959e892562f485afde4748c71cd66456c23f89ab;hpb=32a1673064cfd9eaa165b4ea62fa416f02f3dfd2;p=distro-setup diff --git a/brc2 b/brc2 index 959e892..a3ab32a 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,8 +100,8 @@ 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 @@ -122,7 +121,7 @@ bbk() { # btrbk wrapper fi # run latest install-my-scripts - btrbk-run "$@" |& pee cat "systemd-cat -t btrbk-run" + unbuffer btrbk-run "$@" |& pee cat "systemd-cat -t btrbk-run" if $active; then ser enable btrbk.timer fi @@ -139,14 +138,14 @@ bpull() { c / # run latest install-my-scripts - switch-mail-host pull $1 |& pee cat "systemd-cat -t switch-mail-host" + ubuffer switch-mail-host pull $1 |& pee cat "systemd-cat -t switch-mail-host" } bpush() { [[ $1 ]] || return 1 c / # run latest install-my-scripts - switch-mail-host push $1 |& pee cat "systemd-cat -t switch-mail-host" + ubuffer switch-mail-host push $1 |& pee cat "systemd-cat -t switch-mail-host" } lipush() { # note, i had --delete-excluded, but that deletes all files in --exclude-from on @@ -236,8 +235,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 @@ -283,7 +283,7 @@ dup() { ran_d=true ;;& *DISTRO-END!*|*DISTRO!*) - pushd + pushd / /b/ds/distro-end || return $? popd ran_d=true @@ -659,21 +659,21 @@ net-dev-info() { hr e "s lshw -C network" hr - s lshw -C network + sudo lshw -C network } nk() { ser stop NetworkManager ser stop dnsmasq - s resolvconf -d NetworkManager + sudo resolvconf -d NetworkManager ser start dnsmasq - s ifup br0 + sudo ifup br0 } ngo() { - s ifdown br0 + sudo ifdown br0 ser start NetworkManager sleep 4 - s nmtui-connect + sudo nmtui-connect } otp() { @@ -746,8 +746,8 @@ pumpa() { #rbp() { rbt post -o "$@"; } rebr() { - s ifdown br0 - s ifup br0 + sudo ifdown br0 + sudo ifup br0 } resolvcat() { @@ -860,14 +860,14 @@ spd() { } spend() { - s systemctl suspend + sudo systemctl suspend } # ssh, copy my universal config over if needed. # By default .bashrc is sourced for ALL ssh commands. This is wonky. # Normally, this file is not sourced when a script is run, but we can -# override that by having #!/bin/bash -l. I want the same thing for ssh +# override that by sourcing ~/.bashrc. I want the same thing for ssh # commands. when a local script runs an ssh command, bashrc should not be # sourced, unless we use a modified command. # @@ -936,13 +936,15 @@ sl() { type=${tmp2: -1} if [[ $type == b ]]; then info_sec=${tmp::10} - if (( $(stat -c%Y /b/ds/brc) > info_sec || $(stat -c%Y /b/ds/.bashrc) > info_sec )); then - dorsync=true - rm -f $sshinfo - fi + for f in /b/ds/sl/.iank/*; do + if (( $(stat -L -c%Y $f) > info_sec )); then + dorsync=true + rm -f $sshinfo + break + fi + done fi else - dorsync=true # use this weird yes thing to ensure we know ssh succeeded if ! tmp=$(command ssh "${args[@]}" "$remote" "if test -e /a/bin/ds/.bashrc -a -L .bashrc; then echo yes; fi"); then echo failed sl test. doing plain ssh -v @@ -951,13 +953,12 @@ sl() { if [[ $tmp == yes ]]; then type=a else + dorsync=true type=b fi fi - if [[ $type == b ]] && $dorsync; then - if ! RSYNC_RSH="ssh ${args[*]}" rsync -rptL /b/ds/sl/.iank "$remote":; then - echo WARNING: rsync failed. remove $sshinfo to try again - fi + if $dorsync; then + RSYNC_RSH="ssh ${args[*]}" rsync -rptL /b/ds/sl/.iank "$remote": fi if $dorsync || ! $haveinfo; then sshinfo=/p/sshinfo/$now$type"$remote" @@ -965,9 +966,6 @@ sl() { chmod 666 $sshinfo fi if [[ $type == b ]]; then - if $dorsync; then - RSYNC_RSH="ssh ${args[*]}" rsync -rptL /b/ds/sl/.iank "$remote": - fi if (( ${#@} )); then # Theres a couple ways to do this. im not sure whats best, @@ -986,7 +984,7 @@ sl() { if [[ -t 0 ]]; then BRC=t command ssh "${args[@]}" "$remote" ${@@Q} else - command ssh "${args[@]}" "$remote" BRC=t bash -l + command ssh "${args[@]}" "$remote" BRC=t bash fi fi } @@ -1129,13 +1127,13 @@ vpn() { [[ $1 ]] || { echo need arg; return 1; } journalctl --unit=$vpn_service@$1 -f -n0 & - s systemctl start $vpn_service@$1 + sudo systemctl start $vpn_service@$1 # sometimes the ask-password agent does not work and needs a delay. sleep .5 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=779240 # noticed around 8-2017 after update from around stretch release # on debian testing, even though the bug is much older. - s systemd-tty-ask-password-agent + sudo systemd-tty-ask-password-agent } vpnoff() { @@ -1145,7 +1143,7 @@ vpnoff() { else local vpn_service=openvpn fi - s systemctl stop $vpn_service@$1 + sudo systemctl stop $vpn_service@$1 } vpnoffc() { # vpn off client ser stop openvpn-nn@client