41 lines
779 B
Bash
Executable File
41 lines
779 B
Bash
Executable File
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
. .env
|
|
|
|
wgif="$1"
|
|
net="10.100.1"
|
|
privfile="$DATA_DIR/wgif.wgprivatekey"
|
|
|
|
# Create key if doesnt exists
|
|
if [ ! -e "$privfile" ] ; then
|
|
touch "$privfile"
|
|
chmod 700 "$privfile"
|
|
wg genkey > "$privfile"
|
|
fi
|
|
|
|
# Print wg-quick config
|
|
echo "
|
|
[Interface]
|
|
PrivateKey = $(cat "$privfile")
|
|
ListenPort = $((51800+$JC_ID))
|
|
Address = $net.254/32
|
|
|
|
[Peer] # Adrian
|
|
PublicKey = 14yKNmSfD2lrWU+d/RJBPNvh9pZ/nW4bK27F9nTgvk0=
|
|
AllowedIPs = $net.253/32
|
|
|
|
[Peer] # Nico
|
|
PublicKey = jsXBs8tZn1sWT73xx3DWEdGAWv6SjfQ2TAxX+8pL6mU=
|
|
AllowedIPs = $net.252/32
|
|
|
|
[Peer] # Passerelle
|
|
PublicKey = ZTKOW5DE8jPO8oMh5hAw/c1MQSlUaVxInMPz9Zdwzwo=
|
|
AllowedIPs = $net.13/32,192.168.100.0/24
|
|
|
|
[Peer] # Debug
|
|
PublicKey = K9IpoUbjyN+42y0YG3OIwAPRBZcd92GnKfbYEj3RZ18=
|
|
AllowedIPs = $net.21/32
|
|
"
|