39 lines
742 B
Bash
Executable File
39 lines
742 B
Bash
Executable File
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
. .env
|
|
|
|
wgif="$1"
|
|
net="10.100.$JC_ID"
|
|
privfile="$DATA_DIR/wgif.wgprivatekey"
|
|
|
|
# Create key if doesnt exists
|
|
if [ ! -e "$privfile" ] ; then
|
|
wg genkey > "$privfile"
|
|
fi
|
|
|
|
# Print wg-quick config
|
|
echo "
|
|
[Interface]
|
|
PrivateKey = $(cat "$privfile")
|
|
ListenPort = $((51800+$JC_ID))
|
|
Address = $net.254/32
|
|
|
|
[Peer] # Adrian
|
|
PublicKey = p4/km7Rtl5IgYGw8OPIyE0/f8UoRbcMJwkVJ0Zyv/C8=
|
|
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
|
|
"
|