-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.ps1
More file actions
89 lines (73 loc) · 1.99 KB
/
Copy pathsetup.ps1
File metadata and controls
89 lines (73 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
Param(
[string]$InstallDir = "nomisma"
)
$ErrorActionPreference = "Stop"
$InstallDirInput = Read-Host "Install path [$InstallDir]"
if ($InstallDirInput) {
$InstallDir = $InstallDirInput
}
$RepoUrl = $env:REPO_URL
if (-not $RepoUrl) {
$RepoUrl = "https://github.com/nikolareljin/nomisma.git"
}
function Open-Url {
param([string]$Url)
try {
Start-Process $Url
} catch {
Write-Host "Open this URL in your browser: $Url"
}
}
function Require-Command {
param(
[string]$CommandName,
[string]$Url
)
if (-not (Get-Command $CommandName -ErrorAction SilentlyContinue)) {
Write-Host "Missing dependency: $CommandName"
Open-Url $Url
exit 1
}
}
Require-Command -CommandName "git" -Url "https://git-scm.com/downloads"
if (-not (Get-Command "docker" -ErrorAction SilentlyContinue)) {
Write-Host "Missing dependency: docker"
Open-Url "https://docs.docker.com/get-docker/"
exit 1
}
$composeAvailable = $false
try {
docker compose version | Out-Null
$composeAvailable = $true
} catch {
$composeAvailable = $false
}
if (-not $composeAvailable -and (Get-Command "docker-compose" -ErrorAction SilentlyContinue)) {
$composeAvailable = $true
}
if (-not $composeAvailable) {
Write-Host "Missing dependency: docker compose"
Open-Url "https://docs.docker.com/compose/install/"
exit 1
}
if (Test-Path $InstallDir) {
Write-Host "Install directory already exists: $InstallDir"
Write-Host "Remove it or pick a different path."
exit 1
}
Write-Host "Cloning $RepoUrl into $InstallDir"
git clone $RepoUrl $InstallDir
Set-Location $InstallDir
if (Test-Path ".\update") {
.\update
} else {
git submodule update --init --recursive
}
if (-not (Test-Path ".\.env") -and (Test-Path ".\.env.example")) {
Copy-Item ".\.env.example" ".\.env"
Write-Host "Created .env from .env.example"
}
Write-Host "Setup complete."
Write-Host "Next steps:"
Write-Host " cd $InstallDir"
Write-Host " ./start"