+add script to fix missing peers
Signed-off-by: Nico Schottelius <nico@nico-notebook.schottelius.org>
This commit is contained in:
parent
c532e62ffe
commit
84944f2584
1 changed files with 25 additions and 0 deletions
25
one-time-scripts/fix-vpn-peers.sh
Normal file
25
one-time-scripts/fix-vpn-peers.sh
Normal 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
|
Loading…
Reference in a new issue