From 6667fdf0d5983f48ea59662e79193128ec3d2027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Dudr?= Date: Fri, 18 Oct 2024 08:31:31 +0200 Subject: [PATCH] metvpn --- bin/executable_metvpn.tmpl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 bin/executable_metvpn.tmpl diff --git a/bin/executable_metvpn.tmpl b/bin/executable_metvpn.tmpl new file mode 100644 index 0000000..e4e489f --- /dev/null +++ b/bin/executable_metvpn.tmpl @@ -0,0 +1,19 @@ +#!{{ .chezmoi.pathSeparator }}bin{{ .chezmoi.pathSeparator }}zsh + +if (( UID != 0 )) +then + exec sudo "$(realpath "$0")" "$@" +fi + +openvpn --config <(sudo -u {{ .chezmoi.user }} {{ .chezmoi.config.gopass.command }} show metrans{{ .chezmoi.pathSeparator }}vpn tcp.ovpn) --askpass <(sudo -u {{ .chezmoi.user }} {{ .chezmoi.config.gopass.command }} show metrans{{ .chezmoi.pathSeparator }}vpn) & +ovpn=$? +set -v +until ip l show dev metrans &>{{ .chezmoi.pathSeparator }}dev{{ .chezmoi.pathSeparator }}null +do + sleep 0.5 +done +resolvectl dns metrans 192.168.1.61 192.168.1.62 +resolvectl domain metrans '~metrans.local' '~corp.metrans.cz' + +wait +kill "$ovpn"