-
Notifications
You must be signed in to change notification settings - Fork 2
/
install.ps1
35 lines (29 loc) · 1.45 KB
/
install.ps1
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
# Ensure the script is run as Administrator
if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Host "This script must be run as an Administrator. Restarting as administrator..."
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File $($MyInvocation.MyCommand.Path)" -Verb RunAs
exit
}
# Define directories
$binDir = "bin"
$configDir = "scripts"
$installDir = "C:\Program Files\SPoK"
$configInstallDir = "C:\ProgramData\SPoK"
# Create installation directories if they don't exist
if (-Not (Test-Path $installDir)) {
New-Item -Path $installDir -ItemType Directory
}
if (-Not (Test-Path $configInstallDir)) {
New-Item -Path $configInstallDir -ItemType Directory
}
# Copy binaries
Copy-Item -Path "$binDir\spok.exe" -Destination $installDir -Force
Copy-Item -Path "$configDir\configure-spok-server.sh" -Destination $configInstallDir -Force
Copy-Item -Path ".\README.md" -Destination $configInstallDir -Force
Copy-Item -Path ".\LICENSE" -Destination $configInstallDir -Force
# Add to PATH environment variable
$envPath = [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine)
if (-Not ($envPath -like "*$installDir*")) {
[Environment]::SetEnvironmentVariable("Path", $envPath + ";$installDir", [EnvironmentVariableTarget]::Machine)
}
Write-Host "Installation of SPoK completed successfully!"