-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstall-Direwolf.ps1
More file actions
189 lines (152 loc) · 6 KB
/
Install-Direwolf.ps1
File metadata and controls
189 lines (152 loc) · 6 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
<#
.SYNOPSIS
Install Direwolf software TNC for APRS and packet radio
.DESCRIPTION
Downloads and installs latest Direwolf from GitHub releases with pre-configuration
for sound card devices and APRS settings.
.PARAMETER ConfigFile
Optional JSON configuration file with callsign, audio devices, and APRS settings
.EXAMPLE
.\Install-Direwolf.ps1
Basic installation without pre-configuration
.EXAMPLE
.\Install-Direwolf.ps1 -ConfigFile "EmComm-Config.json"
Install with pre-configured settings from JSON
.NOTES
Requires Administrator privileges
Logs to C:\Logs\Direwolf_Install_YYYYMMDD_HHMMSS.log
Creates default configuration at %USERPROFILE%\direwolf.conf
.INTUNE WIN32 APP DEPLOYMENT
Install command: powershell.exe -ExecutionPolicy Bypass -NoProfile -File "Install-Direwolf.ps1"
Install behavior: System context
Detection: File exists %ProgramFiles%\Direwolf\direwolf.exe
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\Direwolf_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 Direwolf installation"
# Check if already installed
$DirewolfExe = "$env:ProgramFiles\Direwolf\direwolf.exe"
$DirewolfExe86 = "${env:ProgramFiles(x86)}\Direwolf\direwolf.exe"
if ((Test-Path $DirewolfExe) -or (Test-Path $DirewolfExe86)) {
$installed = if (Test-Path $DirewolfExe) { $DirewolfExe } else { $DirewolfExe86 }
Write-Log "Direwolf already installed at: $installed" -Level WARNING
Write-Log "To reinstall, uninstall first or delete the installation folder"
exit 0
}
# GitHub API to get latest release
$GitHubAPI = "https://api.github.com/repos/wb2osz/direwolf/releases/latest"
$TempDir = "$env:TEMP\Direwolf"
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
}
}
try {
Write-Log "Fetching latest Direwolf release from GitHub"
$Release = Invoke-RestMethod -Uri $GitHubAPI -Headers @{ "User-Agent" = "PowerShell" } -ErrorAction Stop
$Version = $Release.tag_name
Write-Log "Latest version: $Version"
# Find Windows installer (usually .exe or .msi)
$Asset = $Release.assets | Where-Object { $_.name -match "win.*\.(exe|msi)$" } | Select-Object -First 1
if (-not $Asset) {
Write-Log "No Windows installer found in release assets" -Level ERROR
exit 1
}
$DownloadUrl = $Asset.browser_download_url
$InstallerName = $Asset.name
$InstallerPath = "$TempDir\$InstallerName"
Write-Log "Downloading Direwolf from $DownloadUrl"
Invoke-WebRequest -Uri $DownloadUrl -OutFile $InstallerPath -ErrorAction Stop
Write-Log "Download completed: $InstallerPath"
Write-Log "Installing Direwolf"
if ($InstallerName -match "\.msi$") {
$Process = Start-Process -FilePath "msiexec.exe" -ArgumentList "/i `"$InstallerPath`" /quiet /norestart" -Wait -PassThru -ErrorAction Stop
} else {
$Process = Start-Process -FilePath $InstallerPath -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART" -Wait -PassThru -ErrorAction Stop
}
if ($Process.ExitCode -eq 0) {
Write-Log "Direwolf installed successfully"
} else {
Write-Log "Direwolf installation returned exit code: $($Process.ExitCode)" -Level WARNING
}
}
catch {
Write-Log "Failed to install Direwolf: $_" -Level ERROR
exit 1
}
# Create default configuration file
Write-Log "Creating Direwolf configuration file"
$CallSign = if ($Config -and $Config.operator.callsign) { $Config.operator.callsign } else { "NOCALL" }
$AudioDevice = if ($Config -and $Config.audio.captureDevice) { $Config.audio.captureDevice } else { "0" }
$DirewolfConf = @"
# Direwolf configuration generated by Install-Direwolf.ps1
# $(Get-Date -Format "yyyy-MM-dd HH:mm:ss")
ADEVICE $AudioDevice
ACHANNELS 1
# Radio channel configuration
CHANNEL 0
MYCALL $CallSign
MODEM 1200
# PTT configuration - using VOX by default
# For CAT control, uncomment and configure:
# PTT COM1 RTS
# APRS Digipeater (disabled by default)
# DIGIPEAT 0 0 ^WIDE[3-7]-[1-7]$|^TEST$ ^WIDE[12]-[12]$ TRACE
# Internet Gateway (APRS-IS) - disabled by default
# Uncomment and configure to enable:
# IGSERVER noam.aprs2.net
# IGLOGIN $CallSign 12345
# Beaconing (disabled by default)
# PBEACON delay=1 every=30 overlay=S symbol="digi" lat=47.6062 long=-122.3321 comment="Direwolf TNC"
# Logging
LOGDIR C:\Logs\Direwolf
"@
$ConfPath = "$env:USERPROFILE\direwolf.conf"
Set-Content -Path $ConfPath -Value $DirewolfConf -Force
Write-Log "Configuration created at $ConfPath"
# Create log directory
$DirewolfLogDir = "C:\Logs\Direwolf"
if (-not (Test-Path $DirewolfLogDir)) {
New-Item -Path $DirewolfLogDir -ItemType Directory -Force | Out-Null
Write-Log "Created log directory: $DirewolfLogDir"
}
# Cleanup
Write-Log "Cleaning up temporary files"
Remove-Item -Path $TempDir -Recurse -Force -ErrorAction SilentlyContinue
Write-Log "Direwolf installation completed successfully"
Write-Log "Edit $ConfPath to customize settings"
exit 0