1
0
Fork 0
This commit is contained in:
Arthur K. 2025-06-16 11:04:16 +03:00
parent ce19d6a62c
commit 624ab42f73
Signed by: wzray
GPG key ID: B97F30FDC4636357
26 changed files with 493 additions and 163 deletions

View file

@ -6,6 +6,19 @@ send_cmd() {
cat < $PIPE
}
send_router_cmd() {
touch "${HOME}/.local/state/.vpn_loading"
pkill -36 dwmblocks
ssh router vpn "$1" laptop 2>/dev/null
rm "${HOME}/.local/state/.vpn_loading"
}
DEFAULT_LINK="$(resolvectl status | grep 'Default Route: yes' -B10 | grep 'Link' | tail -1 | grep -Eo '\(.*\)' | tr -d '()')"
if resolvectl domain "$DEFAULT_LINK" | grep -q 'wzray.com'; then
IS_LOCAL=1
fi
IFNAME="rix"
while [ "$#" -gt 0 ]; do
@ -25,17 +38,26 @@ fi
UP_NAME="$(send_cmd status)"
if [ -n "${UP_NAME}" ]; then
if [ "${UP_NAME}" != "${IFNAME}" ]; then
if [ -n "$IS_LOCAL" ]; then
if [ -n "$UP_NAME" ]; then
send_cmd down
send_cmd up "$IFNAME"
else
send_cmd down
send_router_cmd toggle
fi
else
send_cmd up "$IFNAME"
if [ -n "${UP_NAME}" ]; then
if [ "${UP_NAME}" != "${IFNAME}" ]; then
send_cmd down
send_cmd up "$IFNAME"
else
send_cmd down
fi
else
send_cmd up "$IFNAME"
fi
fi
pkill -36 dwmblocks
# vim: ft=bash