35 lines
950 B
Bash
Executable File
35 lines
950 B
Bash
Executable File
#!/bin/sh
|
|
|
|
set -eu
|
|
|
|
SECRET_NAME=turn-shared-secret
|
|
|
|
if [ -z "${TURN_SHARED_SECRET:-}" ]; then
|
|
echo "Set TURN_SHARED_SECRET to the existing 64-character shared secret." >&2
|
|
exit 1
|
|
fi
|
|
|
|
case "$TURN_SHARED_SECRET" in
|
|
*[!0-9a-f]*|'')
|
|
echo "TURN_SHARED_SECRET must contain lowercase hexadecimal characters only." >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
if [ "${#TURN_SHARED_SECRET}" -ne 64 ]; then
|
|
echo "TURN_SHARED_SECRET must be exactly 64 characters." >&2
|
|
exit 1
|
|
fi
|
|
|
|
for namespace in coturn matrix; do
|
|
kubectl create namespace "$namespace" --dry-run=client --output=yaml \
|
|
| kubectl apply --filename=-
|
|
kubectl create secret generic "$SECRET_NAME" \
|
|
--namespace "$namespace" \
|
|
--from-literal="shared-secret=$TURN_SHARED_SECRET" \
|
|
--dry-run=client --output=yaml \
|
|
| kubectl apply --filename=-
|
|
done
|
|
|
|
echo "Stored the existing TURN shared secret in coturn/$SECRET_NAME and matrix/$SECRET_NAME."
|