-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.ps1
51 lines (39 loc) · 1.56 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Configuration
$INSTALL_DIR = "C:\Program Files\tchat"
$CONFIG_DIR = "$env:USERPROFILE\.config\tchat"
$CLIENT_DIR = "./client" # Directory containing the client source code
$RELEASE_URL = "https://github.com/tasnimzotder/tchat/releases/latest/download"
$ASSET_WINDOWS_AMD64 = "tchat.windows.amd64.exe"
# ------------------------
# Functions (like Bash 'print')
# ------------------------
function Write-ColoredOutput($Type, $Message) {
switch ($Type) {
"info" { Write-Host "tChat >> " -ForegroundColor Cyan $Message }
"error" { Write-Host "tChat >> " -ForegroundColor Red $Message }
Default { Write-Host "tChat >> " -ForegroundColor Green $Message }
}
}
# ------------------------
# "Error Handling"
# ------------------------
$ErrorActionPreference = "Stop" # PowerShell's equivalent to 'set -e'
# ------------------------
# Check OS
# ------------------------
Write-ColoredOutput "info" "Checking OS..."
if (-not ($env:OS -eq "Windows_NT")) {
Write-ColoredOutput "error" "This script is primarily intended for Windows systems."
exit 1
}
# ------------------------
# Main Installation Logic
# ------------------------
Write-ColoredOutput "info" "Installing tchat..."
# Create installation directory if needed
if (-not (Test-Path $INSTALL_DIR)) {
New-Item -Path $INSTALL_DIR -ItemType Directory | Out-Null
}
# Download the binary (assuming there's a Windows-compatible asset)
Invoke-WebRequest -Uri ($RELEASE_URL + "/" + $ASSET_WINDOWS_AMD64) -OutFile "$INSTALL_DIR\tchat.exe"
Write-ColoredOutput "info" "Installation successful!"