depository-deploy 1.0.11 → 1.0.12
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/install/install-unix.sh +86 -6
- package/install/install-windows.ps1 +90 -7
- package/package.json +4 -4
- package/wizard-server.mjs +1 -1
package/install/install-unix.sh
CHANGED
|
@@ -92,6 +92,11 @@ eval "$(parse_conf)"
|
|
|
92
92
|
[ ${#JWT_SECRET} -ge 32 ] || error "JWT_SECRET must be at least 32 characters long"
|
|
93
93
|
[ -n "$DATA_DIR" ] || error "DATA_DIR is not set in depository.conf"
|
|
94
94
|
[ -n "$INSTALL_DIR" ] || error "INSTALL_DIR is not set in depository.conf"
|
|
95
|
+
[ -n "$API_PORT" ] || error "API_PORT is not set in depository.conf"
|
|
96
|
+
[ -n "$AUTH_PORT" ] || error "AUTH_PORT is not set in depository.conf"
|
|
97
|
+
[ -n "$GATHERER_PORT" ] || error "GATHERER_PORT is not set in depository.conf"
|
|
98
|
+
[ -n "$UI_PORT" ] || error "UI_PORT is not set in depository.conf"
|
|
99
|
+
[ -n "$SITE_URL" ] || error "SITE_URL is not set in depository.conf"
|
|
95
100
|
|
|
96
101
|
# ---- Build connection strings ----
|
|
97
102
|
if [ "$DB_PROVIDER" = "SqlServer" ]; then
|
|
@@ -186,10 +191,31 @@ fi
|
|
|
186
191
|
|
|
187
192
|
# ---- Create directories ----
|
|
188
193
|
info "Creating directories..."
|
|
189
|
-
mkdir -p "$INSTALL_DIR"/{api,auth,worker,gatherer,digestor,ui}
|
|
194
|
+
mkdir -p "$INSTALL_DIR"/{api,auth,worker,gatherer,digestor,ui,logs}
|
|
190
195
|
mkdir -p "$DATA_DIR"
|
|
191
196
|
chown -R depository:depository "$INSTALL_DIR" "$DATA_DIR"
|
|
192
197
|
|
|
198
|
+
# ---- Stop old services and kill remaining processes ----
|
|
199
|
+
info "Stopping existing services (if any)..."
|
|
200
|
+
for svc in depository-auth depository-api depository-worker depository-gatherer depository-digestor; do
|
|
201
|
+
if systemctl is-active --quiet "$svc" 2>/dev/null; then
|
|
202
|
+
systemctl stop "$svc" 2>/dev/null || true
|
|
203
|
+
info " Stopped: $svc"
|
|
204
|
+
fi
|
|
205
|
+
done
|
|
206
|
+
|
|
207
|
+
info "Killing any remaining Depository processes..."
|
|
208
|
+
for proc_name in DEPOSITORY.API.REST DEPOSITORY.API.OATH DEPOSITORY.CORE.WORKER DEPOSITORY.CORE.GATHERER DEPOSITORY.CORE.DIGESTOR; do
|
|
209
|
+
pids=$(pgrep -f "$proc_name" 2>/dev/null || true)
|
|
210
|
+
if [ -n "$pids" ]; then
|
|
211
|
+
echo "$pids" | while read -r pid; do
|
|
212
|
+
warn " Killing $proc_name (PID $pid)..."
|
|
213
|
+
kill -9 "$pid" 2>/dev/null || true
|
|
214
|
+
done
|
|
215
|
+
fi
|
|
216
|
+
done
|
|
217
|
+
sleep 2
|
|
218
|
+
|
|
193
219
|
# ---- Copy binaries ----
|
|
194
220
|
info "Copying service binaries..."
|
|
195
221
|
cp -r "$RELEASE_DIR/api/"* "$INSTALL_DIR/api/"
|
|
@@ -247,23 +273,77 @@ if command -v nginx &> /dev/null; then
|
|
|
247
273
|
nginx -t && systemctl reload nginx || warn "nginx config test failed — check /etc/nginx/sites-available/depository"
|
|
248
274
|
fi
|
|
249
275
|
|
|
276
|
+
# ---- Kill processes occupying service ports ----
|
|
277
|
+
kill_port_holder() {
|
|
278
|
+
local port="$1"
|
|
279
|
+
[ -z "$port" ] && return
|
|
280
|
+
local pids=""
|
|
281
|
+
if command -v fuser &>/dev/null; then
|
|
282
|
+
pids=$(fuser "$port/tcp" 2>/dev/null | xargs)
|
|
283
|
+
elif command -v lsof &>/dev/null; then
|
|
284
|
+
pids=$(lsof -ti "tcp:$port" 2>/dev/null | xargs)
|
|
285
|
+
fi
|
|
286
|
+
if [ -n "$pids" ]; then
|
|
287
|
+
warn "Port $port in use by PID(s): $pids -- killing..."
|
|
288
|
+
kill -9 $pids 2>/dev/null || true
|
|
289
|
+
sleep 1
|
|
290
|
+
fi
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
info "Checking for port conflicts..."
|
|
294
|
+
kill_port_holder "$API_PORT"
|
|
295
|
+
kill_port_holder "$AUTH_PORT"
|
|
296
|
+
kill_port_holder "$GATHERER_PORT"
|
|
297
|
+
|
|
250
298
|
# ---- Enable and start services ----
|
|
251
299
|
info "Enabling and starting services..."
|
|
252
300
|
systemctl daemon-reload
|
|
253
301
|
|
|
254
302
|
SERVICES="depository-auth depository-gatherer depository-api depository-worker depository-digestor"
|
|
303
|
+
START_FAILED=""
|
|
255
304
|
for svc in $SERVICES; do
|
|
256
|
-
systemctl enable "$svc"
|
|
257
|
-
systemctl restart "$svc"
|
|
258
|
-
|
|
305
|
+
systemctl enable "$svc" 2>/dev/null || true
|
|
306
|
+
if systemctl restart "$svc" 2>/dev/null; then
|
|
307
|
+
sleep 2
|
|
308
|
+
if systemctl is-active --quiet "$svc" 2>/dev/null; then
|
|
309
|
+
echo -e " ${GREEN}[OK]${NC} Started: $svc"
|
|
310
|
+
else
|
|
311
|
+
warn " FAILED to start: $svc (did not reach active state)"
|
|
312
|
+
warn " Run: journalctl -u $svc -n 30 --no-pager"
|
|
313
|
+
journalctl -u "$svc" -n 8 --no-pager 2>/dev/null | grep -iE 'error|fail|exception|unhandled|crit' | head -5 | while read -r line; do
|
|
314
|
+
warn " $line"
|
|
315
|
+
done
|
|
316
|
+
START_FAILED="$START_FAILED $svc"
|
|
317
|
+
fi
|
|
318
|
+
else
|
|
319
|
+
warn " FAILED to start: $svc"
|
|
320
|
+
warn " Run: journalctl -u $svc -n 30 --no-pager"
|
|
321
|
+
journalctl -u "$svc" -n 8 --no-pager 2>/dev/null | grep -iE 'error|fail|exception|unhandled|crit' | head -5 | while read -r line; do
|
|
322
|
+
warn " $line"
|
|
323
|
+
done
|
|
324
|
+
START_FAILED="$START_FAILED $svc"
|
|
325
|
+
fi
|
|
259
326
|
done
|
|
260
327
|
|
|
328
|
+
if [ -n "$START_FAILED" ]; then
|
|
329
|
+
warn ""
|
|
330
|
+
warn " Service(s) failed to start:$START_FAILED"
|
|
331
|
+
warn " Common causes:"
|
|
332
|
+
warn " - .NET 9 ASP.NET Core Runtime not installed (run: dotnet --list-runtimes)"
|
|
333
|
+
warn " - Invalid connection string in depository.conf"
|
|
334
|
+
warn " - Executable not found or not executable"
|
|
335
|
+
warn " The installer will continue -- fix the issue then run:"
|
|
336
|
+
warn " systemctl restart depository-auth depository-api depository-worker depository-gatherer depository-digestor"
|
|
337
|
+
warn ""
|
|
338
|
+
fi
|
|
339
|
+
|
|
261
340
|
# ---- Firewall rules (ufw) ----
|
|
262
341
|
if command -v ufw &> /dev/null && ufw status | grep -q "Status: active"; then
|
|
263
342
|
info "Opening firewall ports..."
|
|
264
343
|
ufw allow "$UI_PORT/tcp" comment "Depository UI"
|
|
265
344
|
ufw allow "$API_PORT/tcp" comment "Depository API"
|
|
266
345
|
ufw allow "$AUTH_PORT/tcp" comment "Depository Auth"
|
|
346
|
+
ufw allow "$GATHERER_PORT/tcp" comment "Depository Gatherer"
|
|
267
347
|
fi
|
|
268
348
|
|
|
269
349
|
# ---- Status check ----
|
|
@@ -294,6 +374,6 @@ fi
|
|
|
294
374
|
echo ""
|
|
295
375
|
echo " Useful commands:"
|
|
296
376
|
echo " View logs: journalctl -u depository-api -f"
|
|
297
|
-
echo " Restart all: systemctl restart depository-api depository-
|
|
298
|
-
echo " Status: systemctl status depository-api"
|
|
377
|
+
echo " Restart all: systemctl restart depository-auth depository-api depository-worker depository-gatherer depository-digestor"
|
|
378
|
+
echo " Status: systemctl status depository-auth depository-api depository-worker depository-gatherer depository-digestor"
|
|
299
379
|
echo ""
|
|
@@ -176,6 +176,23 @@ foreach ($svc in $services) {
|
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
+
# ---- Kill any remaining Depository processes ----
|
|
180
|
+
Write-Info "Killing any remaining Depository processes..."
|
|
181
|
+
$depositoryExes = @(
|
|
182
|
+
"DEPOSITORY.API.REST", "DEPOSITORY.API.OATH",
|
|
183
|
+
"DEPOSITORY.CORE.WORKER", "DEPOSITORY.CORE.GATHERER", "DEPOSITORY.CORE.DIGESTOR"
|
|
184
|
+
)
|
|
185
|
+
foreach ($exeName in $depositoryExes) {
|
|
186
|
+
$procs = Get-Process -Name $exeName -ErrorAction SilentlyContinue
|
|
187
|
+
if ($procs) {
|
|
188
|
+
$procs | ForEach-Object {
|
|
189
|
+
Write-Warn " Killing $($_.ProcessName) (PID $($_.Id))..."
|
|
190
|
+
Stop-Process -Id $_.Id -Force -ErrorAction SilentlyContinue
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
Start-Sleep -Seconds 2
|
|
195
|
+
|
|
179
196
|
# ---- Create directories ----
|
|
180
197
|
Write-Info "Creating directories..."
|
|
181
198
|
foreach ($sub in @("api","auth","worker","gatherer","digestor","ui","logs")) {
|
|
@@ -263,6 +280,33 @@ foreach ($name in $portMap.Keys) {
|
|
|
263
280
|
New-NetFirewallRule -DisplayName $name -Direction Inbound -Protocol TCP -LocalPort $port -Action Allow | Out-Null
|
|
264
281
|
}
|
|
265
282
|
|
|
283
|
+
# ---- Kill processes occupying service ports ----
|
|
284
|
+
function Kill-PortHolder {
|
|
285
|
+
param([int]$Port)
|
|
286
|
+
if ($Port -le 0) { return }
|
|
287
|
+
try {
|
|
288
|
+
$lines = netstat -ano | Select-String "LISTENING" | Select-String ":$Port\b"
|
|
289
|
+
foreach ($line in $lines) {
|
|
290
|
+
if ($line -match '\s+(\d+)\s*$') {
|
|
291
|
+
$pid = [int]$Matches[1]
|
|
292
|
+
if ($pid -gt 0) {
|
|
293
|
+
$proc = Get-Process -Id $pid -ErrorAction SilentlyContinue
|
|
294
|
+
if ($proc) {
|
|
295
|
+
Write-Warn " Port $Port in use by PID $pid ($($proc.ProcessName)) -- killing..."
|
|
296
|
+
Stop-Process -Id $pid -Force -ErrorAction SilentlyContinue
|
|
297
|
+
Start-Sleep -Seconds 1
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
} catch {}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
Write-Info "Checking for port conflicts..."
|
|
306
|
+
Kill-PortHolder ([int]$API_PORT)
|
|
307
|
+
Kill-PortHolder ([int]$AUTH_PORT)
|
|
308
|
+
Kill-PortHolder ([int]$GATHERER_PORT)
|
|
309
|
+
|
|
266
310
|
# ---- Start services ----
|
|
267
311
|
Write-Info "Starting services..."
|
|
268
312
|
$startFailed = @()
|
|
@@ -342,19 +386,58 @@ if ($WEBSERVER_TYPE -eq "iis") {
|
|
|
342
386
|
}
|
|
343
387
|
Write-OK "IIS features enabled"
|
|
344
388
|
|
|
345
|
-
#
|
|
389
|
+
# Auto-install IIS URL Rewrite module if missing
|
|
346
390
|
if (-not (Test-Path "$env:SystemRoot\System32\inetsrv\rewrite.dll")) {
|
|
347
|
-
Write-
|
|
348
|
-
|
|
349
|
-
|
|
391
|
+
Write-Info "IIS URL Rewrite module not found -- downloading and installing..."
|
|
392
|
+
$rewriteMsi = Join-Path $env:TEMP "urlrewrite2.msi"
|
|
393
|
+
try {
|
|
394
|
+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
|
395
|
+
Invoke-WebRequest -Uri "https://download.microsoft.com/download/1/2/8/128E2E22-C1B9-44A4-BE2A-5859ED1D4592/rewrite_amd64_en-US.msi" `
|
|
396
|
+
-OutFile $rewriteMsi -UseBasicParsing -ErrorAction Stop
|
|
397
|
+
$proc = Start-Process msiexec.exe -ArgumentList "/i `"$rewriteMsi`" /quiet /norestart" -Wait -PassThru -NoNewWindow
|
|
398
|
+
if ($proc.ExitCode -eq 0 -and (Test-Path "$env:SystemRoot\System32\inetsrv\rewrite.dll")) {
|
|
399
|
+
Write-OK "IIS URL Rewrite module installed"
|
|
400
|
+
} else {
|
|
401
|
+
Write-Warn "URL Rewrite installer exited with code $($proc.ExitCode)"
|
|
402
|
+
Write-Warn "Manual download: https://www.iis.net/downloads/microsoft/url-rewrite"
|
|
403
|
+
}
|
|
404
|
+
} catch {
|
|
405
|
+
Write-Warn "Failed to download URL Rewrite module: $_"
|
|
406
|
+
Write-Warn "Manual download: https://www.iis.net/downloads/microsoft/url-rewrite"
|
|
407
|
+
} finally {
|
|
408
|
+
Remove-Item $rewriteMsi -Force -ErrorAction SilentlyContinue
|
|
409
|
+
}
|
|
410
|
+
} else {
|
|
411
|
+
Write-OK "IIS URL Rewrite module present"
|
|
350
412
|
}
|
|
413
|
+
|
|
414
|
+
# Auto-install IIS Application Request Routing (ARR) if missing
|
|
351
415
|
$arrDll = Get-Item "$env:SystemRoot\System32\inetsrv\arr*.dll" -ErrorAction SilentlyContinue
|
|
352
416
|
if (-not $arrDll) {
|
|
353
|
-
Write-
|
|
354
|
-
|
|
417
|
+
Write-Info "IIS ARR module not found -- downloading and installing..."
|
|
418
|
+
$arrMsi = Join-Path $env:TEMP "arr3.msi"
|
|
419
|
+
try {
|
|
420
|
+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
|
421
|
+
Invoke-WebRequest -Uri "https://download.microsoft.com/download/E/9/8/E9849D6A-020E-47E4-9FD0-A023E99B54EB/requestRouter_amd64.msi" `
|
|
422
|
+
-OutFile $arrMsi -UseBasicParsing -ErrorAction Stop
|
|
423
|
+
$proc = Start-Process msiexec.exe -ArgumentList "/i `"$arrMsi`" /quiet /norestart" -Wait -PassThru -NoNewWindow
|
|
424
|
+
if ($proc.ExitCode -eq 0) {
|
|
425
|
+
Write-OK "IIS ARR module installed"
|
|
426
|
+
} else {
|
|
427
|
+
Write-Warn "ARR installer exited with code $($proc.ExitCode)"
|
|
428
|
+
Write-Warn "Manual download: https://www.iis.net/downloads/microsoft/application-request-routing"
|
|
429
|
+
}
|
|
430
|
+
} catch {
|
|
431
|
+
Write-Warn "Failed to download ARR module: $_"
|
|
432
|
+
Write-Warn "Manual download: https://www.iis.net/downloads/microsoft/application-request-routing"
|
|
433
|
+
} finally {
|
|
434
|
+
Remove-Item $arrMsi -Force -ErrorAction SilentlyContinue
|
|
435
|
+
}
|
|
436
|
+
} else {
|
|
437
|
+
Write-OK "IIS ARR module present"
|
|
355
438
|
}
|
|
356
439
|
|
|
357
|
-
# Enable ARR proxy
|
|
440
|
+
# Enable ARR proxy
|
|
358
441
|
try {
|
|
359
442
|
Set-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST" `
|
|
360
443
|
-filter "system.webServer/proxy" -name "enabled" -value $true -ErrorAction SilentlyContinue
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "depository-deploy",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"description": "Depository document management system – deployment wizard and installers",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"publishConfig": {
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"scripts/publish.mjs"
|
|
26
26
|
],
|
|
27
27
|
"optionalDependencies": {
|
|
28
|
-
"depository-deploy-linux": "1.0.
|
|
29
|
-
"depository-deploy-macos": "1.0.
|
|
30
|
-
"depository-deploy-windows": "1.0.
|
|
28
|
+
"depository-deploy-linux": "1.0.12",
|
|
29
|
+
"depository-deploy-macos": "1.0.12",
|
|
30
|
+
"depository-deploy-windows": "1.0.12"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"start": "node wizard-server.mjs"
|
package/wizard-server.mjs
CHANGED
|
@@ -157,7 +157,7 @@ const server = createServer((req, res) => {
|
|
|
157
157
|
const confLines = Object.entries(conf)
|
|
158
158
|
.map(([k, v]) => `${k}=${v}`)
|
|
159
159
|
.join('\n');
|
|
160
|
-
const confPath = join(
|
|
160
|
+
const confPath = join(__dirname, 'depository.conf');
|
|
161
161
|
writeFileSync(confPath, confLines, 'utf8');
|
|
162
162
|
|
|
163
163
|
// Determine install script
|