From 694d7d1b84958961357d04700737373cc7c66d7c Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sat, 1 Aug 2020 14:23:42 +0200 Subject: [PATCH] Add script to add peers to Wireguard config The script is to be run on the VPN host. It extracts the necessary data from the configuration file and asks for some data about the new peer. It then outputs the peer configuration file and updates the host configuration accordingly. --- VPS/WireguardAddPeer.sh | 117 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100755 VPS/WireguardAddPeer.sh diff --git a/VPS/WireguardAddPeer.sh b/VPS/WireguardAddPeer.sh new file mode 100755 index 0000000..a307146 --- /dev/null +++ b/VPS/WireguardAddPeer.sh @@ -0,0 +1,117 @@ +#!/bin/bash + +# Usage : parseConf $fileContent $propertyName +# Retrieves the value of propertyName from fileContent +# And echoes it back +function parseConf() { + result=$(echo "$1" | grep $2 | cut -f2 -d'=') + echo $result +} + + +if [ $EUID -ne 0 ]; then + echo "This script can only be run as root" + exit -1 +fi + +if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then + cat <> $confFile + +[Peer] +PublicKey = $peerPubKey +AllowedIPs = $peerAddress/32 + +EOF + +cat <