openvibers/source.openvibe.games LINUX_SETUP.md
LINUX_SETUP.md
| 1 | # OpenVibe: Source - Linux Setup & Run Guide |
| 2 | |
| 3 | Complete step-by-step guide to set up and run OpenVibe: Source on Linux. |
| 4 | |
| 5 | ## Prerequisites |
| 6 | |
| 7 | ### System Requirements |
| 8 | - Ubuntu 20.04 LTS or later (tested on 22.04 LTS) |
| 9 | - 50GB free disk space (SRCDS + Steam apps) |
| 10 | - 8GB RAM minimum (16GB recommended for multiple servers) |
| 11 | - 4-core CPU minimum |
| 12 | |
| 13 | ### Required Software |
| 14 | |
| 15 | #### 1. Install system dependencies |
| 16 | ```bash |
| 17 | sudo apt-get update |
| 18 | sudo apt-get install -y \ |
| 19 | git curl wget build-essential \ |
| 20 | python3 python3-pip \ |
| 21 | node.js npm \ |
| 22 | wine wine32 wine64 winetricks \ |
| 23 | lib32gcc-s1 lib32stdc++6 \ |
| 24 | libssl-dev libffi-dev \ |
| 25 | postgresql postgresql-contrib \ |
| 26 | docker.io docker-compose \ |
| 27 | tmux screen \ |
| 28 | jq |
| 29 | ``` |
| 30 | |
| 31 | #### 2. Install Proton Experimental (for SRCDS on Linux) |
| 32 | ```bash |
| 33 | # Download Proton Experimental if using newer Steam |
| 34 | # For Proton 8.x+, set up environment: |
| 35 | export PROTON_VERSION="experimental" |
| 36 | export STEAM_COMPAT_TOOLS_PATHS="/home/$USER/.steam/root/compatibilitytools.d" |
| 37 | |
| 38 | # Or use native SRCDS if available for your engine version |
| 39 | ``` |
| 40 | |
| 41 | #### 3. Install Steam and SteamCMD |
| 42 | ```bash |
| 43 | mkdir -p ~/steamcmd |
| 44 | cd ~/steamcmd |
| 45 | curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf - |
| 46 | |
| 47 | # Login to Steam |
| 48 | ./steamcmd.sh |
| 49 | > login anonymous |
| 50 | > quit |
| 51 | |
| 52 | # Add to PATH |
| 53 | echo 'export PATH="$PATH:$HOME/steamcmd"' >> ~/.bashrc |
| 54 | source ~/.bashrc |
| 55 | ``` |
| 56 | |
| 57 | #### 4. Install Team Fortress 2 (for BSP compilation tools) |
| 58 | ```bash |
| 59 | steamcmd.sh \ |
| 60 | +login anonymous \ |
| 61 | +app_update 440 validate \ |
| 62 | +quit |
| 63 | |
| 64 | # Wait for download (~15GB) |
| 65 | ``` |
| 66 | |
| 67 | #### 5. Install HL2: Deathmatch (game base) |
| 68 | ```bash |
| 69 | steamcmd.sh \ |
| 70 | +login anonymous \ |
| 71 | +app_update 320 validate \ |
| 72 | +quit |
| 73 | ``` |
| 74 | |
| 75 | ## OpenVibe Setup |
| 76 | |
| 77 | ### 1. Clone the repository |
| 78 | ```bash |
| 79 | cd ~ |
| 80 | git clone https://github.com/yourusername/openvibe-source.git |
| 81 | cd openvibe-source |
| 82 | ``` |
| 83 | |
| 84 | ### 2. Set up environment variables |
| 85 | ```bash |
| 86 | # Create ~/.bashrc additions |
| 87 | cat >> ~/.bashrc << 'EOF' |
| 88 | export OPENVIBE_ROOT="$HOME/openvibe-source" |
| 89 | export TF2_INSTALL_DIR="$HOME/.steam/steam/SteamApps/common/Team Fortress 2" |
| 90 | export HL2_INSTALL_DIR="$HOME/.steam/steam/SteamApps/common/Half-Life 2 Deathmatch" |
| 91 | export SRCDS_DIR="$HOME/srcds" |
| 92 | export OV_API_ENDPOINT="http://localhost:3000" |
| 93 | export OV_API_SECRET="your-secret-key-here" |
| 94 | EOF |
| 95 | |
| 96 | source ~/.bashrc |
| 97 | ``` |
| 98 | |
| 99 | ### 3. Set up SRCDS installation |
| 100 | ```bash |
| 101 | # Create SRCDS directory structure |
| 102 | mkdir -p $SRCDS_DIR/hlserver/orangebox/cfg |
| 103 | mkdir -p $SRCDS_DIR/hlserver/orangebox/maps |
| 104 | mkdir -p $SRCDS_DIR/hlserver/orangebox/logs |
| 105 | |
| 106 | # Copy game files from HL2:DM installation |
| 107 | cp -r "$HL2_INSTALL_DIR/hl2mp" "$SRCDS_DIR/hlserver/orangebox/" |
| 108 | cp -r "$HL2_INSTALL_DIR/bin" "$SRCDS_DIR/hlserver/orangebox/" |
| 109 | cp -r "$HL2_INSTALL_DIR/orange.gcf" "$SRCDS_DIR/hlserver/orangebox/" || true |
| 110 | ``` |
| 111 | |
| 112 | ### 4. Set up PostgreSQL database |
| 113 | ```bash |
| 114 | # Start PostgreSQL |
| 115 | sudo systemctl start postgresql |
| 116 | |
| 117 | # Create database |
| 118 | sudo -u postgres psql << 'EOF' |
| 119 | CREATE DATABASE openvibe; |
| 120 | CREATE USER openvibe WITH PASSWORD 'openvibe_dev_password'; |
| 121 | ALTER ROLE openvibe SET client_encoding TO 'utf8'; |
| 122 | ALTER ROLE openvibe SET default_transaction_isolation TO 'read committed'; |
| 123 | ALTER ROLE openvibe SET default_transaction_deferrable TO on; |
| 124 | ALTER ROLE openvibe SET timezone TO 'UTC'; |
| 125 | GRANT ALL PRIVILEGES ON DATABASE openvibe TO openvibe; |
| 126 | EOF |
| 127 | |
| 128 | # Initialize database schema |
| 129 | cd $OPENVIBE_ROOT/backend |
| 130 | npm install |
| 131 | npm run db:migrate |
| 132 | ``` |
| 133 | |
| 134 | ### 5. Install backend dependencies |
| 135 | ```bash |
| 136 | cd $OPENVIBE_ROOT/backend |
| 137 | npm install |
| 138 | npm run build |
| 139 | ``` |
| 140 | |
| 141 | ### 6. Compile maps (requires Wine + TF2 tools) |
| 142 | ```bash |
| 143 | cd $OPENVIBE_ROOT |
| 144 | |
| 145 | # Make script executable |
| 146 | chmod +x tools/compile-dev-maps-wine.sh |
| 147 | |
| 148 | # Compile all maps (VIS can be slow, skip with VVIS_ENABLED=0) |
| 149 | VVIS_ENABLED=0 ./tools/compile-dev-maps-wine.sh |
| 150 | |
| 151 | # Copy compiled BSPs to SRCDS |
| 152 | cp game/openvibe.games/maps/*.bsp $SRCDS_DIR/hlserver/orangebox/hl2mp/maps/ |
| 153 | ``` |
| 154 | |
| 155 | ### 7. Copy OpenVibe game content |
| 156 | ```bash |
| 157 | # Copy scripts |
| 158 | mkdir -p $SRCDS_DIR/hlserver/orangebox/hl2mp/scripts/vscripts |
| 159 | cp game/openvibe.games/scripts/vscripts/*.nut \ |
| 160 | $SRCDS_DIR/hlserver/orangebox/hl2mp/scripts/vscripts/ |
| 161 | |
| 162 | # Copy configs |
| 163 | mkdir -p $SRCDS_DIR/hlserver/orangebox/hl2mp/cfg |
| 164 | cp game/openvibe.games/cfg/*.cfg \ |
| 165 | $SRCDS_DIR/hlserver/orangebox/hl2mp/cfg/ |
| 166 | |
| 167 | # Copy resources |
| 168 | mkdir -p $SRCDS_DIR/hlserver/orangebox/hl2mp/resource |
| 169 | cp game/openvibe.games/resource/*.txt \ |
| 170 | $SRCDS_DIR/hlserver/orangebox/hl2mp/resource/ |
| 171 | |
| 172 | # Copy particles |
| 173 | mkdir -p $SRCDS_DIR/hlserver/orangebox/hl2mp/particles |
| 174 | cp game/openvibe.games/particles/* \ |
| 175 | $SRCDS_DIR/hlserver/orangebox/hl2mp/particles/ |
| 176 | ``` |
| 177 | |
| 178 | ## Configuration |
| 179 | |
| 180 | ### 1. Configure server.cfg |
| 181 | ```bash |
| 182 | cat > $SRCDS_DIR/hlserver/orangebox/hl2mp/cfg/server.cfg << 'EOF' |
| 183 | // OpenVibe Server Configuration |
| 184 | |
| 185 | // Server settings |
| 186 | hostname "OpenVibe - Hub [US-East]" |
| 187 | rcon_password "your-secure-rcon-password" |
| 188 | |
| 189 | // OpenVibe settings |
| 190 | ov_api_endpoint "http://localhost:3000" |
| 191 | ov_server_id "us-east-hub-01" |
| 192 | ov_server_secret "your-server-secret" |
| 193 | |
| 194 | // Network |
| 195 | rate 30000 |
| 196 | cl_cmdrate 66 |
| 197 | sv_mincmdrate 10 |
| 198 | |
| 199 | // Gameplay |
| 200 | mp_friendlyfire 0 |
| 201 | mp_falldamage 0 |
| 202 | mp_teamplay 1 |
| 203 | |
| 204 | // Logging |
| 205 | log on |
| 206 | sv_log_onefile 1 |
| 207 | EOF |
| 208 | ``` |
| 209 | |
| 210 | ### 2. Configure backend API (.env) |
| 211 | ```bash |
| 212 | cat > $OPENVIBE_ROOT/backend/.env << 'EOF' |
| 213 | # Database |
| 214 | DATABASE_URL="postgresql://openvibe:openvibe_dev_password@localhost:5432/openvibe" |
| 215 | |
| 216 | # Server |
| 217 | NODE_ENV="production" |
| 218 | PORT=3000 |
| 219 | LOG_LEVEL="info" |
| 220 | |
| 221 | # Admin |
| 222 | ADMIN_SECRET_KEY="your-admin-secret-key" |
| 223 | |
| 224 | # Steam |
| 225 | STEAM_APP_ID="YOUR_STEAM_APP_ID" |
| 226 | STEAM_API_KEY="your-steam-api-key" |
| 227 | EOF |
| 228 | ``` |
| 229 | |
| 230 | ## Running the Servers |
| 231 | |
| 232 | ### 1. Start the API backend |
| 233 | ```bash |
| 234 | cd $OPENVIBE_ROOT/backend |
| 235 | npm start |
| 236 | |
| 237 | # Or with Docker |
| 238 | cd $OPENVIBE_ROOT |
| 239 | docker-compose -f infra/docker-compose.yml up -d |
| 240 | ``` |
| 241 | |
| 242 | ### 2. Start all game servers (via tmux) |
| 243 | ```bash |
| 244 | # Make dev-up script executable |
| 245 | chmod +x $OPENVIBE_ROOT/tools/dev-up.sh |
| 246 | |
| 247 | # Start all 5 servers + sidecar |
| 248 | $OPENVIBE_ROOT/tools/dev-up.sh |
| 249 | |
| 250 | # Attach to tmux session to view output |
| 251 | tmux attach-session -t openvibe |
| 252 | ``` |
| 253 | |
| 254 | ### 3. Manual server startup (single server) |
| 255 | ```bash |
| 256 | # For Hub server |
| 257 | cd $SRCDS_DIR/hlserver |
| 258 | ./srcds_run -game hl2mp \ |
| 259 | +map ov_hub \ |
| 260 | -maxplayers 32 \ |
| 261 | -port 27015 \ |
| 262 | +sv_pure 0 \ |
| 263 | +exec server.cfg \ |
| 264 | -console |
| 265 | |
| 266 | # For Prop Hunt server |
| 267 | cd $SRCDS_DIR/hlserver |
| 268 | ./srcds_run -game hl2mp \ |
| 269 | +map ph_openvibe_dev \ |
| 270 | -maxplayers 16 \ |
| 271 | -port 27016 \ |
| 272 | +sv_pure 0 \ |
| 273 | +exec server.cfg \ |
| 274 | -console |
| 275 | ``` |
| 276 | |
| 277 | ### 4. Connect client |
| 278 | ```bash |
| 279 | # With Proton Experimental |
| 280 | PROTON_EXPERIMENTAL=1 steam steam://run/320//-console +connect 127.0.0.1:27015 |
| 281 | |
| 282 | # Or via console |
| 283 | > connect 127.0.0.1:27015 |
| 284 | > ov_join hub |
| 285 | ``` |
| 286 | |
| 287 | ## Troubleshooting |
| 288 | |
| 289 | ### Game server won't start |
| 290 | ```bash |
| 291 | # Check SRCDS binary exists |
| 292 | ls -la $SRCDS_DIR/hlserver/srcds_run |
| 293 | |
| 294 | # Run with verbose output |
| 295 | ./srcds_run -game hl2mp +map ov_hub -console -debug |
| 296 | |
| 297 | # Check for missing libraries |
| 298 | ldd ./srcds_i486 |
| 299 | ``` |
| 300 | |
| 301 | ### API connection fails |
| 302 | ```bash |
| 303 | # Check backend is running |
| 304 | curl http://localhost:3000/health |
| 305 | |
| 306 | # Check logs |
| 307 | docker logs openvibe_api |
| 308 | |
| 309 | # Verify PostgreSQL |
| 310 | sudo -u postgres psql openvibe -c "SELECT 1;" |
| 311 | ``` |
| 312 | |
| 313 | ### BSP compilation errors |
| 314 | ```bash |
| 315 | # Check TF2 installation |
| 316 | ls -la "$TF2_INSTALL_DIR/bin/" |
| 317 | |
| 318 | # Run VBSP manually for debugging |
| 319 | WINEARCH=win32 wine "$TF2_INSTALL_DIR/bin/vbsp.exe" \ |
| 320 | -game "$TF2_INSTALL_DIR/tf" \ |
| 321 | "$OPENVIBE_ROOT/game/openvibe.games/maps/ov_hub.vmf" |
| 322 | ``` |
| 323 | |
| 324 | ### VScript errors in server console |
| 325 | ```bash |
| 326 | # Check script files exist |
| 327 | ls -la $SRCDS_DIR/hlserver/orangebox/hl2mp/scripts/vscripts/ |
| 328 | |
| 329 | # Enable VScript logging |
| 330 | sv_script_debug 1 |
| 331 | |
| 332 | # Check logs directory has write permissions |
| 333 | chmod 777 $SRCDS_DIR/hlserver/orangebox/hl2mp/logs |
| 334 | ``` |
| 335 | |
| 336 | ### Player can't join servers |
| 337 | ```bash |
| 338 | # Check firewall rules |
| 339 | sudo ufw status |
| 340 | sudo ufw allow 27015:27020/udp |
| 341 | sudo ufw allow 27015:27020/tcp |
| 342 | |
| 343 | # Check SRCDS is listening |
| 344 | netstat -tulnp | grep -E "27015|27016|27017|27018|27019" |
| 345 | |
| 346 | # Verify server loads map correctly |
| 347 | # Look for: "Didn't load map" errors in console |
| 348 | ``` |
| 349 | |
| 350 | ## Development Workflow |
| 351 | |
| 352 | ### 1. Modify VScript logic |
| 353 | ```bash |
| 354 | # Edit game mode script |
| 355 | nano $OPENVIBE_ROOT/game/openvibe.games/scripts/vscripts/ov_prophunt.nut |
| 356 | |
| 357 | # Changes take effect on map reload (no restart needed) |
| 358 | # In-game console: `changelevel ph_openvibe_dev` |
| 359 | ``` |
| 360 | |
| 361 | ### 2. Modify backend API |
| 362 | ```bash |
| 363 | # Edit endpoint |
| 364 | nano $OPENVIBE_ROOT/backend/src/app.ts |
| 365 | |
| 366 | # Rebuild TypeScript |
| 367 | cd $OPENVIBE_ROOT/backend |
| 368 | npm run build |
| 369 | |
| 370 | # Restart API |
| 371 | docker-compose -f infra/docker-compose.yml restart api |
| 372 | ``` |
| 373 | |
| 374 | ### 3. Update maps |
| 375 | ```bash |
| 376 | # Edit VMF in Hammer Editor (if available) |
| 377 | # Or modify generator |
| 378 | nano $OPENVIBE_ROOT/tools/generate-dev-vmfs.mjs |
| 379 | |
| 380 | # Regenerate and compile |
| 381 | cd $OPENVIBE_ROOT |
| 382 | ./tools/compile-dev-maps-wine.sh |
| 383 | |
| 384 | # Copy new BSP |
| 385 | cp game/openvibe.games/maps/ph_openvibe_dev.bsp $SRCDS_DIR/hlserver/orangebox/hl2mp/maps/ |
| 386 | |
| 387 | # Reload map in-game |
| 388 | ``` |
| 389 | |
| 390 | ## Monitoring |
| 391 | |
| 392 | ### Check server status |
| 393 | ```bash |
| 394 | # List running SRCDS processes |
| 395 | ps aux | grep srcds |
| 396 | |
| 397 | # Check port availability |
| 398 | netstat -tulnp | grep -E "27015|27016|27017" |
| 399 | |
| 400 | # Check API health |
| 401 | curl http://localhost:3000/health | jq . |
| 402 | ``` |
| 403 | |
| 404 | ### View logs |
| 405 | ```bash |
| 406 | # SRCDS logs |
| 407 | tail -f $SRCDS_DIR/hlserver/orangebox/hl2mp/logs/L*.log |
| 408 | |
| 409 | # API logs |
| 410 | docker logs -f openvibe_api |
| 411 | |
| 412 | # Sidecar logs |
| 413 | tmux capture-pane -t openvibe:sidecar -p |
| 414 | |
| 415 | # PostgreSQL logs |
| 416 | sudo tail -f /var/log/postgresql/postgresql.log |
| 417 | ``` |
| 418 | |
| 419 | ## Performance Tuning |
| 420 | |
| 421 | ### Increase SRCDS performance |
| 422 | ```bash |
| 423 | # Adjust rate limits for better responsiveness |
| 424 | rate 30000 |
| 425 | cl_cmdrate 66 |
| 426 | sv_mincmdrate 10 |
| 427 | |
| 428 | # Adjust tickrate (higher = more CPU usage) |
| 429 | sv_tickrate 66 |
| 430 | ``` |
| 431 | |
| 432 | ### Database optimization |
| 433 | ```bash |
| 434 | # Enable query logging |
| 435 | sudo -u postgres psql openvibe -c "ALTER SYSTEM SET log_min_duration_statement = 100;" |
| 436 | sudo systemctl restart postgresql |
| 437 | |
| 438 | # Check indexes |
| 439 | sudo -u postgres psql openvibe -c "\d+ players" |
| 440 | sudo -u postgres psql openvibe -c "\d+ matches" |
| 441 | ``` |
| 442 | |
| 443 | ## Deployment to Production |
| 444 | |
| 445 | ### 1. Use environment-specific configs |
| 446 | ```bash |
| 447 | # Production backend config |
| 448 | cp $OPENVIBE_ROOT/backend/.env.example $OPENVIBE_ROOT/backend/.env.production |
| 449 | # Edit with real credentials and settings |
| 450 | nano $OPENVIBE_ROOT/backend/.env.production |
| 451 | ``` |
| 452 | |
| 453 | ### 2. Use Docker for all services |
| 454 | ```bash |
| 455 | # Production docker-compose |
| 456 | docker-compose -f infra/docker-compose.yml up -d |
| 457 | |
| 458 | # Enable restart policy |
| 459 | docker update --restart=unless-stopped openvibe_api |
| 460 | docker update --restart=unless-stopped openvibe_db |
| 461 | ``` |
| 462 | |
| 463 | ### 3. Set up SSL/TLS reverse proxy |
| 464 | ```bash |
| 465 | # Use nginx or similar |
| 466 | # Configure with valid certificates |
| 467 | # Point to http://localhost:3000 backend |
| 468 | ``` |
| 469 | |
| 470 | ### 4. Enable server monitoring |
| 471 | ```bash |
| 472 | # Use systemd service files for SRCDS instances |
| 473 | # Set up Prometheus/Grafana for metrics |
| 474 | # Configure alerts for server crashes |
| 475 | ``` |
| 476 | |
| 477 | ## Useful Commands |
| 478 | |
| 479 | ```bash |
| 480 | # List all tmux sessions |
| 481 | tmux list-sessions |
| 482 | |
| 483 | # Attach to specific server |
| 484 | tmux attach-session -t openvibe:hub |
| 485 | |
| 486 | # Kill all servers |
| 487 | tmux kill-session -t openvibe |
| 488 | |
| 489 | # Check SRCDS console remotely |
| 490 | tmux capture-pane -t openvibe:hub -p |
| 491 | |
| 492 | # Execute command on server |
| 493 | tmux send-keys -t openvibe:hub "say Hello from console" Enter |
| 494 | |
| 495 | # View leaderboard |
| 496 | curl "http://localhost:3000/v1/leaderboard?limit=10" | jq . |
| 497 | |
| 498 | # Create admin shop item |
| 499 | curl -X POST http://localhost:3000/v1/admin/shop/items \ |
| 500 | -H "Content-Type: application/json" \ |
| 501 | -H "X-Admin-Secret: your-admin-secret" \ |
| 502 | -d '{"name":"Cool Skin","type":"model","price":5000}' |
| 503 | ``` |
| 504 | |
| 505 | ## Support & Debugging |
| 506 | |
| 507 | ### Enable verbose logging |
| 508 | ```bash |
| 509 | # In server.cfg |
| 510 | developer 2 |
| 511 | sv_log_onefile 1 |
| 512 | sv_script_debug 1 |
| 513 | |
| 514 | # In OpenVibe config |
| 515 | OV_DEBUG=1 |
| 516 | ``` |
| 517 | |
| 518 | ### Generate debug package |
| 519 | ```bash |
| 520 | cd $OPENVIBE_ROOT |
| 521 | mkdir -p debug-export |
| 522 | cp game/openvibe.games/scripts/vscripts/*.nut debug-export/ |
| 523 | cp tools/ov-sidecar.mjs debug-export/ |
| 524 | docker logs openvibe_api > debug-export/api.log |
| 525 | docker logs openvibe_db > debug-export/db.log |
| 526 | # Tar for sharing |
| 527 | tar czf openvibe-debug-$(date +%Y%m%d-%H%M%S).tar.gz debug-export/ |
| 528 | ``` |
| 529 | |
| 530 | ## Next Steps |
| 531 | |
| 532 | 1. **Customize game modes** - Edit VScript files to adjust gameplay |
| 533 | 2. **Add more cosmetics** - Use `/v1/admin/shop/items` to add items |
| 534 | 3. **Set up web dashboard** - Create a web UI that connects to the API |
| 535 | 4. **Configure Steam integration** - Add proper Steam authentication |
| 536 | 5. **Deploy to production** - Use Docker Swarm or Kubernetes |
| 537 | |
| 538 | --- |
| 539 | |
| 540 | For more information, see: |
| 541 | - [Architecture Documentation](./docs/architecture.md) |
| 542 | - [Backend API Docs](./backend/README.md) |
| 543 | - [VScript Reference](./game/openvibe.games/scripts/vscripts/ov_shared.nut) |
| 544 |