-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.ps1
More file actions
100 lines (84 loc) · 3.76 KB
/
Copy pathinstall.ps1
File metadata and controls
100 lines (84 loc) · 3.76 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
90
91
92
93
94
95
96
97
98
99
100
#Requires -RunAsAdministrator
# --- OS Detection ---
$IsWindows = $env:OS -match "Windows_NT"
$IsMacOS = (uname) -eq "Darwin"
$IsLinux = (!$IsWindows -and !$IsMacOS)
Write-Host "Detected OS: $(if ($IsWindows) {'Windows'} elseif ($IsMacOS) {'macOS'} else {'Linux'})" -ForegroundColor Cyan
# --- Version Configuration ---
$SupportedVersions = @("7.8.4", "7.9.3", "7.10.0")
$LatestVersion = $SupportedVersions[-1] # Get last element
$PythonVersion = "3.12.2" # Fixed Python version for compatibility
# --- Windows Setup ---
if ($IsWindows) {
try {
Write-Host "Starting Windows Setup..."
# Python
Write-Host "Downloading Python $PythonVersion..."
$pythonUrl = "https://www.python.org/ftp/python/$PythonVersion/python-$PythonVersion-amd64.exe"
$pythonInstaller = "$env:TEMP\python.exe"
Invoke-WebRequest -Uri $pythonUrl -OutFile $pythonInstaller -ErrorAction Stop
Write-Host "Installing Python..."
Start-Process -FilePath $pythonInstaller -ArgumentList "/quiet InstallAllUsers=1 PrependPath=1" -Wait -ErrorAction Stop
Remove-Item $pythonInstaller -ErrorAction SilentlyContinue
# Sejda
foreach ($version in $SupportedVersions) {
Write-Host "Installing Sejda PDF Desktop v$version..."
$sejdaUrl = "https://downloads.sejda.com/sejda-desktop_$version_windows.exe"
$sejdaInstaller = "$env:TEMP\sejda-$version.exe"
Invoke-WebRequest -Uri $sejdaUrl -OutFile $sejdaInstaller -ErrorAction Stop
Start-Process -FilePath $sejdaInstaller -ArgumentList "/S" -Wait -ErrorAction Stop
Remove-Item $sejdaInstaller -ErrorAction SilentlyContinue
}
}
catch {
Write-Error "Windows installation failed: $_"
exit 1
}
}
# --- macOS Setup (via Homebrew) ---
elseif ($IsMacOS) {
try {
Write-Host "Starting macOS Setup..."
if (!(Get-Command brew -ErrorAction SilentlyContinue)) {
Write-Error "Homebrew is not installed. Please install Homebrew first."
exit 1
}
Write-Host "Installing Python $PythonVersion..."
Start-Process brew -ArgumentList "install python@$PythonVersion" -Wait -NoNewWindow
Write-Host "Installing Sejda PDF..."
Start-Process brew -ArgumentList "install --cask sejda-pdf" -Wait -NoNewWindow
}
catch {
Write-Error "macOS installation failed: $_"
exit 1
}
}
# --- Linux Setup (Debian/Ubuntu based) ---
elseif ($IsLinux) {
try {
Write-Host "Starting Linux Setup..."
# Check for sudo
if ((Measure-Command { sudo -n true } 2>&1).ToString() -ne "") {
Write-Warning "Sudo password may be required."
}
# Python
Write-Host "Installing Python $PythonVersion..."
Start-Process sudo -ArgumentList "apt-get update" -Wait -NoNewWindow
Start-Process sudo -ArgumentList "apt-get install -y python3 python3-pip" -Wait -NoNewWindow
# Sejda
foreach ($version in $SupportedVersions) {
Write-Host "Installing Sejda PDF Desktop v$version..."
$sejdaUrl = "https://downloads.sejda.com/sejda-desktop_$version_linux_amd64.deb"
$sejdaInstaller = "/tmp/sejda-$version.deb"
Invoke-WebRequest -Uri $sejdaUrl -OutFile $sejdaInstaller -ErrorAction Stop
Start-Process sudo -ArgumentList "dpkg -i $sejdaInstaller" -Wait -NoNewWindow
Start-Process sudo -ArgumentList "apt-get install -f -y" -Wait -NoNewWindow # Fix dependencies
Remove-Item $sejdaInstaller -ErrorAction SilentlyContinue
}
}
catch {
Write-Error "Linux installation failed: $_"
exit 1
}
}
Write-Host "Setup completed successfully." -ForegroundColor Green