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
|
|
|
|
elif [ -z "$TURN_SECRET" ]; then
|
|
|
|
echo "You need to provide the TURN_SECRET."
|
|
|
|
exit 1
|
|
|
|
elif [ -z "$JANUS_API_KEY" ]; then
|
|
|
|
echo "You need to provide the JANUS_API_KEY."
|
|
|
|
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
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Turn
|
|
|
|
cat << TURN_CONF > "/etc/turnserver.conf"
|
2022-06-07 06:43:48 +08:00
|
|
|
listening-port=$TALK_PORT
|
2021-11-30 18:20:42 +08:00
|
|
|
fingerprint
|
2022-03-18 20:09:08 +08:00
|
|
|
lt-cred-mech
|
2021-11-30 18:20:42 +08:00
|
|
|
use-auth-secret
|
|
|
|
static-auth-secret=$TURN_SECRET
|
|
|
|
realm=$NC_DOMAIN
|
2022-09-07 17:17:53 +08:00
|
|
|
total-quota=0
|
2021-11-30 18:20:42 +08:00
|
|
|
bps-capacity=0
|
|
|
|
stale-nonce
|
|
|
|
no-multicast-peers
|
|
|
|
simple-log
|
|
|
|
pidfile=/var/tmp/turnserver.pid
|
|
|
|
TURN_CONF
|
|
|
|
|
|
|
|
# Janus
|
2022-03-18 20:09:08 +08:00
|
|
|
set -x
|
2022-03-18 23:41:31 +08:00
|
|
|
sed -i "s|#turn_rest_api_key.*|turn_rest_api_key = \"$JANUS_API_KEY\"|" /etc/janus/janus.jcfg
|
2022-03-18 20:09:08 +08:00
|
|
|
sed -i "s|#full_trickle.*|full_trickle = true|g" /etc/janus/janus.jcfg
|
2022-03-18 23:41:31 +08:00
|
|
|
sed -i 's|#stun_server.*|stun_server = "127.0.0.1"|g' /etc/janus/janus.jcfg
|
2022-06-07 06:43:48 +08:00
|
|
|
sed -i "s|#stun_port.*|stun_port = $TALK_PORT|g" /etc/janus/janus.jcfg
|
|
|
|
sed -i "s|#turn_port.*|turn_port = $TALK_PORT|g" /etc/janus/janus.jcfg
|
2022-08-14 21:43:14 +08:00
|
|
|
sed -i 's|#turn_server.*|turn_server = "127.0.0.1"|g' /etc/janus/janus.jcfg
|
2022-03-18 23:41:31 +08:00
|
|
|
sed -i 's|#turn_type .*|turn_type = "udp"|g' /etc/janus/janus.jcfg
|
|
|
|
sed -i 's|#ice_ignore_list .*|ice_ignore_list = "udp"|g' /etc/janus/janus.jcfg
|
|
|
|
sed -i 's|#interface.*|interface = "lo"|g' /etc/janus/janus.transport.websockets.jcfg
|
|
|
|
sed -i 's|#ws_interface.*|ws_interface = "lo"|g' /etc/janus/janus.transport.websockets.jcfg
|
2022-09-27 17:28:50 +08:00
|
|
|
sed -i 's|certfile =|#certfile =|g' /etc/janus/janus.transport.mqtt.jcfg
|
|
|
|
sed -i 's|keyfile =|#keyfile =|g' /etc/janus/janus.transport.mqtt.jcfg
|
2022-03-18 20:09:08 +08:00
|
|
|
set +x
|
2021-11-30 18:20:42 +08:00
|
|
|
|
|
|
|
# Signling
|
|
|
|
cat << SIGNALING_CONF > "/etc/signaling/server.conf"
|
|
|
|
[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]
|
|
|
|
internalsecret = $(openssl rand -hex 16)
|
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
|
2022-03-18 20:09:08 +08:00
|
|
|
|
2021-11-30 18:20:42 +08:00
|
|
|
[turn]
|
|
|
|
apikey = ${JANUS_API_KEY}
|
|
|
|
secret = ${TURN_SECRET}
|
2022-06-07 06:43:48 +08:00
|
|
|
servers = turn:$NC_DOMAIN:$TALK_PORT?transport=tcp,turn:$NC_DOMAIN:$TALK_PORT?transport=udp
|
2021-11-30 18:20:42 +08:00
|
|
|
SIGNALING_CONF
|
|
|
|
|
|
|
|
exec "$@"
|