aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYaroslav <contact@yaroslavps.com>2020-02-03 13:14:07 +0300
committerYaroslav <contact@yaroslavps.com>2020-02-03 13:14:07 +0300
commit278311cc16be7b3857634ec8c76b28442d4f31e9 (patch)
tree8469733b80b9439c788c994565d01b05fdef25a6
parente5532752993f463524e0c89d5e82b5a84a77759b (diff)
downloadswayrice-278311cc16be7b3857634ec8c76b28442d4f31e9.tar.gz
swayrice-278311cc16be7b3857634ec8c76b28442d4f31e9.zip
vpn script improvements
-rwxr-xr-xdotfiles/.local/bin/swaysession2
-rwxr-xr-xdotfiles/.local/bin/togglevpn8
-rw-r--r--system/sudoers1
3 files changed, 10 insertions, 1 deletions
diff --git a/dotfiles/.local/bin/swaysession b/dotfiles/.local/bin/swaysession
index 0507368..c4fa4db 100755
--- a/dotfiles/.local/bin/swaysession
+++ b/dotfiles/.local/bin/swaysession
@@ -21,9 +21,11 @@ case "$1" in
lock-color & sleep 1 && $logind hibernate
;;
reboot)
+ rm -f ~/.cache/openvpnpid
$logind reboot
;;
poweroff)
+ rm -f ~/.cache/openvpnpid
$logind poweroff
;;
*)
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
diff --git a/system/sudoers b/system/sudoers
index c7efcf6..9740719 100644
--- a/system/sudoers
+++ b/system/sudoers
@@ -87,6 +87,7 @@ root ALL=(ALL) ALL
## Run some commands without a password
%wheel ALL=(ALL) NOPASSWD: /usr/bin/pacman -Sy
%wheel ALL=(ALL) NOPASSWD: /usr/bin/openvpn
+%wheel ALL=(ALL) NOPASSWD: /usr/bin/killall -SIGINT openvpn
## Uncomment to allow members of group sudo to execute any command
# %sudo ALL=(ALL) ALL