forked from membrane/api-gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservice-proxySSL.ps1
More file actions
68 lines (58 loc) · 2.03 KB
/
service-proxySSL.ps1
File metadata and controls
68 lines (58 loc) · 2.03 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
$required_version = "21"
function Start-MembraneService {
param([string]$membrane_home)
$CLASSPATH = "$membrane_home\conf;$membrane_home\lib\*"
Write-Host "Starting: $membrane_home CL: $CLASSPATH"
& java -cp "$CLASSPATH" com.predic8.membrane.core.cli.RouterCLI -c proxiesSSL.xml
}
function Find-MembraneDirectory {
param([string]$current)
while ($current -ne "") {
if ((Test-Path "$current\conf") -and (Test-Path "$current\lib")) {
return $current
}
$current = Split-Path -Parent $current
}
return $null
}
function Start-Membrane {
$membrane_home = Find-MembraneDirectory (Get-Location).Path
if ($membrane_home) {
Start-MembraneService $membrane_home
} else {
Write-Host "Could not start Membrane. Ensure the directory structure is correct."
}
}
try {
$null = Get-Command java -ErrorAction Stop
} catch {
Write-Host "Java is not installed. Membrane needs at least Java $required_version."
exit 1
}
try {
$version_output = & java -version 2>&1
$version_line = $version_output | Where-Object { $_ -match "version" } | Select-Object -First 1
if (-not $version_line) {
Write-Host "WARNING: Could not determine Java version. Make sure Java version is at least $required_version. Proceeding anyway..."
Start-Membrane
exit 0
}
$full_version = $version_line -replace '.*version "([^"]+)".*', '$1'
$current_version = $full_version -replace '\..*$', ''
if ($current_version -match '^\d+$') {
if ([int]$current_version -ge [int]$required_version) {
Start-Membrane
exit 0
} else {
Write-Host "Java version mismatch: Required=$required_version, Installed=$full_version"
exit 1
}
} else {
Write-Host "WARNING: Could not parse Java version. Make sure your Java version is at least $required_version. Proceeding anyway..."
Start-Membrane
exit 0
}
} catch {
Write-Host "Error checking Java version: $_"
exit 1
}