This repository has been archived by the owner on Sep 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Start-Gremlin-Server.ps1
53 lines (47 loc) · 2.31 KB
/
Start-Gremlin-Server.ps1
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
$gremlinServerUrl = 'https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.apache.tinkerpop&a=gremlin-server&e=zip&c=distribution&v=LATEST'
$workingDirectory = "C:/Gremlin.Net"
$gremlinServerArchive = "$workingDirectory/gremlin-server.zip"
Write-Output "Check if directory $workingDirectory exists..."
if(!(Test-Path -Path $workingDirectory)){
Write-Output "Directory doesn't exist, creating it now."
New-Item -ItemType Directory -Path $workingDirectory
}
else {
Write-Output "Directory exists, nothing to do."
}
Write-Output "Check if archive $gremlinServerArchive exists already..."
if (!(Test-Path $gremlinServerArchive)){
Write-Output "Archive doesn't exist, downloading it from $gremlinServerUrl"
Invoke-WebRequest -Uri $gremlinServerUrl -OutFile $gremlinServerArchive
Write-Output "Download finished."
}
else {
Write-Output "Archive exists, nothing to do."
}
Add-Type -assembly “system.io.compression.filesystem”
Write-Output "Check if an extracted version exists already..."
$zipArchive = [io.compression.zipfile]::OpenRead($gremlinServerArchive)
$archiveRootDirectory = $zipArchive.Entries[0]
$gremlinServerDirectory = "$workingDirectory/$archiveRootDirectory"
if (!(Test-Path -Path $gremlinServerDirectory))
{
Write-Output "No extracted version found, begin extracting..."
[io.compression.zipfile]::ExtractToDirectory($gremlinServerArchive, $workingDirectory)
Write-Output "Extraction finished."
}
else {
Write-Output "Found an extracted version, nothing to do here."
}
$gremlinServerStartFile = "bin/gremlin-server.bat"
Write-Output "Starting Gremlin Server from $gremlinServerStartFile"
Write-Output "Switching to directory $gremlinServerDirectory"
$currentDirectory = (Get-Item -Path ".\" -Verbose).FullName
Set-Location $gremlinServerDirectory
Start-Process $gremlinServerStartFile
Write-Output "Gremlin Server should now be running"
$gremlinServerSecureConf = "conf/gremlin-server-secure.yaml"
(Get-Content $gremlinServerSecureConf).Replace("8182", "8183").Replace("enabled: true}","enabled: false}") | Set-Content $gremlinServerSecureConf
Write-Output "Starting Secure Gremlin Server on Port 8183"
Start-Process $gremlinServerStartFile $gremlinServerSecureConf
Write-Output "Secure Gremlin Server should now be running"
Set-Location $currentDirectory