cdist-contrib/type/__wireguard_peer/files/wg-peer.sh

31 lines
449 B
Bash
Executable File

#!/bin/sh
# We expect the pre-shared key, if it exists, as an argument because we do not
# consider the environment to be secure.
cat << EOF
[Peer]
PublicKey = ${PKEY:?}
EOF
if [ -n "$1" ];
then
echo "PresharedKey = ${1:?}"
fi
for ip in $ALLOWED_IPS;
do
echo "AllowedIPs = ${ip:?}"
done
if [ -n "$ENDPOINT" ];
then
echo "Endpoint = ${ENDPOINT:?}"
fi
if [ -n "$PERSISTENT_KA" ];
then
echo "PersistentKeepalive = ${PERSISTENT_KA:?}"
fi
echo