X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=brc2;h=e936badfba828a52dcbab2c003e8b1c05bd2c65a;hb=7f9af41bd119784d4f062731911d1485d224ec73;hp=3f953c1dc8c001b4bc110b9ebfc554efbb352066;hpb=50f25d1eec109c4596cfc638c9a7c98da0f0b5d0;p=distro-setup diff --git a/brc2 b/brc2 index 3f953c1..e936bad 100644 --- a/brc2 +++ b/brc2 @@ -840,6 +840,7 @@ mpvrpc-loadfile() { # q quit # ret next # +# todo: enter should also unpause beetag() { local last_genre_i fstring tag id char new_item char_i genre tag remove doplay i j random path local do_rare_genres read_wait help line lsout tmp ls_line skip_lookback @@ -1791,21 +1792,13 @@ bindpush() { dsign iankelling.org expertpathologyreview.com zroe.org amnimal.ninja lipush for h in li bk; do - e sshing $h - ssh $h.b8.nz <<'EOF' -source ~/.bashrc -m dnsup -EOF + m ssh $h.b8.nz dnsup done } bindpushb8() { lipush for h in li bk; do - e sshing $h - ssh $h.b8.nz <<'EOF' -source ~/.bashrc -m dnsb8 -EOF + m ssh $h.b8.nz dnsb8 done } @@ -1816,8 +1809,18 @@ dnsup() { dnsb8() { local f=/var/lib/bind/db.b8.nz m ser stop named - m sleep 1 - m sudo rm -fv $f.jnl $f.signed.jnl + # jbk is like a temp file. dunno if removing it helps + + i=0 + while pgrep '^named$' &>/dev/null; do + sleep .5 + i=$(( i + 1 )) + if (( i > 100 )); then + echo "dnsb8: error: timeout waiting for named to exit" + return 1 + fi + done + m sudo rm -fv $f.jnl $f.signed.jnl $f.jbk m sudo install -m 644 -o bind -g bind /p/c/machine_specific/vps/bind-initial/db.b8.nz $f m ser restart named } @@ -1996,16 +1999,10 @@ capache() - - -apache-apply() { - for file; do - if head -n1 "$file"| grep -E '^#!/bin/bash\b' &>/dev/null; then - { - head -n1 "$file" - # First paragraph is to avoid people being confused about why a - # file is apache licensed. - cat <<'EOF' +apache-header() { + # First paragraph is to avoid people being confused about why a + # file is apache licensed. + cat <<'EOF' # I, Ian Kelling, follow the GNU license recommendations at # https://www.gnu.org/licenses/license-recommendations.en.html. They # recommend that small programs, < 300 lines, be licensed under the @@ -2028,14 +2025,42 @@ apache-apply() { # limitations under the License. EOF + +} + +# apply apache to git tracked bash files + README, except files with A?GPL3 header. +apache-apply-repo() { + for f in $(git ls-files); do + [[ -L $f || ! -f $f ]] && continue + if [[ $f != README ]]; then + if ! grep -n '^#!/bin/bash' $f | grep ^1: &>/dev/null; then continue; fi + if head -n 10 $f | grep 'it under the terms of the GNU General Public License as published by' &>/dev/null; then continue; fi + fi + apache-apply $f + done +} + +apache-apply() { + for file; do + if head -n1 "$file"| grep -E '^#!/bin/bash\b' &>/dev/null; then + { + head -n1 "$file" + apache-header tail -n+2 "$file" } | sponge "$file" + else + { + apache-header + cat "$file" + } | sponge "$file" fi done } +# strip out the apache license from a file. apache-strip() { + # shellcheck disable=SC2044 # meh for f in $(find . -type f -maxdepth 1); do if head -n1 "$f"| grep -E '^#!/bin/bash\b' &>/dev/null; then { head -n 20 $f | tac | sed '/^# limitations under the License.$/,/^# Copyright.*Ian Kelling$/d' | tac; tail -n+21 $f; } |sponge $f; fi ; done - } +} chrome() { if type -p chromium &>/dev/null; then @@ -2541,7 +2566,10 @@ ilog-local() { cd $d$n/"$chan" hr for x in *; do - echo $x; sed "s/^./${x%log}/" $x; hr; + # *** are parts and joins and such, and they make reading hard. + # I probably will want to see them sometimes, just have to + # remove that part. + echo $x; sed "s/^./${x%log}/;/\*\*\*/d" $x; hr; done done } @@ -2604,19 +2632,62 @@ wgkey() { umask $umask_orig } -declare -A vpn_ips -vpn_ips[kd]=2 -# note: 1, 4, 5 are occupied by mail wireguard -vpn_ips[x3]=8 -vpn_ips[sy]=12 -vpn_ips[x2]=13 -vpn_ips[kw]=27 -vpn_ips[bo]=28 -vpn_ips[frodo]=34 -vpn_ips[s23b]=49 +host-info-all() { + host-info-update + bindpushb8 + wrt-setup +} + + +# if you change a host's ip, then run +# bindpushb8 +# wrt-setup +host-info-update() { + + local -A vpn_ips host_ips host_macs nonvpn_ips + local -a root_hosts nonroot_hosts + + # the hosts with no mac + root_hosts=( bk je li b8.nz ) + for h in ${root_hosts[@]}; do + root_hosts+=(${h}ex) + done + root_hosts+=(cmc) + + while read -r ip host mac opts; do + if [[ $ip == *#* || ! $host ]]; then continue; fi + if [[ $opts == vpn ]]; then + vpn_ips[$host]=$ip + else + nonvpn_ips[$host]=$ip + fi + + + if [[ $opts == user=root ]]; then + # note: the b8.nz suffix is for the User part, the IdentityFile + # part is redundant to *.b8.nz. + root_hosts+=($host i$host $host.b8.nz i$host.b8.nz) + else + nonroot_hosts+=($host i$host) + fi + + host_ips[$host]=$ip + host_macs[$host]=$mac + done