32 lines
1.0 KiB
PowerShell
32 lines
1.0 KiB
PowerShell
param(
|
|
[string]$Distro = ""
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$Root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
|
|
Set-Location $Root
|
|
|
|
if (!(Get-Command wsl -ErrorAction SilentlyContinue)) {
|
|
throw "WSL command not found. Please install WSL first."
|
|
}
|
|
|
|
# Resolve Windows project path to the same distro that will run the server (mounts differ per distro).
|
|
if ([string]::IsNullOrWhiteSpace($Distro)) {
|
|
$linuxPath = (wsl -- wslpath -a "$Root").Trim()
|
|
} else {
|
|
$linuxPath = (wsl -d $Distro -- wslpath -a "$Root").Trim()
|
|
}
|
|
if ([string]::IsNullOrWhiteSpace($linuxPath)) {
|
|
throw "Failed to resolve WSL path for project root: $Root"
|
|
}
|
|
|
|
# Single argument to bash -lc; quote the whole string so spaces in path are safe.
|
|
$bashCommand = "cd '$linuxPath' && chmod +x scripts/one_click_wsl.sh scripts/install_wsl_env.sh scripts/run_server.sh && exec bash scripts/one_click_wsl.sh"
|
|
|
|
if ([string]::IsNullOrWhiteSpace($Distro)) {
|
|
wsl -- bash -lc "$bashCommand"
|
|
} else {
|
|
wsl -d $Distro -- bash -lc "$bashCommand"
|
|
}
|