lightman-agent 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent.config.template.json +30 -30
- package/package.json +52 -52
- package/public/assets/index-CcBNCz6h.css +1 -1
- package/public/assets/index-D9QHMG8k.js +1 -0
- package/public/assets/index-H-8HDl46.js +1 -1
- package/public/assets/index-YodeiCia.css +1 -0
- package/public/assets/index-legacy-DWtNM8y7.js +41 -0
- package/public/assets/museum-map-CwVDA2z1.svg +4182 -0
- package/public/assets/polyfills-legacy-DyVYWHbW.js +4 -0
- package/public/index.html +7 -2
- package/public/templates/custom08/elements/back-button.svg +20 -0
- package/public/templates/custom08/elements/base-map-background.svg +37 -0
- package/public/templates/custom08/elements/base-map.svg +1191 -0
- package/public/templates/custom08/elements/gallery-1-2-3-info-panel.svg +236 -0
- package/public/templates/custom08/elements/gallery-4-5-6-7-info-panel.svg +266 -0
- package/public/templates/custom08/elements/gallery-8-9-info-panel.svg +274 -0
- package/public/templates/custom08/elements/gallery-labels/_nav-map-styles.css +554 -0
- package/public/templates/custom08/elements/gallery-labels/_styles.css +556 -0
- package/public/templates/custom08/elements/gallery-labels/gallery-1.svg +35 -0
- package/public/templates/custom08/elements/gallery-labels/gallery-2.svg +34 -0
- package/public/templates/custom08/elements/gallery-labels/gallery-3.svg +34 -0
- package/public/templates/custom08/elements/gallery-labels/gallery-4.svg +37 -0
- package/public/templates/custom08/elements/gallery-labels/gallery-5.svg +34 -0
- package/public/templates/custom08/elements/gallery-labels/gallery-6.svg +34 -0
- package/public/templates/custom08/elements/gallery-labels/gallery-7.svg +34 -0
- package/public/templates/custom08/elements/gallery-labels/gallery-8.svg +37 -0
- package/public/templates/custom08/elements/gallery-labels/gallery-9.svg +34 -0
- package/public/templates/custom08/elements/hand-hint.png +0 -0
- package/public/templates/custom08/elements/idle-screen-bg.svg +5 -0
- package/public/templates/custom08/elements/idle-screen-map.svg +627 -0
- package/public/templates/custom08/elements/idle-screen-text.svg +350 -0
- package/public/templates/custom08/elements/key-map-1.svg +986 -0
- package/public/templates/custom08/elements/key-map-2.svg +1018 -0
- package/public/templates/custom08/elements/key-map-3.svg +1019 -0
- package/public/templates/custom08/elements/key-map-combined.svg +1001 -0
- package/public/templates/custom08/elements/map-highlight-marker.svg +11 -0
- package/public/templates/custom08/elements/map-pin-marker.svg +15 -0
- package/public/templates/custom08/elements/map-teardrop-star-marker.svg +13 -0
- package/public/templates/custom08/elements/nav-circle-galleries-1-3.svg +21 -0
- package/public/templates/custom08/elements/nav-circle-galleries-4-7.svg +24 -0
- package/public/templates/custom08/elements/nav-circle-galleries-8-9.svg +20 -0
- package/public/templates/custom08/elements/section1-map.svg +1435 -0
- package/public/templates/custom08/elements/section2-map.svg +1724 -0
- package/public/templates/custom08/elements/section3-map.svg +1295 -0
- package/public/templates/custom08/fonts/CabinetGrotesk-Variable.ttf +0 -0
- package/public/templates/custom08/images/highlights/Screenshot_2026-03-05_at_7.23.12_PM.png +0 -0
- package/public/templates/custom08/images/highlights/Screenshot_2026-03-05_at_7.23.56_PM.png +0 -0
- package/public/templates/custom08/images/highlights/Screenshot_2026-03-05_at_7.24.24_PM.png +0 -0
- package/public/templates/custom08/images/highlights/Screenshot_2026-03-24_at_11.31.58_PM.jpg +0 -0
- package/public/templates/custom08/images/highlights/Screenshot_2026-03-24_at_11.32.11_PM.jpg +0 -0
- package/public/templates/custom08/images/highlights/Screenshot_2026-03-24_at_11.32.36_PM.jpg +0 -0
- package/public/templates/custom08/images/highlights/Screenshot_2026-03-24_at_11.32.48_PM.jpg +0 -0
- package/public/templates/custom08/images/highlights/Screenshot_2026-03-24_at_11.32.59_PM.jpg +0 -0
- package/public/templates/custom08/images/highlights/Screenshot_2026-03-24_at_11.33.15_PM.jpg +0 -0
- package/public/templates/custom08/images/highlights/Screenshot_2026-03-24_at_11.33.27_PM.jpg +0 -0
- package/public/templates/custom08/images/highlights/Screenshot_2026-03-24_at_11.33.34_PM.jpg +0 -0
- package/public/templates/custom08/images/highlights/Screenshot_2026-03-24_at_11.33.42_PM.jpg +0 -0
- package/public/templates/custom08/images/highlights/Screenshot_2026-03-24_at_11.33.50_PM.jpg +0 -0
- package/public/templates/custom08/images/highlights/Screenshot_2026-03-24_at_11.33.58_PM.jpg +0 -0
- package/public/templates/custom08/images/highlights/Screenshot_2026-03-24_at_11.34.04_PM.jpg +0 -0
- package/public/templates/custom08/images/highlights/Screenshot_2026-03-24_at_11.34.11_PM.jpg +0 -0
- package/public/templates/custom08/images/highlights/Screenshot_2026-03-24_at_11.34.20_PM.jpg +0 -0
- package/public/templates/custom08/images/highlights/Screenshot_2026-03-24_at_11.34.57_PM.jpg +0 -0
- package/public/templates/custom08/images/highlights/Screenshot_2026-03-24_at_11.35.03_PM.jpg +0 -0
- package/public/templates/custom08/images/highlights/Screenshot_2026-03-24_at_11.35.16_PM.jpg +0 -0
- package/public/templates/custom08/images/highlights/Screenshot_2026-03-24_at_11.35.23_PM.jpg +0 -0
- package/public/templates/custom08/images/highlights/prologue-highlight.png +0 -0
- package/scripts/guardian.ps1 +75 -75
- package/scripts/install-linux.sh +134 -134
- package/scripts/install-rpi.sh +117 -117
- package/scripts/install-windows.ps1 +505 -505
- package/scripts/launch-kiosk.vbs +101 -101
- package/scripts/lightman-agent.logrotate +12 -12
- package/scripts/lightman-agent.service +38 -38
- package/scripts/lightman-shell.bat +107 -107
- package/scripts/reinstall-windows.ps1 +26 -26
- package/scripts/restore-desktop.ps1 +32 -32
- package/scripts/setup.ps1 +116 -116
- package/scripts/setup.sh +115 -115
- package/scripts/sync-display.mjs +20 -0
- package/scripts/uninstall-linux.sh +50 -50
- package/scripts/uninstall-windows.ps1 +54 -54
- package/src/commands/display.ts +177 -177
- package/src/commands/kiosk.ts +113 -113
- package/src/commands/maintenance.ts +106 -106
- package/src/commands/network.ts +129 -129
- package/src/commands/power.ts +163 -163
- package/src/commands/rpi.ts +45 -45
- package/src/commands/screenshot.ts +166 -166
- package/src/commands/serial.ts +17 -17
- package/src/commands/update.ts +124 -124
- package/src/index.ts +652 -652
- package/src/lib/config.ts +69 -69
- package/src/lib/identity.ts +40 -40
- package/src/lib/logger.ts +137 -137
- package/src/lib/platform.ts +10 -10
- package/src/lib/rpi.ts +180 -180
- package/src/lib/screens.ts +128 -128
- package/src/lib/types.ts +176 -176
- package/src/services/commands.ts +107 -107
- package/src/services/health.ts +161 -161
- package/src/services/kiosk.ts +384 -384
- package/src/services/localEvents.ts +60 -60
- package/src/services/logForwarder.ts +72 -72
- package/src/services/multiScreenKiosk.ts +324 -324
- package/src/services/oscBridge.ts +186 -186
- package/src/services/powerScheduler.ts +260 -260
- package/src/services/provisioning.ts +120 -120
- package/src/services/serialBridge.ts +230 -230
- package/src/services/serviceLauncher.ts +183 -183
- package/src/services/staticServer.ts +226 -226
- package/src/services/updater.ts +249 -249
- package/src/services/watchdog.ts +310 -310
- package/src/services/websocket.ts +152 -152
- package/tsconfig.json +28 -28
package/scripts/setup.ps1
CHANGED
|
@@ -1,116 +1,116 @@
|
|
|
1
|
-
# LIGHTMAN Agent - Device Setup Script (Windows)
|
|
2
|
-
# Generates agent.config.json for this specific device.
|
|
3
|
-
#
|
|
4
|
-
# Usage (run from agent directory or scripts directory):
|
|
5
|
-
# powershell -ExecutionPolicy Bypass -File setup.ps1 -Slug "f-av01" -Server "http://192.168.1.100:3401"
|
|
6
|
-
# powershell -ExecutionPolicy Bypass -File setup.ps1 -Slug "f-av01" -Server "http://192.168.1.100:3401" -Timezone "Asia/Kolkata"
|
|
7
|
-
#
|
|
8
|
-
# This script MUST be run once on every new device installation.
|
|
9
|
-
# It clears any cached identity so the device provisions fresh.
|
|
10
|
-
|
|
11
|
-
param(
|
|
12
|
-
[Parameter(Mandatory=$true)]
|
|
13
|
-
[string]$Slug,
|
|
14
|
-
|
|
15
|
-
[Parameter(Mandatory=$true)]
|
|
16
|
-
[string]$Server,
|
|
17
|
-
|
|
18
|
-
[Parameter(Mandatory=$false)]
|
|
19
|
-
[string]$Timezone = "Asia/Kolkata",
|
|
20
|
-
|
|
21
|
-
[Parameter(Mandatory=$false)]
|
|
22
|
-
[string]$InstallDir = $null,
|
|
23
|
-
|
|
24
|
-
[Parameter(Mandatory=$false)]
|
|
25
|
-
[switch]$ShellMode = $false
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
$ErrorActionPreference = "Stop"
|
|
29
|
-
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
30
|
-
$AgentDir = Split-Path -Parent $ScriptDir
|
|
31
|
-
|
|
32
|
-
# Default install dir: the agent folder itself (for dev) or passed explicitly
|
|
33
|
-
if (-not $InstallDir) {
|
|
34
|
-
$InstallDir = $AgentDir
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
Write-Host ""
|
|
38
|
-
Write-Host "=== LIGHTMAN Agent - Device Setup ===" -ForegroundColor Cyan
|
|
39
|
-
Write-Host " Slug: $Slug"
|
|
40
|
-
Write-Host " Server: $Server"
|
|
41
|
-
Write-Host " Install dir: $InstallDir"
|
|
42
|
-
Write-Host " Timezone: $Timezone"
|
|
43
|
-
Write-Host ""
|
|
44
|
-
|
|
45
|
-
# 1. Clear cached identity (CRITICAL - prevents old device credentials leaking)
|
|
46
|
-
$IdentityFile = Join-Path $InstallDir ".lightman-identity.json"
|
|
47
|
-
if (Test-Path $IdentityFile) {
|
|
48
|
-
Remove-Item $IdentityFile -Force
|
|
49
|
-
Write-Host "[OK] Cleared old identity cache (.lightman-identity.json)" -ForegroundColor Green
|
|
50
|
-
} else {
|
|
51
|
-
Write-Host "[OK] No existing identity cache found (clean install)" -ForegroundColor DarkGray
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
# 2. Kiosk display URL - always localhost since agent runs the static server locally on port 3403
|
|
55
|
-
$KioskUrl = "http://localhost:3403/display/$Slug"
|
|
56
|
-
|
|
57
|
-
# 3. Detect browser path
|
|
58
|
-
$BrowserPath = "C:\Program Files\Google\Chrome\Application\chrome.exe"
|
|
59
|
-
if (-not (Test-Path $BrowserPath)) {
|
|
60
|
-
$BrowserPath = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
|
|
61
|
-
}
|
|
62
|
-
if (-not (Test-Path $BrowserPath)) {
|
|
63
|
-
$BrowserPath = "chromium-browser"
|
|
64
|
-
Write-Host "[WARN] Chrome not found - using 'chromium-browser'" -ForegroundColor Yellow
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
$ChromeDataDir = "C:\ProgramData\Lightman\chrome-kiosk"
|
|
68
|
-
|
|
69
|
-
# 4. Read template
|
|
70
|
-
$TemplatePath = Join-Path $AgentDir "agent.config.template.json"
|
|
71
|
-
if (-not (Test-Path $TemplatePath)) {
|
|
72
|
-
# If running from install dir (post-install), template should have been copied there
|
|
73
|
-
$TemplatePath = Join-Path $InstallDir "agent.config.template.json"
|
|
74
|
-
}
|
|
75
|
-
if (-not (Test-Path $TemplatePath)) {
|
|
76
|
-
Write-Host "[ERROR] Template not found. Expected: $TemplatePath" -ForegroundColor Red
|
|
77
|
-
exit 1
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
$Template = Get-Content $TemplatePath -Raw
|
|
81
|
-
|
|
82
|
-
# 5. Replace placeholders
|
|
83
|
-
$BrowserEscaped = $BrowserPath -replace '\\', '\\'
|
|
84
|
-
$ChromeDirEscaped = $ChromeDataDir -replace '\\', '\\'
|
|
85
|
-
|
|
86
|
-
$Config = $Template `
|
|
87
|
-
-replace '__SERVER_URL__', $Server `
|
|
88
|
-
-replace '__DEVICE_SLUG__', $Slug `
|
|
89
|
-
-replace '__KIOSK_URL__', $KioskUrl `
|
|
90
|
-
-replace '__BROWSER_PATH__', $BrowserEscaped `
|
|
91
|
-
-replace '__CHROME_DATA_DIR__', $ChromeDirEscaped `
|
|
92
|
-
-replace 'Asia/Kolkata', $Timezone
|
|
93
|
-
|
|
94
|
-
# 6. Inject shellMode into kiosk config if requested
|
|
95
|
-
if ($ShellMode) {
|
|
96
|
-
# Parse as object, set shellMode, re-serialize (reliable, no regex fragility)
|
|
97
|
-
$configObj = $Config | ConvertFrom-Json
|
|
98
|
-
$configObj.kiosk | Add-Member -NotePropertyName "shellMode" -NotePropertyValue $true -Force
|
|
99
|
-
$Config = $configObj | ConvertTo-Json -Depth 4
|
|
100
|
-
Write-Host "[OK] Shell replacement mode enabled in config" -ForegroundColor Magenta
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
# 7. Write config
|
|
104
|
-
$ConfigPath = Join-Path $InstallDir "agent.config.json"
|
|
105
|
-
# Write as UTF-8 WITHOUT BOM (BOM breaks JSON parsing in Node.js)
|
|
106
|
-
[System.IO.File]::WriteAllText($ConfigPath, $Config, [System.Text.UTF8Encoding]::new($false))
|
|
107
|
-
|
|
108
|
-
Write-Host "[OK] Created agent.config.json" -ForegroundColor Green
|
|
109
|
-
Write-Host ""
|
|
110
|
-
Write-Host " Device slug : $Slug"
|
|
111
|
-
Write-Host " Server : $Server"
|
|
112
|
-
Write-Host " Kiosk URL : $KioskUrl"
|
|
113
|
-
Write-Host ""
|
|
114
|
-
Write-Host "Setup complete. Start the agent - it will provision automatically." -ForegroundColor Cyan
|
|
115
|
-
Write-Host "(If IP matches, provisioning is instant. Otherwise enter pairing code shown in admin.)" -ForegroundColor DarkGray
|
|
116
|
-
Write-Host ""
|
|
1
|
+
# LIGHTMAN Agent - Device Setup Script (Windows)
|
|
2
|
+
# Generates agent.config.json for this specific device.
|
|
3
|
+
#
|
|
4
|
+
# Usage (run from agent directory or scripts directory):
|
|
5
|
+
# powershell -ExecutionPolicy Bypass -File setup.ps1 -Slug "f-av01" -Server "http://192.168.1.100:3401"
|
|
6
|
+
# powershell -ExecutionPolicy Bypass -File setup.ps1 -Slug "f-av01" -Server "http://192.168.1.100:3401" -Timezone "Asia/Kolkata"
|
|
7
|
+
#
|
|
8
|
+
# This script MUST be run once on every new device installation.
|
|
9
|
+
# It clears any cached identity so the device provisions fresh.
|
|
10
|
+
|
|
11
|
+
param(
|
|
12
|
+
[Parameter(Mandatory=$true)]
|
|
13
|
+
[string]$Slug,
|
|
14
|
+
|
|
15
|
+
[Parameter(Mandatory=$true)]
|
|
16
|
+
[string]$Server,
|
|
17
|
+
|
|
18
|
+
[Parameter(Mandatory=$false)]
|
|
19
|
+
[string]$Timezone = "Asia/Kolkata",
|
|
20
|
+
|
|
21
|
+
[Parameter(Mandatory=$false)]
|
|
22
|
+
[string]$InstallDir = $null,
|
|
23
|
+
|
|
24
|
+
[Parameter(Mandatory=$false)]
|
|
25
|
+
[switch]$ShellMode = $false
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
$ErrorActionPreference = "Stop"
|
|
29
|
+
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
30
|
+
$AgentDir = Split-Path -Parent $ScriptDir
|
|
31
|
+
|
|
32
|
+
# Default install dir: the agent folder itself (for dev) or passed explicitly
|
|
33
|
+
if (-not $InstallDir) {
|
|
34
|
+
$InstallDir = $AgentDir
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
Write-Host ""
|
|
38
|
+
Write-Host "=== LIGHTMAN Agent - Device Setup ===" -ForegroundColor Cyan
|
|
39
|
+
Write-Host " Slug: $Slug"
|
|
40
|
+
Write-Host " Server: $Server"
|
|
41
|
+
Write-Host " Install dir: $InstallDir"
|
|
42
|
+
Write-Host " Timezone: $Timezone"
|
|
43
|
+
Write-Host ""
|
|
44
|
+
|
|
45
|
+
# 1. Clear cached identity (CRITICAL - prevents old device credentials leaking)
|
|
46
|
+
$IdentityFile = Join-Path $InstallDir ".lightman-identity.json"
|
|
47
|
+
if (Test-Path $IdentityFile) {
|
|
48
|
+
Remove-Item $IdentityFile -Force
|
|
49
|
+
Write-Host "[OK] Cleared old identity cache (.lightman-identity.json)" -ForegroundColor Green
|
|
50
|
+
} else {
|
|
51
|
+
Write-Host "[OK] No existing identity cache found (clean install)" -ForegroundColor DarkGray
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
# 2. Kiosk display URL - always localhost since agent runs the static server locally on port 3403
|
|
55
|
+
$KioskUrl = "http://localhost:3403/display/$Slug"
|
|
56
|
+
|
|
57
|
+
# 3. Detect browser path
|
|
58
|
+
$BrowserPath = "C:\Program Files\Google\Chrome\Application\chrome.exe"
|
|
59
|
+
if (-not (Test-Path $BrowserPath)) {
|
|
60
|
+
$BrowserPath = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
|
|
61
|
+
}
|
|
62
|
+
if (-not (Test-Path $BrowserPath)) {
|
|
63
|
+
$BrowserPath = "chromium-browser"
|
|
64
|
+
Write-Host "[WARN] Chrome not found - using 'chromium-browser'" -ForegroundColor Yellow
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
$ChromeDataDir = "C:\ProgramData\Lightman\chrome-kiosk"
|
|
68
|
+
|
|
69
|
+
# 4. Read template
|
|
70
|
+
$TemplatePath = Join-Path $AgentDir "agent.config.template.json"
|
|
71
|
+
if (-not (Test-Path $TemplatePath)) {
|
|
72
|
+
# If running from install dir (post-install), template should have been copied there
|
|
73
|
+
$TemplatePath = Join-Path $InstallDir "agent.config.template.json"
|
|
74
|
+
}
|
|
75
|
+
if (-not (Test-Path $TemplatePath)) {
|
|
76
|
+
Write-Host "[ERROR] Template not found. Expected: $TemplatePath" -ForegroundColor Red
|
|
77
|
+
exit 1
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
$Template = Get-Content $TemplatePath -Raw
|
|
81
|
+
|
|
82
|
+
# 5. Replace placeholders
|
|
83
|
+
$BrowserEscaped = $BrowserPath -replace '\\', '\\'
|
|
84
|
+
$ChromeDirEscaped = $ChromeDataDir -replace '\\', '\\'
|
|
85
|
+
|
|
86
|
+
$Config = $Template `
|
|
87
|
+
-replace '__SERVER_URL__', $Server `
|
|
88
|
+
-replace '__DEVICE_SLUG__', $Slug `
|
|
89
|
+
-replace '__KIOSK_URL__', $KioskUrl `
|
|
90
|
+
-replace '__BROWSER_PATH__', $BrowserEscaped `
|
|
91
|
+
-replace '__CHROME_DATA_DIR__', $ChromeDirEscaped `
|
|
92
|
+
-replace 'Asia/Kolkata', $Timezone
|
|
93
|
+
|
|
94
|
+
# 6. Inject shellMode into kiosk config if requested
|
|
95
|
+
if ($ShellMode) {
|
|
96
|
+
# Parse as object, set shellMode, re-serialize (reliable, no regex fragility)
|
|
97
|
+
$configObj = $Config | ConvertFrom-Json
|
|
98
|
+
$configObj.kiosk | Add-Member -NotePropertyName "shellMode" -NotePropertyValue $true -Force
|
|
99
|
+
$Config = $configObj | ConvertTo-Json -Depth 4
|
|
100
|
+
Write-Host "[OK] Shell replacement mode enabled in config" -ForegroundColor Magenta
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
# 7. Write config
|
|
104
|
+
$ConfigPath = Join-Path $InstallDir "agent.config.json"
|
|
105
|
+
# Write as UTF-8 WITHOUT BOM (BOM breaks JSON parsing in Node.js)
|
|
106
|
+
[System.IO.File]::WriteAllText($ConfigPath, $Config, [System.Text.UTF8Encoding]::new($false))
|
|
107
|
+
|
|
108
|
+
Write-Host "[OK] Created agent.config.json" -ForegroundColor Green
|
|
109
|
+
Write-Host ""
|
|
110
|
+
Write-Host " Device slug : $Slug"
|
|
111
|
+
Write-Host " Server : $Server"
|
|
112
|
+
Write-Host " Kiosk URL : $KioskUrl"
|
|
113
|
+
Write-Host ""
|
|
114
|
+
Write-Host "Setup complete. Start the agent - it will provision automatically." -ForegroundColor Cyan
|
|
115
|
+
Write-Host "(If IP matches, provisioning is instant. Otherwise enter pairing code shown in admin.)" -ForegroundColor DarkGray
|
|
116
|
+
Write-Host ""
|
package/scripts/setup.sh
CHANGED
|
@@ -1,115 +1,115 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# LIGHTMAN Agent — Device Setup Script (Linux / Raspberry Pi)
|
|
3
|
-
# Generates agent.config.json for this specific device.
|
|
4
|
-
#
|
|
5
|
-
# Usage:
|
|
6
|
-
# sudo bash setup.sh --slug f-av01 --server http://192.168.1.100:3401
|
|
7
|
-
# sudo bash setup.sh --slug f-av01 --server http://192.168.1.100:3401 --timezone Asia/Kolkata --dir /opt/lightman/agent
|
|
8
|
-
#
|
|
9
|
-
# This script MUST be run once on every new device installation.
|
|
10
|
-
# It clears any cached identity so the device provisions fresh.
|
|
11
|
-
|
|
12
|
-
set -euo pipefail
|
|
13
|
-
|
|
14
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
15
|
-
AGENT_DIR="$(dirname "$SCRIPT_DIR")"
|
|
16
|
-
|
|
17
|
-
# Defaults
|
|
18
|
-
SLUG=""
|
|
19
|
-
SERVER=""
|
|
20
|
-
TIMEZONE="Asia/Kolkata"
|
|
21
|
-
INSTALL_DIR="/opt/lightman/agent"
|
|
22
|
-
|
|
23
|
-
# ── Parse arguments ──
|
|
24
|
-
while [[ $# -gt 0 ]]; do
|
|
25
|
-
case $1 in
|
|
26
|
-
--slug) SLUG="$2"; shift 2 ;;
|
|
27
|
-
--server) SERVER="$2"; shift 2 ;;
|
|
28
|
-
--timezone) TIMEZONE="$2"; shift 2 ;;
|
|
29
|
-
--dir) INSTALL_DIR="$2"; shift 2 ;;
|
|
30
|
-
-h|--help)
|
|
31
|
-
echo "Usage: bash setup.sh --slug SLUG --server http://SERVER:3401 [--timezone TZ] [--dir /path]"
|
|
32
|
-
exit 0
|
|
33
|
-
;;
|
|
34
|
-
*) echo "Unknown option: $1"; exit 1 ;;
|
|
35
|
-
esac
|
|
36
|
-
done
|
|
37
|
-
|
|
38
|
-
if [[ -z "$SLUG" ]]; then
|
|
39
|
-
echo "Error: --slug is required"
|
|
40
|
-
echo "Usage: bash setup.sh --slug f-av01 --server http://192.168.1.100:3401"
|
|
41
|
-
exit 1
|
|
42
|
-
fi
|
|
43
|
-
|
|
44
|
-
if [[ -z "$SERVER" ]]; then
|
|
45
|
-
echo "Error: --server is required"
|
|
46
|
-
echo "Usage: bash setup.sh --slug f-av01 --server http://192.168.1.100:3401"
|
|
47
|
-
exit 1
|
|
48
|
-
fi
|
|
49
|
-
|
|
50
|
-
echo ""
|
|
51
|
-
echo "=== LIGHTMAN Agent — Device Setup ==="
|
|
52
|
-
echo " Slug: $SLUG"
|
|
53
|
-
echo " Server: $SERVER"
|
|
54
|
-
echo " Install dir: $INSTALL_DIR"
|
|
55
|
-
echo " Timezone: $TIMEZONE"
|
|
56
|
-
echo ""
|
|
57
|
-
|
|
58
|
-
# ── 1. Clear cached identity (CRITICAL — prevents old device credentials leaking) ──
|
|
59
|
-
IDENTITY_FILE="$INSTALL_DIR/.lightman-identity.json"
|
|
60
|
-
if [[ -f "$IDENTITY_FILE" ]]; then
|
|
61
|
-
rm -f "$IDENTITY_FILE"
|
|
62
|
-
echo "[OK] Cleared old identity cache (.lightman-identity.json)"
|
|
63
|
-
else
|
|
64
|
-
echo "[OK] No existing identity cache found (clean install)"
|
|
65
|
-
fi
|
|
66
|
-
|
|
67
|
-
# ── 2. Derive kiosk display URL from server URL ──
|
|
68
|
-
# Replace port with 3403 (display server)
|
|
69
|
-
KIOSK_BASE="$(echo "$SERVER" | sed 's/:[0-9]*$//')"
|
|
70
|
-
KIOSK_URL="${KIOSK_BASE}:3403/display/${SLUG}"
|
|
71
|
-
|
|
72
|
-
# ── 3. Detect browser ──
|
|
73
|
-
BROWSER_PATH="chromium-browser"
|
|
74
|
-
if command -v chromium &>/dev/null; then
|
|
75
|
-
BROWSER_PATH="chromium"
|
|
76
|
-
elif command -v chromium-browser &>/dev/null; then
|
|
77
|
-
BROWSER_PATH="chromium-browser"
|
|
78
|
-
elif command -v google-chrome &>/dev/null; then
|
|
79
|
-
BROWSER_PATH="google-chrome"
|
|
80
|
-
fi
|
|
81
|
-
CHROME_DATA_DIR="/opt/lightman/chrome-kiosk"
|
|
82
|
-
|
|
83
|
-
# ── 4. Find template ──
|
|
84
|
-
TEMPLATE="$AGENT_DIR/agent.config.template.json"
|
|
85
|
-
if [[ ! -f "$TEMPLATE" ]]; then
|
|
86
|
-
# Post-install: template may be in install dir
|
|
87
|
-
TEMPLATE="$INSTALL_DIR/agent.config.template.json"
|
|
88
|
-
fi
|
|
89
|
-
if [[ ! -f "$TEMPLATE" ]]; then
|
|
90
|
-
echo "[ERROR] Template not found at $TEMPLATE"
|
|
91
|
-
exit 1
|
|
92
|
-
fi
|
|
93
|
-
|
|
94
|
-
# ── 5. Create install dir if needed ──
|
|
95
|
-
mkdir -p "$INSTALL_DIR"
|
|
96
|
-
|
|
97
|
-
# ── 6. Replace placeholders and write config ──
|
|
98
|
-
sed \
|
|
99
|
-
-e "s|__SERVER_URL__|${SERVER}|g" \
|
|
100
|
-
-e "s|__DEVICE_SLUG__|${SLUG}|g" \
|
|
101
|
-
-e "s|__KIOSK_URL__|${KIOSK_URL}|g" \
|
|
102
|
-
-e "s|__BROWSER_PATH__|${BROWSER_PATH}|g" \
|
|
103
|
-
-e "s|__CHROME_DATA_DIR__|${CHROME_DATA_DIR}|g" \
|
|
104
|
-
-e "s|Asia/Kolkata|${TIMEZONE}|g" \
|
|
105
|
-
"$TEMPLATE" > "$INSTALL_DIR/agent.config.json"
|
|
106
|
-
|
|
107
|
-
echo "[OK] Created agent.config.json"
|
|
108
|
-
echo ""
|
|
109
|
-
echo " Device slug : $SLUG"
|
|
110
|
-
echo " Server : $SERVER"
|
|
111
|
-
echo " Kiosk URL : $KIOSK_URL"
|
|
112
|
-
echo ""
|
|
113
|
-
echo "Setup complete. Start the agent — it will provision automatically."
|
|
114
|
-
echo "(If IP matches, provisioning is instant. Otherwise enter pairing code shown in admin.)"
|
|
115
|
-
echo ""
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# LIGHTMAN Agent — Device Setup Script (Linux / Raspberry Pi)
|
|
3
|
+
# Generates agent.config.json for this specific device.
|
|
4
|
+
#
|
|
5
|
+
# Usage:
|
|
6
|
+
# sudo bash setup.sh --slug f-av01 --server http://192.168.1.100:3401
|
|
7
|
+
# sudo bash setup.sh --slug f-av01 --server http://192.168.1.100:3401 --timezone Asia/Kolkata --dir /opt/lightman/agent
|
|
8
|
+
#
|
|
9
|
+
# This script MUST be run once on every new device installation.
|
|
10
|
+
# It clears any cached identity so the device provisions fresh.
|
|
11
|
+
|
|
12
|
+
set -euo pipefail
|
|
13
|
+
|
|
14
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
15
|
+
AGENT_DIR="$(dirname "$SCRIPT_DIR")"
|
|
16
|
+
|
|
17
|
+
# Defaults
|
|
18
|
+
SLUG=""
|
|
19
|
+
SERVER=""
|
|
20
|
+
TIMEZONE="Asia/Kolkata"
|
|
21
|
+
INSTALL_DIR="/opt/lightman/agent"
|
|
22
|
+
|
|
23
|
+
# ── Parse arguments ──
|
|
24
|
+
while [[ $# -gt 0 ]]; do
|
|
25
|
+
case $1 in
|
|
26
|
+
--slug) SLUG="$2"; shift 2 ;;
|
|
27
|
+
--server) SERVER="$2"; shift 2 ;;
|
|
28
|
+
--timezone) TIMEZONE="$2"; shift 2 ;;
|
|
29
|
+
--dir) INSTALL_DIR="$2"; shift 2 ;;
|
|
30
|
+
-h|--help)
|
|
31
|
+
echo "Usage: bash setup.sh --slug SLUG --server http://SERVER:3401 [--timezone TZ] [--dir /path]"
|
|
32
|
+
exit 0
|
|
33
|
+
;;
|
|
34
|
+
*) echo "Unknown option: $1"; exit 1 ;;
|
|
35
|
+
esac
|
|
36
|
+
done
|
|
37
|
+
|
|
38
|
+
if [[ -z "$SLUG" ]]; then
|
|
39
|
+
echo "Error: --slug is required"
|
|
40
|
+
echo "Usage: bash setup.sh --slug f-av01 --server http://192.168.1.100:3401"
|
|
41
|
+
exit 1
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
if [[ -z "$SERVER" ]]; then
|
|
45
|
+
echo "Error: --server is required"
|
|
46
|
+
echo "Usage: bash setup.sh --slug f-av01 --server http://192.168.1.100:3401"
|
|
47
|
+
exit 1
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
echo ""
|
|
51
|
+
echo "=== LIGHTMAN Agent — Device Setup ==="
|
|
52
|
+
echo " Slug: $SLUG"
|
|
53
|
+
echo " Server: $SERVER"
|
|
54
|
+
echo " Install dir: $INSTALL_DIR"
|
|
55
|
+
echo " Timezone: $TIMEZONE"
|
|
56
|
+
echo ""
|
|
57
|
+
|
|
58
|
+
# ── 1. Clear cached identity (CRITICAL — prevents old device credentials leaking) ──
|
|
59
|
+
IDENTITY_FILE="$INSTALL_DIR/.lightman-identity.json"
|
|
60
|
+
if [[ -f "$IDENTITY_FILE" ]]; then
|
|
61
|
+
rm -f "$IDENTITY_FILE"
|
|
62
|
+
echo "[OK] Cleared old identity cache (.lightman-identity.json)"
|
|
63
|
+
else
|
|
64
|
+
echo "[OK] No existing identity cache found (clean install)"
|
|
65
|
+
fi
|
|
66
|
+
|
|
67
|
+
# ── 2. Derive kiosk display URL from server URL ──
|
|
68
|
+
# Replace port with 3403 (display server)
|
|
69
|
+
KIOSK_BASE="$(echo "$SERVER" | sed 's/:[0-9]*$//')"
|
|
70
|
+
KIOSK_URL="${KIOSK_BASE}:3403/display/${SLUG}"
|
|
71
|
+
|
|
72
|
+
# ── 3. Detect browser ──
|
|
73
|
+
BROWSER_PATH="chromium-browser"
|
|
74
|
+
if command -v chromium &>/dev/null; then
|
|
75
|
+
BROWSER_PATH="chromium"
|
|
76
|
+
elif command -v chromium-browser &>/dev/null; then
|
|
77
|
+
BROWSER_PATH="chromium-browser"
|
|
78
|
+
elif command -v google-chrome &>/dev/null; then
|
|
79
|
+
BROWSER_PATH="google-chrome"
|
|
80
|
+
fi
|
|
81
|
+
CHROME_DATA_DIR="/opt/lightman/chrome-kiosk"
|
|
82
|
+
|
|
83
|
+
# ── 4. Find template ──
|
|
84
|
+
TEMPLATE="$AGENT_DIR/agent.config.template.json"
|
|
85
|
+
if [[ ! -f "$TEMPLATE" ]]; then
|
|
86
|
+
# Post-install: template may be in install dir
|
|
87
|
+
TEMPLATE="$INSTALL_DIR/agent.config.template.json"
|
|
88
|
+
fi
|
|
89
|
+
if [[ ! -f "$TEMPLATE" ]]; then
|
|
90
|
+
echo "[ERROR] Template not found at $TEMPLATE"
|
|
91
|
+
exit 1
|
|
92
|
+
fi
|
|
93
|
+
|
|
94
|
+
# ── 5. Create install dir if needed ──
|
|
95
|
+
mkdir -p "$INSTALL_DIR"
|
|
96
|
+
|
|
97
|
+
# ── 6. Replace placeholders and write config ──
|
|
98
|
+
sed \
|
|
99
|
+
-e "s|__SERVER_URL__|${SERVER}|g" \
|
|
100
|
+
-e "s|__DEVICE_SLUG__|${SLUG}|g" \
|
|
101
|
+
-e "s|__KIOSK_URL__|${KIOSK_URL}|g" \
|
|
102
|
+
-e "s|__BROWSER_PATH__|${BROWSER_PATH}|g" \
|
|
103
|
+
-e "s|__CHROME_DATA_DIR__|${CHROME_DATA_DIR}|g" \
|
|
104
|
+
-e "s|Asia/Kolkata|${TIMEZONE}|g" \
|
|
105
|
+
"$TEMPLATE" > "$INSTALL_DIR/agent.config.json"
|
|
106
|
+
|
|
107
|
+
echo "[OK] Created agent.config.json"
|
|
108
|
+
echo ""
|
|
109
|
+
echo " Device slug : $SLUG"
|
|
110
|
+
echo " Server : $SERVER"
|
|
111
|
+
echo " Kiosk URL : $KIOSK_URL"
|
|
112
|
+
echo ""
|
|
113
|
+
echo "Setup complete. Start the agent — it will provision automatically."
|
|
114
|
+
echo "(If IP matches, provisioning is instant. Otherwise enter pairing code shown in admin.)"
|
|
115
|
+
echo ""
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { cpSync, existsSync, mkdirSync } from 'node:fs';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
|
|
4
|
+
const rootDir = resolve(import.meta.dirname, '..');
|
|
5
|
+
const displayDistDir = resolve(rootDir, '..', 'display', 'dist');
|
|
6
|
+
const agentPublicDir = resolve(rootDir, 'public');
|
|
7
|
+
|
|
8
|
+
if (!existsSync(displayDistDir)) {
|
|
9
|
+
console.error(`Display build not found: ${displayDistDir}`);
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
mkdirSync(agentPublicDir, { recursive: true });
|
|
14
|
+
|
|
15
|
+
cpSync(displayDistDir, agentPublicDir, {
|
|
16
|
+
recursive: true,
|
|
17
|
+
force: true,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
console.log('Display synced to agent/public/');
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# LIGHTMAN Agent — Linux Uninstaller
|
|
3
|
-
# Run as root: sudo bash uninstall-linux.sh
|
|
4
|
-
set -euo pipefail
|
|
5
|
-
|
|
6
|
-
INSTALL_DIR="/opt/lightman/agent"
|
|
7
|
-
LOG_DIR="/var/log/lightman"
|
|
8
|
-
SERVICE_NAME="lightman-agent"
|
|
9
|
-
|
|
10
|
-
if [[ $EUID -ne 0 ]]; then
|
|
11
|
-
echo "Error: This script must be run as root (use sudo)."
|
|
12
|
-
exit 1
|
|
13
|
-
fi
|
|
14
|
-
|
|
15
|
-
echo "=== LIGHTMAN Agent — Linux Uninstaller ==="
|
|
16
|
-
echo ""
|
|
17
|
-
|
|
18
|
-
# --- Stop and disable service ---
|
|
19
|
-
echo "[1/5] Stopping service..."
|
|
20
|
-
systemctl stop "$SERVICE_NAME" 2>/dev/null || true
|
|
21
|
-
systemctl disable "$SERVICE_NAME" 2>/dev/null || true
|
|
22
|
-
|
|
23
|
-
# --- Remove systemd unit ---
|
|
24
|
-
echo "[2/5] Removing systemd unit..."
|
|
25
|
-
rm -f "/etc/systemd/system/${SERVICE_NAME}.service"
|
|
26
|
-
systemctl daemon-reload
|
|
27
|
-
|
|
28
|
-
# --- Remove logrotate config ---
|
|
29
|
-
echo "[3/5] Removing logrotate config..."
|
|
30
|
-
rm -f "/etc/logrotate.d/${SERVICE_NAME}"
|
|
31
|
-
|
|
32
|
-
# --- Remove installation directory ---
|
|
33
|
-
echo "[4/5] Removing ${INSTALL_DIR}..."
|
|
34
|
-
rm -rf "$INSTALL_DIR"
|
|
35
|
-
|
|
36
|
-
# --- Remove log directory ---
|
|
37
|
-
echo "[5/5] Removing ${LOG_DIR}..."
|
|
38
|
-
rm -rf "$LOG_DIR"
|
|
39
|
-
|
|
40
|
-
# --- Remove user/group (optional) ---
|
|
41
|
-
read -rp "Remove 'lightman' user and group? [y/N]: " REMOVE_USER
|
|
42
|
-
if [[ "$REMOVE_USER" =~ ^[Yy]$ ]]; then
|
|
43
|
-
userdel lightman 2>/dev/null || true
|
|
44
|
-
groupdel lightman 2>/dev/null || true
|
|
45
|
-
echo "User and group removed."
|
|
46
|
-
fi
|
|
47
|
-
|
|
48
|
-
echo ""
|
|
49
|
-
echo "=== Uninstallation Complete ==="
|
|
50
|
-
echo ""
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# LIGHTMAN Agent — Linux Uninstaller
|
|
3
|
+
# Run as root: sudo bash uninstall-linux.sh
|
|
4
|
+
set -euo pipefail
|
|
5
|
+
|
|
6
|
+
INSTALL_DIR="/opt/lightman/agent"
|
|
7
|
+
LOG_DIR="/var/log/lightman"
|
|
8
|
+
SERVICE_NAME="lightman-agent"
|
|
9
|
+
|
|
10
|
+
if [[ $EUID -ne 0 ]]; then
|
|
11
|
+
echo "Error: This script must be run as root (use sudo)."
|
|
12
|
+
exit 1
|
|
13
|
+
fi
|
|
14
|
+
|
|
15
|
+
echo "=== LIGHTMAN Agent — Linux Uninstaller ==="
|
|
16
|
+
echo ""
|
|
17
|
+
|
|
18
|
+
# --- Stop and disable service ---
|
|
19
|
+
echo "[1/5] Stopping service..."
|
|
20
|
+
systemctl stop "$SERVICE_NAME" 2>/dev/null || true
|
|
21
|
+
systemctl disable "$SERVICE_NAME" 2>/dev/null || true
|
|
22
|
+
|
|
23
|
+
# --- Remove systemd unit ---
|
|
24
|
+
echo "[2/5] Removing systemd unit..."
|
|
25
|
+
rm -f "/etc/systemd/system/${SERVICE_NAME}.service"
|
|
26
|
+
systemctl daemon-reload
|
|
27
|
+
|
|
28
|
+
# --- Remove logrotate config ---
|
|
29
|
+
echo "[3/5] Removing logrotate config..."
|
|
30
|
+
rm -f "/etc/logrotate.d/${SERVICE_NAME}"
|
|
31
|
+
|
|
32
|
+
# --- Remove installation directory ---
|
|
33
|
+
echo "[4/5] Removing ${INSTALL_DIR}..."
|
|
34
|
+
rm -rf "$INSTALL_DIR"
|
|
35
|
+
|
|
36
|
+
# --- Remove log directory ---
|
|
37
|
+
echo "[5/5] Removing ${LOG_DIR}..."
|
|
38
|
+
rm -rf "$LOG_DIR"
|
|
39
|
+
|
|
40
|
+
# --- Remove user/group (optional) ---
|
|
41
|
+
read -rp "Remove 'lightman' user and group? [y/N]: " REMOVE_USER
|
|
42
|
+
if [[ "$REMOVE_USER" =~ ^[Yy]$ ]]; then
|
|
43
|
+
userdel lightman 2>/dev/null || true
|
|
44
|
+
groupdel lightman 2>/dev/null || true
|
|
45
|
+
echo "User and group removed."
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
echo ""
|
|
49
|
+
echo "=== Uninstallation Complete ==="
|
|
50
|
+
echo ""
|