iex evaluates the script body in the caller's scope, so top-level side effects leak into the user's interactive PowerShell. Two leaks fixed: - Dropped 'exit $LASTEXITCODE' — would close the user's shell window. - Dropped 'Set-Location $Dir' — would leave the user sitting in .\installer\ after the run. install.ps1 uses $PSScriptRoot to find its templates, so it can be invoked from any CWD via its full path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
60 lines
1.7 KiB
PowerShell
60 lines
1.7 KiB
PowerShell
#Requires -Version 5.1
|
|
<#
|
|
.SYNOPSIS
|
|
Bootstrap script — downloads the Cameleer installer and runs it.
|
|
.EXAMPLE
|
|
irm https://registry.cameleer.io/cameleer/cameleer-saas-installer/raw/branch/main/get-cameleer.ps1 | iex
|
|
& ([scriptblock]::Create((irm https://.../get-cameleer.ps1))) -Version v1.2.0
|
|
#>
|
|
param(
|
|
[string]$Version,
|
|
[string]$Ref,
|
|
[Parameter(ValueFromRemainingArguments = $true)]
|
|
[string[]]$InstallerArgs
|
|
)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
$Repo = 'https://registry.cameleer.io/cameleer/cameleer-saas-installer/raw'
|
|
if ($Version) { $RefPath = "tag/$Version" }
|
|
elseif ($Ref) { $RefPath = "branch/$Ref" }
|
|
else { $RefPath = 'branch/main' }
|
|
|
|
$Base = "$Repo/$RefPath"
|
|
$Dir = '.\installer'
|
|
|
|
$Files = @(
|
|
'install.ps1'
|
|
'templates/docker-compose.yml'
|
|
'templates/docker-compose.saas.yml'
|
|
'templates/docker-compose.server.yml'
|
|
'templates/docker-compose.tls.yml'
|
|
'templates/docker-compose.monitoring.yml'
|
|
'templates/traefik-dynamic.yml'
|
|
'templates/.env.example'
|
|
)
|
|
|
|
Write-Host 'Downloading Cameleer installer...'
|
|
|
|
New-Item -ItemType Directory -Path "$Dir\templates" -Force | Out-Null
|
|
|
|
foreach ($file in $Files) {
|
|
$localPath = Join-Path $Dir $file
|
|
$localDir = Split-Path $localPath -Parent
|
|
if (-not (Test-Path $localDir)) { New-Item -ItemType Directory -Path $localDir -Force | Out-Null }
|
|
|
|
Write-Host " $file"
|
|
Invoke-WebRequest -Uri "$Base/$file" -OutFile $localPath -UseBasicParsing
|
|
}
|
|
|
|
Write-Host ''
|
|
Write-Host "Installer downloaded to $Dir\ — launching..."
|
|
Write-Host ''
|
|
|
|
$installerPath = Join-Path $Dir 'install.ps1'
|
|
if ($InstallerArgs) {
|
|
& $installerPath @InstallerArgs
|
|
} else {
|
|
& $installerPath
|
|
}
|