37 lines
779 B
Bash
Executable file
37 lines
779 B
Bash
Executable file
#!/bin/bash
|
|
|
|
[ -f "${HOME}/.local/state/.vpn_loading" ] && {
|
|
echo 'Loading...'
|
|
exit 0
|
|
}
|
|
|
|
send_cmd() {
|
|
PIPE="/var/run/vpnd.sock"
|
|
[ -p $PIPE ] && echo "$@" > $PIPE && cat < $PIPE
|
|
}
|
|
|
|
router_status() {
|
|
ssh -i "$HOME"/.ssh/id_watcher router vpn status laptop 2>/dev/null
|
|
}
|
|
|
|
case "$(ip link | grep 'awg_' | cut -d ' ' -f2 | tr -d ':' | sed 's,awg_,,')" in
|
|
"int") IFNAME=" Saint-Petersburg";;
|
|
"ext") IFNAME=" Riga";;
|
|
esac
|
|
|
|
[ -n "$IFNAME" ] && {
|
|
echo "$IFNAME"
|
|
exit 0
|
|
}
|
|
|
|
DEFAULT_LINK="$(
|
|
resolvectl status | \
|
|
grep 'Default Route: yes' -B10 | \
|
|
grep 'Link' | \
|
|
tail -1 | \
|
|
grep -Eo '\(.*\)' | \
|
|
tr -d '()'
|
|
)"
|
|
|
|
resolvectl domain "$DEFAULT_LINK" | grep -q 'wzray.com' && \
|
|
[ "$(router_status)" = '1' ] && echo ""
|