OverviewFilesCommitsIssuesDocsReleasesPeers

wirecore / scripts / update-turn-config.sh

54 lines · bash ref:
#!/bin/bash
#
# Update Wirecore app.js with TURN server credentials
#
# Usage: bash update-turn-config.sh <server_ip> <password>
#

if [ "$#" -ne 2 ]; then
  echo "Usage: bash update-turn-config.sh <server_ip> <password>"
  echo "Example: bash update-turn-config.sh 1.2.3.4 wirecore2026secure"
  exit 1
fi

SERVER_IP="$1"
PASSWORD="$2"

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
APP_JS="$SCRIPT_DIR/public/app.js"

if [ ! -f "$APP_JS" ]; then
  echo "❌ Error: $APP_JS not found"
  exit 1
fi

echo "🔧 Updating Wirecore TURN configuration..."
echo "   Server IP: $SERVER_IP"
echo "   Password: $PASSWORD"

# Backup original
cp "$APP_JS" "$APP_JS.backup"

# Use sed to uncomment and update TURN config
sed -i.tmp \
  -e "s|// {|{|g" \
  -e "s|//   urls: 'turn:YOUR_TABERTRON_IP:3478',|  urls: 'turn:$SERVER_IP:3478',|g" \
  -e "s|//   urls: 'turn:YOUR_TABERTRON_IP:5349',|  urls: 'turn:$SERVER_IP:5349',|g" \
  -e "s|//   username: 'wirecore',|  username: 'wirecore',|g" \
  -e "s|//   credential: 'YourStrongPassword123'|  credential: '$PASSWORD'|g" \
  -e "s|// }|}|g" \
  "$APP_JS"

rm -f "$APP_JS.tmp"

echo "✅ Config updated!"
echo ""
echo "📝 Changes made to public/app.js:"
echo "   - Uncommented TURN server lines"
echo "   - Set server IP to: $SERVER_IP"
echo "   - Set password to: $PASSWORD"
echo ""
echo "🔄 Restart your Wirecore server and refresh browsers to apply changes"
echo ""
echo "💾 Backup saved to: $APP_JS.backup"