X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;ds=sidebyside;f=brc2;h=0432e3ad419ff0c07a1f20a5087a125e45bc5aee;hb=2c39d0edb4d64c34356b8d5d6b65a25ee7aab040;hp=b6a4bd320e9b79b2be4c09dfb8e1877ae478070c;hpb=f5fe5af7aec9c23412c9c349e21c42f6c2208582;p=distro-setup diff --git a/brc2 b/brc2 index b6a4bd3..0432e3a 100644 --- a/brc2 +++ b/brc2 @@ -401,8 +401,7 @@ glue() { # usage: $0 REPO_PATH [URL_OR_PATH] _iki-convert() { - local url path input err repo_dir domain filename dir path url_dir - local initial_oldpwd initial_pwd + local url domain path input err repo_dir dir url_dir url repo_dir="$1" domain="$2" shift 2 @@ -417,7 +416,7 @@ _iki-convert() { fi case $input in http*) - path="$repo_dir/${input##http*://$domain/wiki/}" + path="$repo_dir/${input##http*://"$domain"/wiki/}" if [[ $path == */ ]]; then path=${path%/}.mdwn fi @@ -633,7 +632,7 @@ beetag-help() { cat <<'EOF' -y other genres z fg player ' = toggle play 1-5 rate +y other genres z fg player ' = toggle play 1-5 rate ] repeat1 ; previous _ = delete up/down skip mpv vol,pause,seek EOF hr @@ -697,12 +696,13 @@ mpvrpc-percent-pos() { # 1-5 rate # q quit # ret next +# 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 local escape_char escaped_input expected_input skip_input_regex right_pad erasable_line seek_sec local pl_state_path pl_state_dir pl_state_file tmpstr - local new_random pl_seed_path seed_num seed_file fmt first_play + local new_random pl_seed_path seed_num seed_file fmt first_play repeat1 local -a buttons button_map ids tags tmp_tags initial_ls ls_lines paths local -A button_i local -i i j volume scrolled id_count line_int skip_start pre_j_count head_count skip_lookback @@ -714,6 +714,7 @@ beetag() { scrolled=999 # more than any $LINES ### begin arg processing ### random=false + repeat1=false new_random=false case $1 in -r) @@ -778,6 +779,7 @@ beetag() { fi # PijokVipiotOzeph is just a random string for a delimiter + # shellcheck disable=SC2016 # false positive fmt='%ifdef{rating,$rating }'"$fstring"'$genre | $title - $artist - $album $length $id PijokVipiotOzeph $path' # shellcheck disable=SC2016 # obvious reason tmpstr=$(beet ls -f "$fmt" "$@" | { if $random; then sort -R --random-source=$pl_seed_path; else cat; fi; } ) @@ -940,6 +942,15 @@ beetag() { echo volume=$volume continue ;; + ']') + if $repeat1; then + repeat1=false + else + repeat1=true + fi + echo repeat1=$repeat1 + continue + ;; q) kill-bg-quiet return @@ -1106,10 +1117,12 @@ beetag() { fi fi done - if (( j < id_count - 1 )); then - j+=1 - else - j=0 + if ! $repeat1; then + if (( j < id_count - 1 )); then + j+=1 + else + j=0 + fi fi if [[ $playlist ]]; then echo $j >$pl_state_path @@ -1605,7 +1618,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 @@ -1618,14 +1631,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=$? @@ -2317,26 +2330,144 @@ 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-update() { + local host ipsuf f files + for host in ${!vpn_ips[@]}; do + ipsuf=${vpn_ips[$host]} + wghole $host $ipsuf + u /a/bin/ds/machine_specific/$host/filesystem/etc/systemd/system/openvpn-client-tr@.service < 3 )); then 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 extrahost=,$3 fi + for vpn_host in ${!vpn_ips[@]}; do + if [[ $vpn_host == "$host" ]]; then + continue + fi + vpn_allowed+=",10.174.${vpn_ips[$vpn_host]}.2/32" + done mkdir -p /p/c/machine_specific/$host/filesystem/etc/wireguard ( cd /p/c/machine_specific/$host/filesystem/etc/wireguard umask_orig=$(umask) umask 0077 - wg genkey | tee hole-priv.key | wg pubkey > hole-pub.key + if [[ ! -s hole-priv.key || ! -s hole-pub.key ]]; then + wg genkey | tee hole-priv.key | wg pubkey > hole-pub.key + fi cat >wghole.conf </dev/null; then + sudo -v + fi if [[ $1 == /* ]]; then base=${1##*/} fs_file=$1 @@ -3457,6 +3592,7 @@ calvis() { # calendar visualize install -m 600 /dev/null /tmp/calendar-bytes while read -r l; do for char in $l; do + # shellcheck disable=SC2059 # intentional for the hex formatting printf "\x$(printf "%x" $char)" >>/tmp/calendar-bytes done done < <(grep -v '[#-]' /p/calendar-data) @@ -3502,9 +3638,9 @@ 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: # pip3 install linode-cli @@ -3669,10 +3805,40 @@ 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() { + printf "$(tput setaf 5 2>/dev/null ||:)█ coresite █$(tput sgr0 2>/dev/null||:)" + amfsf "$@" + printf "$(tput setaf 5 2>/dev/null ||:)█ office █$(tput sgr0 2>/dev/null||:)" + amoffice "$@" +} +amallq() { # amall quiet + amfsf "$@" + amoffice "$@" +} +amfsf() { + sedi -r '/alertmanager.url/s/@office//' ~/.config/amtool/config.yml + amtool "$@" +} +amoffice() { + sedi -r '/alertmanager.url/s/@fsf/@office.fsf/' ~/.config/amtool/config.yml + amtool "$@" +} +amls() { + amall silence query "$@" +} +amrmall() { + amfsf silence expire $(amfsf silence query -q) + amoffice silence expire $(amoffice silence query -q) +} # taken from default changes to bashrc and bash_profile path-add --end --ifexists $HOME/.rvm/bin