Advertisement
Guest User

Untitled

a guest
Feb 13th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.62 KB | None | 0 0
  1. $oAuth = 'enter oauth here'
  2.  
  3.  
  4. #$oAuth = $null
  5. $ntrid = $null
  6. $ntrhostname = $null
  7. $ntrusername = $null
  8. $ntrwinhostname = $null
  9. $headers = $null
  10. $body = $null
  11. $response = $null
  12. $uri = $null
  13. $password = $null
  14. $dir = $null
  15. $search = $null
  16. $page = $null
  17. $file = $null
  18. $url = $null
  19. $outfile = $null
  20.  
  21.  
  22. $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
  23. $headers.Add("Authorization", "Bearer $oAuth")
  24.  
  25. Function NtrGet
  26. {
  27. Param (
  28. $uri,
  29. $body = @{}
  30. )
  31.  
  32. $response = Invoke-RestMethod $uri -Method Get -Headers $headers -Body $body
  33. $response.data
  34. }
  35. Function NtrPost
  36. {
  37. Param (
  38. $uri,
  39. $body = @{}
  40. )
  41.  
  42. $response = Invoke-RestMethod $uri -Method Post -Headers $headers -Body $body
  43. $response
  44. }
  45. Function NtrUserDetails
  46. {
  47. (NtrGet "https://api.nitrado.net/user").user
  48. }
  49. Function NtrServiceList
  50. {
  51. (NtrGet "https://api.nitrado.net/services").services
  52. }
  53.  
  54. $ntrid = (NtrServiceList).id
  55. $ntrusername = (NtrServiceList).username
  56.  
  57. Function NtrServiceDetails
  58. {
  59. (NtrGet "https://api.nitrado.net/services/$ntrid").service
  60. }
  61. Function NtrServiceLogs
  62. {
  63. Param (
  64. [Parameter(Mandatory=$false)]$page = 1
  65. )
  66. $body = @{page=$page}
  67. (NtrGet "https://api.nitrado.net/services/$ntrid/logs" $body).logs
  68. }
  69. Function NtrServiceNotifications
  70. {
  71. Param (
  72. [Parameter(Mandatory=$false)]$include_dismissed = $false
  73. )
  74. $body = @{include_dismissed=$include_dismissed}
  75. (NtrGet "https://api.nitrado.net/services/$ntrid/notifications" $body).notifications
  76. }
  77. Function NtrGameserverDetails
  78. {
  79. (NtrGet "https://api.nitrado.net/services/$ntrid/gameservers").gameserver
  80. }
  81. $ntrhostname = (NtrGameserverDetails).hostsystems.linux.hostname
  82. $ntrwinhostname = (NtrGameserverDetails).hostsystems.windows.hostname
  83. Function NtrSetFtpPassword
  84. {
  85. Param (
  86. [Parameter(Mandatory=$true)]$password
  87. )
  88. $body = @{password=$password}
  89. (NtrPost "https://api.nitrado.net/services/$ntrid/gameservers/ftp/password" $body)
  90. }
  91. Function NtrFilesList
  92. {
  93. Param (
  94. [Parameter(Mandatory=$false)]$dir = $null,
  95. [Parameter(Mandatory=$false)]$search = $null
  96. )
  97. $body = @{dir=$dir;search=$search}
  98. (NtrGet "https://api.nitrado.net/services/$ntrid/gameservers/file_server/list" $body).entries
  99. }
  100. Function NtrFileDownload
  101. {
  102. Param (
  103. [Parameter(Mandatory=$true)]$file
  104. )
  105. $body = @{file=$file}
  106. $outfile = Split-Path $file -leaf
  107. $url = (NtrGet "https://api.nitrado.net/services/$ntrid/gameservers/file_server/download" $body).token.url
  108. Write-Host $file
  109. wget $url -outfile $outfile
  110. }
  111. Function NtrFileCopy
  112. {
  113. Param (
  114. $source_path,
  115. $target_path,
  116. $target_name
  117. )
  118. $body = @{source_path=$source_path;target_path=$target_path;target_name=$target_name}
  119. (NtrPost "https://api.nitrado.net/services/$ntrid/gameservers/file_server/copy" $body)
  120. }
  121. Function NtrDirDownload
  122. {
  123. Param (
  124. $path
  125. )
  126.  
  127. Write-Host $path
  128.  
  129. md (Split-Path $path -leaf) | out-null
  130. cd (Split-Path $path -leaf)
  131.  
  132. $list = (NtrFilesList $path)
  133. foreach ($file in $list | where {$_.type -eq "file"}){
  134. NtrFileDownload $file.path
  135. }
  136. foreach ($dir in $list | where {$_.type -eq "dir"}){
  137. NtrDirDownload $dir.path
  138. }
  139. cd ..
  140. }
  141. ##########################################
  142.  
  143. md \temp | out-null
  144. md \temp\ark-backup | out-null
  145. cd \temp\ark-backup | out-null
  146. $stamp = $(get-date -f yyyy-MM-dd_HH_mm_ss)
  147. md "Ark-Backup-$stamp" | out-null
  148. cd "Ark-Backup-$stamp" | out-null
  149. md Config | out-null
  150.  
  151. $sg = "/games/$ntrusername/noftp/arkxb/ShooterGame/Saved"
  152.  
  153. NtrDirDownload "$sg/SavedArks/"
  154. NtrDirDownload "$sg/Logs/"
  155.  
  156. cd Config
  157. NtrDirDownload "$sg/Config/WindowsServer/"
  158. cd ..
  159.  
  160. cd ..
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement