From 8d29de95be2b44cac6e2cc3d0643f542be05e4bd Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Wed, 5 Jul 2023 04:37:40 -0400 Subject: [PATCH] harmonize vpn, lan, and transmission ips --- brc | 5 + brc2 | 162 ++++++++++++++++-- distro-end | 44 ++--- .../systemd/system/openvpn-client-tr@.service | 36 ++++ .../systemd/system/openvpn-client-tr@.service | 36 ++++ .../systemd/system/openvpn-client-tr@.service | 10 +- .../systemd/system/openvpn-client-tr@.service | 36 ++++ .../systemd/system/openvpn-client-tr@.service | 36 ++++ .../systemd/system/openvpn-client-tr@.service | 36 ++++ .../systemd/system/openvpn-client-tr@.service | 36 ++++ ptr-data | 7 + transmission-firewall/netns.rules | 6 +- 12 files changed, 398 insertions(+), 52 deletions(-) create mode 100644 machine_specific/bo/filesystem/etc/systemd/system/openvpn-client-tr@.service create mode 100644 machine_specific/frodo/filesystem/etc/systemd/system/openvpn-client-tr@.service rename {filesystem => machine_specific/kd/filesystem}/etc/systemd/system/openvpn-client-tr@.service (81%) create mode 100644 machine_specific/kw/filesystem/etc/systemd/system/openvpn-client-tr@.service create mode 100644 machine_specific/sy/filesystem/etc/systemd/system/openvpn-client-tr@.service create mode 100644 machine_specific/x2/filesystem/etc/systemd/system/openvpn-client-tr@.service create mode 100644 machine_specific/x3/filesystem/etc/systemd/system/openvpn-client-tr@.service create mode 100644 ptr-data diff --git a/brc b/brc index 8483735..f2793e8 100644 --- a/brc +++ b/brc @@ -1938,6 +1938,11 @@ reresolv() { fi } +# add annoyingly long argument which should be the default +sedi() { + sed -i --follow-symlinks "$@" +} + rmstrips() { ssh fencepost head -n 300 /gd/gnuorg/EventAndTravelInfo/rms-current-trips.txt | less } diff --git a/brc2 b/brc2 index b6a4bd3..1be253a 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 @@ -2317,9 +2330,119 @@ 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 @@ -2331,12 +2454,20 @@ wghole() { 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 <>/tmp/calendar-bytes done done < <(grep -v '[#-]' /p/calendar-data) @@ -3504,7 +3636,7 @@ rem() { -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 ||: - } +} # setup: # pip3 install linode-cli diff --git a/distro-end b/distro-end index 80aec6e..593e91e 100755 --- a/distro-end +++ b/distro-end @@ -671,34 +671,18 @@ EOF client-to-client EOF - sd /etc/openvpn/client-config-hole/kd <<'EOF' -ifconfig-push 10.5.5.2 255.255.255.0 -EOF - sd /etc/openvpn/client-config-hole/tp <<'EOF' -ifconfig-push 10.5.5.3 255.255.255.0 -EOF - sd /etc/openvpn/client-config-hole/frodo <<'EOF' -ifconfig-push 10.5.5.5 255.255.255.0 -EOF - sd /etc/openvpn/client-config-hole/x2 <<'EOF' -ifconfig-push 10.5.5.7 255.255.255.0 -EOF - sd /etc/openvpn/client-config-hole/x3 <<'EOF' -ifconfig-push 10.5.5.8 255.255.255.0 -EOF - sd /etc/openvpn/client-config-hole/kw <<'EOF' -ifconfig-push 10.5.5.9 255.255.255.0 -EOF - sd /etc/openvpn/client-config-hole/sy <<'EOF' -ifconfig-push 10.5.5.12 255.255.255.0 -EOF - sd /etc/openvpn/client-config-hole/bo <<'EOF' -ifconfig-push 10.5.5.13 255.255.255.0 -EOF - sd /etc/openvpn/client-config-hole/onep9 <<'EOF' -ifconfig-push 10.5.5.14 255.255.255.0 + + ngset + files=(/etc/openvpn/client-config-hole/*) + if (( ${#files[@]} >= 1 )); then + rm -f ${files[@]} + fi + ngreset + for host in ${!vpn_ips[@]}; do + sd /etc/openvpn/client-config-hole/$host <