docker-wireguard/root/app/show-peer

18 lines
466 B
Plaintext
Raw Normal View History

#!/usr/bin/with-contenv bash
if [ ! $# -gt 0 ]; then
echo "You need to specify which peers to show"
exit 0
fi
2020-04-08 14:46:14 +00:00
INTERNAL_SUBNET=${INTERNAL_SUBNET:-10.13.13.0}
INTERFACE=$(echo "$INTERNAL_SUBNET" | awk 'BEGIN{FS=OFS="."} NF--')
for i in "$@"; do
2020-04-08 14:46:14 +00:00
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