Bot & Automation
Treding Forex Ai
/root/hermes-projects/Treding Forex Ai
mt5-bridge/scripts/configure-vps-bot-bridge.ps1
text
$ErrorActionPreference = "Stop"
$bridgeRoot = Split-Path -Parent $PSScriptRoot
$envPath = Join-Path $bridgeRoot ".env"
if (-not (Test-Path -LiteralPath $envPath)) {
throw ".env bridge belum ada."
}
$bridgeEnv = Get-Content -LiteralPath $envPath -Raw
$bridgeToken = ([regex]::Match($bridgeEnv, "(?m)^BRIDGE_TOKEN=(.+)$")).Groups[1].Value.Trim()
if (-not $bridgeToken) {
throw "BRIDGE_TOKEN kosong."
}
$headers = @{ Authorization = "Bearer $bridgeToken" }
$health = Invoke-RestMethod -Uri "http://127.0.0.1:8095/health" -Headers $headers -Method Get
if (-not $health.ok) {
throw "Bridge health tidak OK."
}
if (-not $health.dryRun -or $health.allowRealTrading) {
throw "Script ini hanya untuk dry-run. Set BRIDGE_DRY_RUN=true dan ALLOW_REAL_TRADING=false dulu."
}
$script = @"
set -e
cd '/root/hermes-projects/Treding Forex Ai'
python3 - <<'PY'
from pathlib import Path
path = Path(".env")
text = path.read_text()
updates = {
"BROKER_PROVIDER": "mt5_bridge",
"MT5_BRIDGE_URL": "http://127.0.0.1:8095",
"MT5_BRIDGE_TOKEN": "$bridgeToken",
"TRADING_MODE": "semi_auto",
"ENABLE_REAL_TRADING": "true",
"AUTO_TRADING_ENABLED": "false",
}
for key, value in updates.items():
lines = text.splitlines()
replaced = False
for index, line in enumerate(lines):
if line.startswith(key + "="):
lines[index] = f"{key}={value}"
replaced = True
break
if not replaced:
lines.append(f"{key}={value}")
text = "\n".join(lines) + "\n"
path.write_text(text)
PY
chmod 600 .env
docker compose build
docker compose up -d
"@
$script | ssh root@187.77.119.32 "bash -s"
Write-Output "VPS_BOT_CONFIGURED_FOR_MT5_BRIDGE_DRY_RUN"