-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstall-YAAC.ps1
More file actions
191 lines (159 loc) · 5.52 KB
/
Install-YAAC.ps1
File metadata and controls
191 lines (159 loc) · 5.52 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<#
.SYNOPSIS
Install YAAC (Yet Another APRS Client)
.DESCRIPTION
Downloads and installs latest YAAC from ka2ddo.org with optional pre-configuration
for callsign, position, and Direwolf integration.
.PARAMETER ConfigFile
Optional JSON configuration file with callsign and station settings
.EXAMPLE
.\Install-YAAC.ps1
Basic installation without pre-configuration
.EXAMPLE
.\Install-YAAC.ps1 -ConfigFile "EmComm-Config.json"
Install with pre-configured callsign and position
.NOTES
Requires Administrator privileges
Requires Java Runtime Environment (JRE)
Logs to C:\Logs\YAAC_Install_YYYYMMDD_HHMMSS.log
.INTUNE WIN32 APP DEPLOYMENT
Install command: powershell.exe -ExecutionPolicy Bypass -NoProfile -File "Install-YAAC.ps1"
Install behavior: System context
Detection: File exists %ProgramFiles%\YAAC\YAAC.jar
Return codes: 0=success, 1=failure
#>
# Requires -RunAsAdministrator
param(
[string]$ConfigFile
)
# Logging setup
$LogDir = "C:\Logs"
if (-not (Test-Path $LogDir)) {
New-Item -Path $LogDir -ItemType Directory -Force | Out-Null
}
$Timestamp = Get-Date -Format "yyyyMMdd_HHmmss"
$LogFile = "$LogDir\YAAC_Install_$Timestamp.log"
function Write-Log {
param(
[string]$Message,
[ValidateSet('INFO','WARNING','ERROR')]
[string]$Level = 'INFO'
)
$LogMessage = "{0} [{1}] {2}" -f (Get-Date -Format "yyyy-MM-dd HH:mm:ss"), $Level, $Message
Add-Content -Path $LogFile -Value $LogMessage
switch ($Level) {
'ERROR' { Write-Host $Message -ForegroundColor Red }
'WARNING' { Write-Host $Message -ForegroundColor Yellow }
default { Write-Host $Message }
}
}
Write-Log "Starting YAAC installation"
# Check if already installed
$YAACJar = "$env:ProgramFiles\YAAC\YAAC.jar"
if (Test-Path $YAACJar) {
Write-Log "YAAC already installed at: $YAACJar" -Level WARNING
Write-Log "To reinstall, delete the folder: $env:ProgramFiles\YAAC"
exit 0
}
# YAAC download URL
$YAACUrl = "https://www.ka2ddo.org/ka2ddo/YAAC.zip"
$InstallDir = "$env:ProgramFiles\YAAC"
$TempDir = "$env:TEMP\YAAC"
if (-not (Test-Path $TempDir)) {
New-Item -Path $TempDir -ItemType Directory -Force | Out-Null
}
# Load configuration if provided
$Config = $null
if ($ConfigFile -and (Test-Path $ConfigFile)) {
Write-Log "Loading configuration from $ConfigFile"
try {
$Config = Get-Content $ConfigFile -Raw | ConvertFrom-Json
Write-Log "Configuration loaded successfully"
}
catch {
Write-Log "Failed to load configuration: $_" -Level WARNING
}
}
# Check for Java
Write-Log "Checking for Java Runtime Environment"
try {
$JavaVersion = & java -version 2>&1 | Select-Object -First 1
Write-Log "Java found: $JavaVersion"
}
catch {
Write-Log "Java not found - YAAC requires JRE" -Level WARNING
Write-Log "Installing OpenJDK via winget"
try {
& winget install --id Microsoft.OpenJDK.21 --silent --accept-package-agreements --accept-source-agreements
Write-Log "OpenJDK installed successfully"
}
catch {
Write-Log "Failed to install Java - YAAC will not function without JRE" -Level ERROR
}
}
try {
Write-Log "Downloading YAAC from $YAACUrl"
$ZipPath = "$TempDir\YAAC.zip"
Invoke-WebRequest -Uri $YAACUrl -OutFile $ZipPath -ErrorAction Stop
Write-Log "Download completed: $ZipPath"
Write-Log "Extracting YAAC to $InstallDir"
if (Test-Path $InstallDir) {
Remove-Item -Path $InstallDir -Recurse -Force
}
Expand-Archive -Path $ZipPath -DestinationPath $InstallDir -Force
Write-Log "Extraction completed"
# Create desktop shortcut
$WshShell = New-Object -ComObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$env:Public\Desktop\YAAC.lnk")
$Shortcut.TargetPath = "javaw.exe"
$Shortcut.Arguments = "-jar `"$InstallDir\YAAC.jar`""
$Shortcut.WorkingDirectory = $InstallDir
$Shortcut.IconLocation = "$InstallDir\YAAC.ico"
$Shortcut.Save()
Write-Log "Desktop shortcut created"
}
catch {
Write-Log "Failed to install YAAC: $_" -Level ERROR
exit 1
}
# Pre-configure if config provided
if ($Config) {
Write-Log "Configuring YAAC settings"
$YAACConfigDir = "$env:USERPROFILE\.yaac"
if (-not (Test-Path $YAACConfigDir)) {
New-Item -Path $YAACConfigDir -ItemType Directory -Force | Out-Null
}
$CallSign = if ($Config.operator.callsign) { $Config.operator.callsign } else { "NOCALL" }
$Latitude = if ($Config.operator.latitude) { $Config.operator.latitude } else { "0.0" }
$Longitude = if ($Config.operator.longitude) { $Config.operator.longitude } else { "0.0" }
# Create YAAC properties file
$PropsContent = @"
# YAAC configuration generated by Install-YAAC.ps1
# $(Get-Date -Format "yyyy-MM-dd HH:mm:ss")
callsign=$CallSign
latitude=$Latitude
longitude=$Longitude
symbol=/[
symbolTable=\\
# Direwolf TNC configuration
port.0.type=KISS
port.0.device=localhost
port.0.port=8001
port.0.enabled=true
# APRS-IS configuration (disabled by default)
aprs-is.enabled=false
aprs-is.server=noam.aprs2.net
aprs-is.port=14580
# Beacon settings (disabled by default)
beacon.enabled=false
beacon.interval=30
"@
$PropsPath = "$YAACConfigDir\YAAC.properties"
Set-Content -Path $PropsPath -Value $PropsContent -Force
Write-Log "Configuration created at $PropsPath"
}
# Cleanup
Write-Log "Cleaning up temporary files"
Remove-Item -Path $TempDir -Recurse -Force -ErrorAction SilentlyContinue
Write-Log "YAAC installation completed successfully"
exit 0