lightman-agent 1.0.3 → 1.0.5
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/package.json +1 -1
- package/scripts/install-windows.ps1 +8 -7
- package/scripts/lightman-shell.bat +38 -21
- package/src/services/kiosk.ts +13 -11
package/package.json
CHANGED
|
@@ -137,13 +137,14 @@ Write-Host " Build successful"
|
|
|
137
137
|
Write-Host "[3/19] Creating directories..." -ForegroundColor Yellow
|
|
138
138
|
foreach ($d in @($InstallDir, $LogDir, $ChromeData, $NssmDir)) { New-Item -ItemType Directory -Force -Path $d | Out-Null }
|
|
139
139
|
|
|
140
|
-
# --- 4. Copy files ---
|
|
141
|
-
Write-Host "[4/19] Copying agent files..." -ForegroundColor Yellow
|
|
142
|
-
Copy-Item "$AgentDir\dist" "$InstallDir\dist" -Recurse -Force
|
|
143
|
-
Copy-Item "$AgentDir\package.json" "$InstallDir\package.json" -Force
|
|
144
|
-
if (Test-Path "$AgentDir\package-lock.json") { Copy-Item "$AgentDir\package-lock.json" "$InstallDir\package-lock.json" -Force }
|
|
145
|
-
Copy-Item "$AgentDir\agent.config.template.json" "$InstallDir\agent.config.template.json" -Force
|
|
146
|
-
if (Test-Path "$AgentDir\public") { Copy-Item "$AgentDir\public" "$InstallDir\public" -Recurse -Force }
|
|
140
|
+
# --- 4. Copy files ---
|
|
141
|
+
Write-Host "[4/19] Copying agent files..." -ForegroundColor Yellow
|
|
142
|
+
Copy-Item "$AgentDir\dist" "$InstallDir\dist" -Recurse -Force
|
|
143
|
+
Copy-Item "$AgentDir\package.json" "$InstallDir\package.json" -Force
|
|
144
|
+
if (Test-Path "$AgentDir\package-lock.json") { Copy-Item "$AgentDir\package-lock.json" "$InstallDir\package-lock.json" -Force }
|
|
145
|
+
Copy-Item "$AgentDir\agent.config.template.json" "$InstallDir\agent.config.template.json" -Force
|
|
146
|
+
if (Test-Path "$AgentDir\public") { Copy-Item "$AgentDir\public" "$InstallDir\public" -Recurse -Force }
|
|
147
|
+
if (Test-Path "$AgentDir\scripts") { Copy-Item "$AgentDir\scripts" "$InstallDir\scripts" -Recurse -Force }
|
|
147
148
|
|
|
148
149
|
# --- 5. Install deps ---
|
|
149
150
|
Write-Host "[5/19] Installing dependencies..." -ForegroundColor Yellow
|
|
@@ -13,10 +13,11 @@ REM 5. Launches Chrome fullscreen
|
|
|
13
13
|
REM 6. If Chrome crashes, relaunches in 3 seconds (infinite loop)
|
|
14
14
|
REM ================================================================
|
|
15
15
|
|
|
16
|
-
set INSTALL_DIR=C:\Program Files\Lightman\Agent
|
|
17
|
-
set CONFIG_FILE=%INSTALL_DIR%\agent.config.json
|
|
18
|
-
set
|
|
19
|
-
set
|
|
16
|
+
set INSTALL_DIR=C:\Program Files\Lightman\Agent
|
|
17
|
+
set CONFIG_FILE=%INSTALL_DIR%\agent.config.json
|
|
18
|
+
set URL_SIDECAR=C:\ProgramData\Lightman\kiosk-url.txt
|
|
19
|
+
set CHROME_DATA=C:\ProgramData\Lightman\chrome-kiosk
|
|
20
|
+
set LOG_FILE=C:\ProgramData\Lightman\logs\shell.log
|
|
20
21
|
|
|
21
22
|
REM Ensure directories exist
|
|
22
23
|
if not exist "C:\ProgramData\Lightman\logs" mkdir "C:\ProgramData\Lightman\logs"
|
|
@@ -59,14 +60,23 @@ if exist "%CONFIG_FILE%" (
|
|
|
59
60
|
|
|
60
61
|
:use_fallbacks
|
|
61
62
|
|
|
62
|
-
REM Build URL from slug (ALWAYS from config, never from sidecar)
|
|
63
|
-
if not "%DEVICE_SLUG%"=="" (
|
|
64
|
-
set URL=http://localhost:3403/display/%DEVICE_SLUG%
|
|
65
|
-
echo [%date% %time%] Slug: %DEVICE_SLUG% >> "%LOG_FILE%"
|
|
66
|
-
) else (
|
|
67
|
-
set URL=http://localhost:3403/display
|
|
68
|
-
echo [%date% %time%] WARNING: No slug in config! >> "%LOG_FILE%"
|
|
69
|
-
)
|
|
63
|
+
REM Build URL from slug (ALWAYS from config, never from sidecar)
|
|
64
|
+
if not "%DEVICE_SLUG%"=="" (
|
|
65
|
+
set URL=http://localhost:3403/display/%DEVICE_SLUG%
|
|
66
|
+
echo [%date% %time%] Slug: %DEVICE_SLUG% >> "%LOG_FILE%"
|
|
67
|
+
) else (
|
|
68
|
+
set URL=http://localhost:3403/display
|
|
69
|
+
echo [%date% %time%] WARNING: No slug in config! >> "%LOG_FILE%"
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
REM If agent wrote a URL sidecar (includes deviceId/apiKey), prefer it.
|
|
73
|
+
if exist "%URL_SIDECAR%" (
|
|
74
|
+
for /f "usebackq delims=" %%u in ("%URL_SIDECAR%") do set SIDE_URL=%%u
|
|
75
|
+
if not "%SIDE_URL%"=="" (
|
|
76
|
+
set URL=%SIDE_URL%
|
|
77
|
+
echo [%date% %time%] Using sidecar URL >> "%LOG_FILE%"
|
|
78
|
+
)
|
|
79
|
+
)
|
|
70
80
|
|
|
71
81
|
REM Fallback browser
|
|
72
82
|
if "%BROWSER%"=="" (
|
|
@@ -108,15 +118,22 @@ echo [%date% %time%] Agent ready >> "%LOG_FILE%"
|
|
|
108
118
|
REM ----------------------------------------------------------------
|
|
109
119
|
REM Infinite Chrome loop
|
|
110
120
|
REM ----------------------------------------------------------------
|
|
111
|
-
:loop
|
|
112
|
-
REM
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
)
|
|
121
|
+
:loop
|
|
122
|
+
REM Prefer sidecar URL for auth params/device routing; fallback to slug URL.
|
|
123
|
+
set SIDE_URL=
|
|
124
|
+
if exist "%URL_SIDECAR%" (
|
|
125
|
+
for /f "usebackq delims=" %%u in ("%URL_SIDECAR%") do set SIDE_URL=%%u
|
|
126
|
+
)
|
|
127
|
+
if not "%SIDE_URL%"=="" (
|
|
128
|
+
set URL=%SIDE_URL%
|
|
129
|
+
) else (
|
|
130
|
+
REM Re-read slug from config on every loop iteration.
|
|
131
|
+
if exist "%CONFIG_FILE%" (
|
|
132
|
+
for /f "delims=" %%a in ('node -e "try{console.log(JSON.parse(require('fs').readFileSync(String.raw`%CONFIG_FILE%`,'utf8')).deviceSlug)}catch(e){console.log('')}" 2^>nul') do (
|
|
133
|
+
if not "%%a"=="" set URL=http://localhost:3403/display/%%a
|
|
134
|
+
)
|
|
135
|
+
)
|
|
136
|
+
)
|
|
120
137
|
|
|
121
138
|
echo [%date% %time%] Launching Chrome: %URL% >> "%LOG_FILE%"
|
|
122
139
|
|
package/src/services/kiosk.ts
CHANGED
|
@@ -169,17 +169,19 @@ export class KioskManager {
|
|
|
169
169
|
// Shell Mode Methods
|
|
170
170
|
// =====================================================================
|
|
171
171
|
|
|
172
|
-
private async shellLaunch(targetUrl: string): Promise<KioskStatus> {
|
|
173
|
-
this.currentUrl = targetUrl;
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
//
|
|
178
|
-
if
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
this.
|
|
182
|
-
}
|
|
172
|
+
private async shellLaunch(targetUrl: string): Promise<KioskStatus> {
|
|
173
|
+
this.currentUrl = targetUrl;
|
|
174
|
+
// Keep shell sidecar updated so shell BAT can launch with auth query params.
|
|
175
|
+
this.writeUrlSidecar(targetUrl);
|
|
176
|
+
|
|
177
|
+
// Shell mode: Chrome is managed by lightman-shell.bat.
|
|
178
|
+
// Shell prefers sidecar URL (if present), then falls back to slug in config.
|
|
179
|
+
if (this.isChromeRunning()) {
|
|
180
|
+
this.logger.info('Shell mode: Chrome already running. Restarting once to apply sidecar URL.');
|
|
181
|
+
this.killAllChrome();
|
|
182
|
+
} else {
|
|
183
|
+
this.logger.info('Shell mode: Chrome not running. Shell BAT will launch it.');
|
|
184
|
+
}
|
|
183
185
|
|
|
184
186
|
this.startedAt = this.startedAt || Date.now();
|
|
185
187
|
return this.getStatus();
|