+add script to fix missing peers

Signed-off-by: Nico Schottelius <nico@nico-notebook.schottelius.org>
This commit is contained in:
Nico Schottelius 2020-11-04 11:59:17 +01:00
parent c532e62ffe
commit 84944f2584

View file

@ -0,0 +1,25 @@
#!/bin/sh
vpndir=/home/nico/vcs/ungleich-dot-cdist/type/__ungleich_wireguard/files
for i in $(ls -1 viirb*public_key); do
viirb=${i%.public_key};
num=${viirb#viirb};
hex=$(printf "%0.2x" $num);
pubkey=$(cat $i);
network="2a0a:e5c1:3${hex}::/48";
peerfilename=vpn-2a0ae5c1300.ungleich.ch.peer${hex}
peerfile=${vpndir}/${peerfilename}
if [ ! -f "${peerfile}" ]; then
echo "VIIRB $num / peer $hex missing, recreating"
cat <<EOF > "${peerfile}"
# viirb${num}, $(date +%F)
[Peer]
PublicKey = $pubkey
AllowedIPs = ${network}
EOF
fi
done