-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathpode_server.ps1
55 lines (51 loc) · 2.09 KB
/
pode_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
54
55
Start-PodeServer {
$config = (gc config.json) | ConvertFrom-Json
Add-PodeEndpoint -Address localhost -Port $config.server.webport -Protocol Http
$chunk = {
param($config)
SSM monitor $($config.server.serverfile) -Verbose -disableclearvariable
start-sleep 3
If ((Get-Process "$process" -ea SilentlyContinue)) {
Write-PodeJsonResponse -Value @{ status = "started" } -StatusCode 302
}Else{
Write-PodeJsonResponse -Value @{ status = 'failed' } -StatusCode 303
}
}
Add-PodeRoute -Method Get -Path "/monitor" -ScriptBlock $chunk -ArgumentList $config
$chunk2 = {
param($config)
SSM stop $config.server.serverfile -Verbose -disableclearvariable
start-sleep 3
If (!($p = (Get-Process "$process" -ea SilentlyContinue))) {
Write-PodeJsonResponse -Value @{ status = 'stopped' } -StatusCode 304
}Else{
Write-PodeJsonResponse -Value @{ status = 'failed' } -StatusCode 305
}
}
Add-PodeRoute -Method Get -Path '/stop' -ScriptBlock $chunk2 -ArgumentList $config
$chunk2 = {
param($config)
SSM query $config.server.serverfile -Verbose -disableclearvariable
start-sleep 3
If ($status) {
Write-PodeJsonResponse -Value @{ status = "$status" } -StatusCode 304
}Else{
Write-PodeJsonResponse -Value @{ status = 'failed' } -StatusCode 305
}
}
Add-PodeRoute -Method Get -Path '/query' -ScriptBlock $chunk2 -ArgumentList $config
$chunk2 = {
param($config)
SSM details $config.server.serverfile -Verbose -disableclearvariable
start-sleep 3
If ($botdetails) {
Write-PodeJsonResponse -Value @{
status = $botdetails
} -StatusCode 304
}Else{
Write-PodeJsonResponse -Value @{ status = 'failed' } -StatusCode 305
}
}
Add-PodeRoute -Method Get -Path '/details' -ScriptBlock $chunk2 -ArgumentList $config
}
#https://discordapp.com/oauth2/authorize?client_id=<bot id here>&scope=bot