Skip to content

Commit 4c8b3e9

Browse files
committed
fix: preserve Matrix spike config ownership
1 parent 49f853a commit 4c8b3e9

1 file changed

Lines changed: 25 additions & 3 deletions

File tree

mesh/infra/matrix-spike/setup.ps1

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,31 @@ function Ensure-SynapseConfig {
7979
New-Item -ItemType Directory -Force -Path $dataPath | Out-Null
8080
$configPath = Join-Path $dataPath 'homeserver.yaml'
8181
if (-not (Test-Path -LiteralPath $configPath)) {
82-
& docker run --rm -v "${dataPath}:/data" `
83-
-e "SYNAPSE_SERVER_NAME=$ServerName" -e SYNAPSE_REPORT_STATS=no `
84-
$synapseImage generate
82+
$dockerRunArguments = @('run', '--rm')
83+
if (-not [System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform(
84+
[System.Runtime.InteropServices.OSPlatform]::Windows
85+
)) {
86+
$userId = (& id -u).Trim()
87+
if ($LASTEXITCODE -ne 0 -or $userId -notmatch '^\d+$') {
88+
throw 'Could not determine the Unix user ID for Matrix spike setup'
89+
}
90+
$groupId = (& id -g).Trim()
91+
if ($LASTEXITCODE -ne 0 -or $groupId -notmatch '^\d+$') {
92+
throw 'Could not determine the Unix group ID for Matrix spike setup'
93+
}
94+
$dockerRunArguments += @('--user', "${userId}:${groupId}")
95+
}
96+
$dockerRunArguments += @(
97+
'-v',
98+
"${dataPath}:/data",
99+
'-e',
100+
"SYNAPSE_SERVER_NAME=$ServerName",
101+
'-e',
102+
'SYNAPSE_REPORT_STATS=no',
103+
$synapseImage,
104+
'generate'
105+
)
106+
& docker @dockerRunArguments
85107
if ($LASTEXITCODE -ne 0) { throw "Failed to generate Synapse config for $ServerName" }
86108

87109
Add-Content -LiteralPath $configPath -Value @"

0 commit comments

Comments
 (0)