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 <