From 2b29e03451b218ce2f4c91fdb3d33a22d4ac1400 Mon Sep 17 00:00:00 2001 From: Tait Hoyem <44244401+TTWNO@users.noreply.github.com> Date: Fri, 3 Apr 2020 21:35:26 +0000 Subject: [PATCH] Add swg: Switch WireGuard. Same as sw-vpn, but for wg-quick interfaces --- swg/swg | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 swg/swg diff --git a/swg/swg b/swg/swg new file mode 100755 index 0000000..b509157 --- /dev/null +++ b/swg/swg @@ -0,0 +1,20 @@ +#!/bin/sh +curr_vpn="$(systemctl list-units | tr -d '*' | awk '/wg-quick/ {print $1}')" + +if [ "" = "$curr_vpn" ]; then + echo "No running VPN. Will start one." +else + echo "Current VPN: $curr_vpn" + echo "systemctl stop $curr_vpn" + systemctl stop $curr_vpn + echo "Stopped $curr_vpn" +fi + +if [ "" = "$1" ]; then + echo "No VPN specified to start. Pass as first argument." +else + echo "Starting wg-quick@$1" + echo "systemctl start wg-quick@$1" + systemctl start "wg-quick@$1" + echo "Started wg-quick@$1" +fi