Skip to content

Instantly share code, notes, and snippets.

@isapir
Created June 6, 2025 19:51
Show Gist options
  • Save isapir/55f1b6d138f3d42161dd95230b0bdd6a to your computer and use it in GitHub Desktop.
Save isapir/55f1b6d138f3d42161dd95230b0bdd6a to your computer and use it in GitHub Desktop.
#!/bin/bash
## https://github.com/OpenVPN/openvpn3-linux
CONFIG=~/.ssh/configuration-file.ovpn
COMMAND=${1:-list}
if [ $COMMAND = "list" ] ; then
openvpn3 sessions-list
exit 0
fi
if [[ $COMMAND = "disconnect" || $COMMAND = "connect" || $COMMAND = "reconnect" ]] ; then
openvpn3 sessions-list | grep Path | awk -v OFS='\t' '{print $2}' | while read -r path; do
echo "Disconnecting session $path"
openvpn3 session-manage --disconnect --path "$path"
done
fi
if [[ $COMMAND = "connect" || $COMMAND = "reconnect" ]] ; then
openvpn3 session-start --config $CONFIG
exit 0
fi
if [[ $COMMAND = "restart" || $COMMAND = "pause" || $COMMAND = "resume" ]] ; then
openvpn3 session-manage --config $CONFIG --${COMMAND}
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment