From: Ian Kelling Date: Wed, 4 Nov 2020 23:16:24 +0000 (-0500) Subject: fixes X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=1e65aee83619b51df36b74b3ef847c4468c2fe5b;p=distro-setup fixes --- diff --git a/brc b/brc index 8d05863..d450cc6 100644 --- a/brc +++ b/brc @@ -328,6 +328,16 @@ a() { echo -n "$x" | xclip } +# a1 = awk {print $1} +for field in {1..20}; do + eval a$field"() { awk '{print \$$field}'; }" +done +# h1 = head -n1 +for num in {1..9}; do + eval h$num"() { head -n$num}; }" +done + + b() { # backwards c - @@ -1070,6 +1080,11 @@ r() { # exit "$@" 2>/dev/null } +# reapply bashrc +reb() { + source ~/.bashrc +} + rl() { readlink -f "$@" } diff --git a/brc2 b/brc2 index 773b3bb..6f28a8b 100644 --- a/brc2 +++ b/brc2 @@ -338,10 +338,20 @@ bindpush() { m sl $h <<'EOF' source ~/.bashrc m dnsup +EOF + done +} +bindpushb8() { + lipush + for h in li bk; do + m sl $h <<'EOF' +source ~/.bashrc +m dnsup m dnsb8 EOF done } + dnsup() { conflink m ser reload bind9 @@ -502,20 +512,20 @@ dup() { ran_d=false system-status _ case $PS1 in - *\]D\ *) + *[\ \]]D\ *) pushd / /b/ds/distro-begin || return $? /b/ds/distro-end || return $? popd ran_d=true ;;& - *\]DB\ *) + *[\ \]]DB\ *) pushd / /b/ds/distro-begin || return $? popd ran_d=true ;; - *\]DE\ *) + *[\ \]]DE\ *) pushd / /b/ds/distro-end || return $? popd @@ -883,7 +893,19 @@ lom() { # mu personality. for original, just run mp. for 2, run mp 2. # this is partly duplicated in mail-setup mp() { - killall mu ||: + local dead=false + for s in {1..5}; do + if ! killall mu; then + dead=true + break + fi + sleep 1 + done + if ! $dead; then + echo error: mu not dead + m psg mu + return 1 + fi suf=$1 set -- /m/mucache ~/.cache/mu /m/.mu ~/.config/mu while (($#)); do @@ -1254,11 +1276,6 @@ tu() { $s /a/exe/teeu "$@" } -# a1 = awk {print $1} -for field in {1..20}; do - eval a$field"() { awk '{print \$$field}'; }" -done - enn() { local ecmd pid @@ -1267,7 +1284,7 @@ enn() { s $ecmd "$@" return fi - pid=$(pgrep -f "/usr/sbin/exim4 -bd -q30m -C /etc/exim4/my.conf"|a1) + pid=$(pgrep -f "/usr/sbin/exim4 -bd -q30m -C /etc/exim4/my.conf"|h1) m s nsenter -t $pid -n -m $ecmd "$@" } @@ -1288,6 +1305,10 @@ vpncmd() { vpnf() { vpncmd sudo --preserve-env=PATH -E -u iank abrowser -no-remote -P vpn &r } +vpn2f() { + vpncmd sudo --preserve-env=PATH -E -u iank abrowser -no-remote -P vpn2 &r +} + vpni() { vpncmd sudo --preserve-env=PATH -E -u iank "$@" } diff --git a/filesystem/etc/systemd/system/openvpn-client-tr@.service b/filesystem/etc/systemd/system/openvpn-client-tr@.service index 5ba2c91..fdd71b1 100644 --- a/filesystem/etc/systemd/system/openvpn-client-tr@.service +++ b/filesystem/etc/systemd/system/openvpn-client-tr@.service @@ -1,6 +1,7 @@ [Unit] Description=OpenVPN tunnel for %I -After=syslog.target network-online.target +After=syslog.target network-online.target vpn-static-ip@%i.service +Requires=vpn-static-ip@%i.service Wants=network-online.target Documentation=man:openvpn(8) Documentation=https://community.openvpn.net/openvpn/wiki/Openvpn24ManPage diff --git a/filesystem/etc/systemd/system/vpn-static-ip@.service b/filesystem/etc/systemd/system/vpn-static-ip@.service new file mode 100644 index 0000000..7af3793 --- /dev/null +++ b/filesystem/etc/systemd/system/vpn-static-ip@.service @@ -0,0 +1,7 @@ +[Unit] +Description=vpn-static-ip + + +[Service] +Type=oneshot +ExecStart=/b/ds/vpn-static-ip /etc/openvpn/client/%i.conf diff --git a/mail-setup b/mail-setup index 2437ea6..cb9f677 100755 --- a/mail-setup +++ b/mail-setup @@ -21,7 +21,10 @@ # todo: mailtest-check failure on remote hosts is not going to alert me. # sort that out. - +# todo: test that mail is dkim signing in our mail test. +# todo: send sending from all domains +# todo: test mail failure as well as success. +# todo: we should monitor spamhaus etc to make sure we dont get blacklisted. # background: I want to run exim in a network namespace so it can send # and receive through a vpn. This is needed so it can do ipv6, because diff --git a/vpn-static-ip b/vpn-static-ip new file mode 100755 index 0000000..ae92d3c --- /dev/null +++ b/vpn-static-ip @@ -0,0 +1,26 @@ +#!/bin/bash +if ! test "$BASH_VERSION"; then echo "error: shell is not bash" >&2; exit 1; fi +shopt -s inherit_errexit 2>/dev/null ||: # ignore fail in bash < 4.4 +set -eE -o pipefail +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?. PIPESTATUS: ${PIPESTATUS[*]}" >&2' ERR + +[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@" + +conf=$1 + +# We block dns lookups from going outside the vpn network namespace, +# there might be some other workaround, but just resolving to static ips +# is a simple fix. + +sed --follow-symlinks -i '/^ *remote /d' $conf +ret=1 +while read -r host port; do + while read -r ip; do + printf "remote %s %s\n" "$ip" "$port" >>$conf + ret=0 + done < <(dig +short $host ||:) +done < <(sed -rn 's/^ *# *remote //p' $conf) +if ((ret)); then + echo "vpn-static-ip: error: failed to set any ips" >&2 + exit 1 +fi