docker-wireguard/root/app/show-peer
2020-04-08 10:46:14 -04:00

18 lines
466 B
Plaintext
Executable File

#!/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