privateone commited on
Commit
41bb6cc
·
verified ·
1 Parent(s): ca89887

Update custom-entrypoint.sh

Browse files
Files changed (1) hide show
  1. custom-entrypoint.sh +16 -1
custom-entrypoint.sh CHANGED
@@ -7,7 +7,22 @@ set -e
7
  echo "Starting ngrok in background..."
8
  ngrok start turn_tls --config /ngrok2/ngrok.yml --log=stdout --log-level=debug &
9
  NGROK_PID=$!
 
 
 
 
 
 
 
10
 
 
 
 
 
 
 
 
 
11
 
12
  sleep 1
13
 
@@ -21,7 +36,7 @@ exec turnserver \
21
  # --cert=/etc/turn/certs/turn_server_cert.pem \
22
  # --pkey=/etc/turn/certs/turn_server_pkey.pem \
23
  --user=myuser:mypassword \
24
- # --realm=privateone-coturn.hf.space \
25
  --log-file=stdout \
26
  --simple-log \
27
  --no-cli &
 
7
  echo "Starting ngrok in background..."
8
  ngrok start turn_tls --config /ngrok2/ngrok.yml --log=stdout --log-level=debug &
9
  NGROK_PID=$!
10
+ echo "Waiting for ngrok tunnel..."
11
+ for i in $(seq 1 20); do
12
+ if curl -s --max-time 1 http://127.0.0.1:4040/api/tunnels >/dev/null 2>&1; then
13
+ break
14
+ fi
15
+ sleep 1
16
+ done
17
 
18
+ # Fetch public TCP address
19
+ PUBLIC_TCP=$(curl -s http://127.0.0.1:4040/api/tunnels \
20
+ | python3 -c "import sys, json; t=json.load(sys.stdin); print(t['tunnels'][0]['public_url'].replace('tcp://',''))")
21
+
22
+ echo "Ngrok public TCP address: $PUBLIC_TCP"
23
+
24
+ # Export it as environment variable if needed
25
+ export TURN_PUBLIC_ADDR="$PUBLIC_TCP"
26
 
27
  sleep 1
28
 
 
36
  # --cert=/etc/turn/certs/turn_server_cert.pem \
37
  # --pkey=/etc/turn/certs/turn_server_pkey.pem \
38
  --user=myuser:mypassword \
39
+ --realm="$PUBLIC_TCP" \
40
  --log-file=stdout \
41
  --simple-log \
42
  --no-cli &