diff options
author | Yaroslav <contact@yaroslavps.com> | 2020-02-03 13:14:07 +0300 |
---|---|---|
committer | Yaroslav <contact@yaroslavps.com> | 2020-02-03 13:14:07 +0300 |
commit | 278311cc16be7b3857634ec8c76b28442d4f31e9 (patch) | |
tree | 8469733b80b9439c788c994565d01b05fdef25a6 /dotfiles/.local/bin/togglevpn | |
parent | e5532752993f463524e0c89d5e82b5a84a77759b (diff) | |
download | swayrice-278311cc16be7b3857634ec8c76b28442d4f31e9.tar.gz swayrice-278311cc16be7b3857634ec8c76b28442d4f31e9.zip |
vpn script improvements
Diffstat (limited to 'dotfiles/.local/bin/togglevpn')
-rwxr-xr-x | dotfiles/.local/bin/togglevpn | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/dotfiles/.local/bin/togglevpn b/dotfiles/.local/bin/togglevpn index f1a6bdb..88add47 100755 --- a/dotfiles/.local/bin/togglevpn +++ b/dotfiles/.local/bin/togglevpn @@ -1,10 +1,16 @@ #!/bin/sh if [ -f "$HOME/.cache/openvpnpid" ]; then + rm ~/.cache/openvpnpid sudo killall -SIGINT openvpn exit fi +if [ ! -f "$HOME/.config/ovpn/conf.ovpn" ]; then + notify-send "🔐 OpenVPN" "Can't start VPN. Configuration file is missing" + exit +fi + sudo openvpn "$HOME/.config/ovpn/conf.ovpn" & PID=$! notify-send "🔐 OpenVPN" "VPN is being initialized" @@ -12,5 +18,5 @@ echo $PID > ~/.cache/openvpnpid killall -40 waybar wait $PID notify-send "🔐 OpenVPN" "VPN service has stopped with exit code $?" -rm ~/.cache/openvpnpid +rm -f ~/.cache/openvpnpid killall -40 waybar |