Make BPQ console station-independent with modem detection and Windows installer
This commit is contained in:
1 parent
5a50f0cfdf
commit
3bf26cec13
22 files changed
+285
-133
No files matched your search
+26
@@ -0,0 +1,26 @@
|
||||
param([string]$BpqRoot,[int]$Port=8090,[int]$HttpPort,[int]$RadioPort,[string]$SysopUser,[string]$ForwardPeer,[switch]$CheckOnly,[switch]$AutoStart,[switch]$EnableLAN)
|
||||
$ErrorActionPreference='Stop'
|
||||
$nodeExe=(Get-Command node.exe -ErrorAction Stop).Source
|
||||
$major=[int]((& $nodeExe --version).TrimStart('v').Split('.')[0])
|
||||
if($major -lt 20){throw 'Serve Node.js 20 o successivo nel PATH.'}
|
||||
if(!$BpqRoot){
|
||||
$candidates=@((Join-Path $env:APPDATA 'BPQ32'))
|
||||
$running=Get-CimInstance Win32_Process | Where-Object {$_.Name -match '^(BPQTerminal|BPQMail|BPQChat|bpq32)\.exe$'}
|
||||
foreach($proc in $running){if($proc.ExecutablePath){$candidates+=Split-Path $proc.ExecutablePath}}
|
||||
$BpqRoot=$candidates | Where-Object {Test-Path -LiteralPath (Join-Path $_ 'BPQ32.cfg')} | Select-Object -First 1
|
||||
if(!$BpqRoot){throw 'BPQ32.cfg non trovato. Usare -BpqRoot con la cartella dati BPQ.'}
|
||||
}
|
||||
$arguments=@((Join-Path $PSScriptRoot 'install.mjs'),'--bpq-root',$BpqRoot,'--port',"$Port")
|
||||
foreach($option in @(@('http-port',$HttpPort),@('radio-port',$RadioPort),@('sysop-user',$SysopUser),@('forward-peer',$ForwardPeer))){if($option[1]){$arguments+=@('--'+$option[0],"$($option[1])")}}
|
||||
if($CheckOnly){$arguments+='--check-only'}
|
||||
& $nodeExe @arguments
|
||||
if($LASTEXITCODE -ne 0){throw 'Installazione interrotta: verifica BPQ fallita.'}
|
||||
if($CheckOnly){return}
|
||||
if($AutoStart){
|
||||
$action=New-ScheduledTaskAction -Execute 'powershell.exe' -Argument ('-NoProfile -WindowStyle Hidden -File "'+(Join-Path $PSScriptRoot 'Start-Console.ps1')+'"') -WorkingDirectory $PSScriptRoot
|
||||
$trigger=New-ScheduledTaskTrigger -AtLogOn -User ([Security.Principal.WindowsIdentity]::GetCurrent().Name)
|
||||
Register-ScheduledTask -TaskName 'BPQ-WebConsole' -Action $action -Trigger $trigger -Description 'BPQ web console locale' -Force | Out-Null
|
||||
}
|
||||
if($EnableLAN){& (Join-Path $PSScriptRoot 'Enable-LAN.ps1')}
|
||||
& (Join-Path $PSScriptRoot 'Start-Console.ps1')
|
||||
Write-Host "Pannello: http://127.0.0.1:$Port"
|
||||
Reference in new issue
Block a user