Advertisement
Guest User

Untitled

a guest
Apr 16th, 2024
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. import clr
  2. clr.AddReference('System.IO.Compression.FileSystem')
  3. clr.AddReference("TCAdmin.SDK")
  4. clr.AddReference("TCAdmin.Interfaces")
  5. clr.AddReference("TCAdmin.GameHosting.SDK")
  6. from System import Environment, PlatformID
  7. from System.IO import Directory, File
  8. from TCAdmin.SDK.Misc import WebClient
  9. from TCAdmin.SDK.Misc import CompressionTools
  10. from TCAdmin.Interfaces.Server import ServiceStatus
  11. from TCAdmin.GameHosting.SDK.Objects import Service
  12.  
  13. #Check if run as a scheduled task. We check if ThisTaskStep.WriteLog is callable. If it is, set WriteLog = ThisTaskStep.WriteLog. If it isn't, set WriteLog = WriteLog.
  14. try:
  15. ThisTaskStep.WriteLog
  16. except NameError:
  17. WriteLog = Script.WriteToConsole
  18. else:
  19. WriteLog = ThisTaskStep.WriteLog
  20.  
  21. c=CompressionTools()
  22. WriteLog('Checking if Carbon is installed...')
  23. # Check if Carbon is installed
  24. if Directory.Exists(ThisService.RootDirectory + 'Carbon'):
  25. if File.Exists(ThisService.RootDirectory + 'Carbon.Rust.zip'):
  26. File.Delete(ThisService.RootDirectory + 'Carbon.Rust.zip')
  27.  
  28. WriteLog('Found carbon installation... Updating Carbon.')
  29. url = 'https://github.com/CarbonCommunity/Carbon/releases/download/production_build/Carbon.Windows.Release.zip' if Environment.OSVersion.Platform == PlatformID.Win32NT else 'https://github.com/CarbonCommunity/Carbon/releases/download/production_build/Carbon.Linux.Release.tar.gz'
  30.  
  31. #Need to rename file here to "Carbon.Rust.zip"
  32.  
  33. if ThisService.Variables['branch'] == 'staging':
  34. WriteLog('Staging branch detected')
  35. url = 'https://github.com/CarbonCommunity/Carbon/releases/download/rustbeta_staging_build/Carbon.Windows.Debug.zip' if Environment.OSVersion.Platform == PlatformID.Win32NT else 'https://github.com/CarbonCommunity/Carbon/releases/download/rustbeta_staging_build/Carbon.Linux.Debug.tar.gz'
  36. fileName = ThisService.RootDirectory + "Carbon.Rust.zip"
  37.  
  38. #File name above is incorrect as carbon uses OS specific names
  39.  
  40. wc = WebClient()
  41. WriteLog("Downloading File " + fileName + " from " + url +"...\n\n")
  42. wc.DownloadFile(url,fileName)
  43.  
  44. if File.Exists(ThisService.RootDirectory + 'Carbon.Rust.zip'):
  45. current_status = ThisService.Status.ServiceStatus
  46. if current_status == ServiceStatus.Running:
  47. WriteLog('Stopping the service.')
  48. Service(ThisService.ServiceId).Stop()
  49. c.Decompress(ThisService.RootDirectory + "Carbon.Rust.zip", ThisService.RootDirectory)
  50. File.Delete(ThisService.RootDirectory + 'Carebon.Rust.zip')
  51. else:
  52. WriteLog('Carbon not installed.')
  53.  
  54.  
Tags: carbon
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement