OverviewFilesCommitsIssuesDocsReleasesPeers

wirecore / scripts / fix-turn-permissions.sh

48 lines · bash ref:
#!/bin/bash
#
# Fix TURN server permissions to bind to relay ports
# Run this on Tabertron
#
# Usage: sudo bash fix-turn-permissions.sh
#

set -e

if [ "$EUID" -ne 0 ]; then
  echo "Please run as root: sudo bash fix-turn-permissions.sh"
  exit 1
fi

echo "🔧 Fixing TURN server permissions..."

# Give turnserver binary permission to bind to privileged ports
setcap 'cap_net_bind_service=+ep' /usr/bin/turnserver

echo "✅ Permissions set!"
echo ""

# Restart TURN server
echo "🔄 Restarting TURN server..."
systemctl restart coturn

sleep 2

if systemctl is-active --quiet coturn; then
  echo "✅ TURN server restarted successfully!"
else
  echo "❌ TURN server failed to start!"
  journalctl -u coturn -n 20
  exit 1
fi

echo ""
echo "📋 Testing TURN server..."
sleep 2

# Test with turnutils
turnutils_uclient -v -u wirecore -w wirecore8261a6a559ce533c -e 8.8.8.8 142.93.23.112 2>&1 | head -20

echo ""
echo "✅ If you see allocations without errors, TURN is working!"
echo ""