2021-11-30 18:20:42 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Variables
|
|
|
|
if [ -z "$NC_DOMAIN" ]; then
|
|
|
|
echo "You need to provide the NC_DOMAIN."
|
|
|
|
exit 1
|
2023-06-24 23:54:12 +08:00
|
|
|
elif [ -z "$TALK_PORT" ]; then
|
|
|
|
echo "You need to provide the TALK_PORT."
|
|
|
|
exit 1
|
2021-11-30 18:20:42 +08:00
|
|
|
elif [ -z "$TURN_SECRET" ]; then
|
|
|
|
echo "You need to provide the TURN_SECRET."
|
|
|
|
exit 1
|
|
|
|
elif [ -z "$SIGNALING_SECRET" ]; then
|
2022-08-24 03:45:48 +08:00
|
|
|
echo "You need to provide the SIGNALING_SECRET."
|
2021-11-30 18:20:42 +08:00
|
|
|
exit 1
|
2023-06-06 15:22:33 +08:00
|
|
|
elif [ -z "$INTERNAL_SECRET" ]; then
|
|
|
|
echo "You need to provide the INTERNAL_SECRET."
|
|
|
|
exit 1
|
2021-11-30 18:20:42 +08:00
|
|
|
fi
|
|
|
|
|
2022-10-13 20:04:59 +08:00
|
|
|
set -x
|
2023-08-07 19:15:41 +08:00
|
|
|
IPv4_ADDRESS_TALK="$(dig nextcloud-aio-talk IN A +short | grep '^[0-9.]\+$' | sort | head -n1)"
|
|
|
|
IPv6_ADDRESS_TALK="$(dig nextcloud-aio-talk AAAA +short | grep '^[0-9a-f:]\+$' | sort | head -n1)"
|
2022-10-13 20:04:59 +08:00
|
|
|
set +x
|
|
|
|
|
|
|
|
# Turn
|
2023-08-10 03:51:10 +08:00
|
|
|
cat << TURN_CONF > "/conf/eturnal.yml"
|
2023-06-24 23:54:12 +08:00
|
|
|
eturnal:
|
|
|
|
listen:
|
|
|
|
- ip: "::"
|
|
|
|
port: $TALK_PORT
|
|
|
|
transport: udp
|
|
|
|
- ip: "::"
|
|
|
|
port: $TALK_PORT
|
|
|
|
transport: tcp
|
|
|
|
log_dir: stdout
|
|
|
|
log_level: warning
|
|
|
|
secret: "$TURN_SECRET"
|
2023-08-22 00:51:31 +08:00
|
|
|
relay_ipv4_addr: "$IPv4_ADDRESS_TALK"
|
2023-08-22 05:25:57 +08:00
|
|
|
relay_ipv6_addr: "$IPv6_ADDRESS_TALK"
|
2023-09-28 02:26:51 +08:00
|
|
|
blacklist_peers:
|
2023-06-24 23:54:12 +08:00
|
|
|
- recommended
|
2023-09-28 03:28:44 +08:00
|
|
|
whitelist_peers:
|
2023-06-24 23:54:12 +08:00
|
|
|
- 127.0.0.1
|
|
|
|
- ::1
|
|
|
|
- "$IPv4_ADDRESS_TALK"
|
|
|
|
- "$IPv6_ADDRESS_TALK"
|
2021-11-30 18:20:42 +08:00
|
|
|
TURN_CONF
|
|
|
|
|
2023-06-24 23:54:12 +08:00
|
|
|
# Remove empty lines so that the config is not invalid
|
2023-08-10 15:16:43 +08:00
|
|
|
sed -i '/""/d' /conf/eturnal.yml
|
2023-06-24 23:54:12 +08:00
|
|
|
|
2021-11-30 18:20:42 +08:00
|
|
|
# Signling
|
2023-06-27 00:11:00 +08:00
|
|
|
cat << SIGNALING_CONF > "/conf/signaling.conf"
|
2021-11-30 18:20:42 +08:00
|
|
|
[http]
|
|
|
|
listen = 0.0.0.0:8081
|
2022-03-18 20:09:08 +08:00
|
|
|
|
2021-11-30 18:20:42 +08:00
|
|
|
[app]
|
|
|
|
debug = false
|
2022-03-18 20:09:08 +08:00
|
|
|
|
2021-11-30 18:20:42 +08:00
|
|
|
[sessions]
|
|
|
|
hashkey = $(openssl rand -hex 16)
|
|
|
|
blockkey = $(openssl rand -hex 16)
|
2022-03-18 20:09:08 +08:00
|
|
|
|
2021-11-30 18:20:42 +08:00
|
|
|
[clients]
|
2023-06-06 15:22:33 +08:00
|
|
|
internalsecret = ${INTERNAL_SECRET}
|
2022-03-18 20:09:08 +08:00
|
|
|
|
2021-11-30 18:20:42 +08:00
|
|
|
[backend]
|
2022-03-18 20:09:08 +08:00
|
|
|
backends = backend-1
|
2021-11-30 18:20:42 +08:00
|
|
|
allowall = false
|
|
|
|
timeout = 10
|
|
|
|
connectionsperhost = 8
|
2022-03-18 20:09:08 +08:00
|
|
|
|
|
|
|
[backend-1]
|
|
|
|
url = https://${NC_DOMAIN}
|
|
|
|
secret = ${SIGNALING_SECRET}
|
|
|
|
|
2021-11-30 18:20:42 +08:00
|
|
|
[nats]
|
|
|
|
url = nats://127.0.0.1:4222
|
2022-03-18 20:09:08 +08:00
|
|
|
|
2021-11-30 18:20:42 +08:00
|
|
|
[mcu]
|
|
|
|
type = janus
|
|
|
|
url = ws://127.0.0.1:8188
|
|
|
|
SIGNALING_CONF
|
|
|
|
|
|
|
|
exec "$@"
|