Skip to content

Instantly share code, notes, and snippets.

@johndevs
Created August 27, 2021 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johndevs/597b4fde73159ee416a8869278b7fb60 to your computer and use it in GitHub Desktop.
Save johndevs/597b4fde73159ee416a8869278b7fb60 to your computer and use it in GitHub Desktop.
Gnome extension script for toggling OpenVPN 3 tunnel status
#!/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
@johndevs
Copy link
Author

Popup

@johndevs
Copy link
Author

Settings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment