Created
August 27, 2021 12:47
-
-
Save johndevs/597b4fde73159ee416a8869278b7fb60 to your computer and use it in GitHub Desktop.
Gnome extension script for toggling OpenVPN 3 tunnel status
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Provides a utility script for https://gitlab.com/XavierBerger/custom-vpn-toggler to toggle a OpenVPN 3 tunnel | |
# | |
# Steps to install: | |
# 1. Install OpenVPN 3 by following https://www.cactusvpn.com/tutorials/how-to-set-up-openvpn-3-linux/ | |
# 1. Download this script and save it somewhere | |
# 2. Install the Gnome extension https://extensions.gnome.org/extension/4061/custom-vpn-toggler/ | |
# 3. Set the script path to point to this script | |
# | |
# Path to your .ovpn file | |
CONFIG_PATH=~<PATH TO .OVPN FILE> | |
if [ "$1" == "start" ]; then | |
openvpn3 session-start --config $CONFIG_PATH | |
notify-send "VPN connected." | |
elif [ "$1" == "stop" ]; then | |
openvpn3 session-manage --config $CONFIG_PATH --disconnect | |
notify-send "VPN disconnected." | |
elif [ "$1" == "ip" ]; then | |
DEVICE=$(openvpn3 sessions-list | grep Device | cut -d':' -f3 | xargs) | |
if [ "$DEVICE" != "" ]; then | |
IP=$(ifconfig $DEVICE | grep netmask | cut -d' ' -f10) | |
echo "$IP" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment