You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
docker-wireguard/root/app/show-peer

18 lines
466 B
Plaintext

#!/usr/bin/with-contenv bash
if [ ! $# -gt 0 ]; then
echo "You need to specify which peers to show"
exit 0
fi
INTERNAL_SUBNET=${INTERNAL_SUBNET:-10.13.13.0}
INTERFACE=$(echo "$INTERNAL_SUBNET" | awk 'BEGIN{FS=OFS="."} NF--')
for i in "$@"; do
if grep -q "AllowedIPs = ${INTERFACE}.$(( $i + 1 ))/32" /config/wg0.conf; then
echo "PEER $i QR code:"
qrencode -t ansiutf8 < /config/peer${i}/peer${i}.conf
else
echo "PEER $i is not active"
fi
done