Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import clr
- clr.AddReference('System.IO.Compression.FileSystem')
- clr.AddReference("TCAdmin.SDK")
- clr.AddReference("TCAdmin.Interfaces")
- clr.AddReference("TCAdmin.GameHosting.SDK")
- from System import Environment, PlatformID
- from System.IO import Directory, File
- from TCAdmin.SDK.Misc import WebClient
- from TCAdmin.SDK.Misc import CompressionTools
- from TCAdmin.Interfaces.Server import ServiceStatus
- from TCAdmin.GameHosting.SDK.Objects import Service
- #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.
- try:
- ThisTaskStep.WriteLog
- except NameError:
- WriteLog = Script.WriteToConsole
- else:
- WriteLog = ThisTaskStep.WriteLog
- c=CompressionTools()
- WriteLog('Checking if Carbon is installed...')
- # Check if Carbon is installed
- if Directory.Exists(ThisService.RootDirectory + 'Carbon'):
- if File.Exists(ThisService.RootDirectory + 'Carbon.Rust.zip'):
- File.Delete(ThisService.RootDirectory + 'Carbon.Rust.zip')
- WriteLog('Found carbon installation... Updating Carbon.')
- 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'
- #Need to rename file here to "Carbon.Rust.zip"
- if ThisService.Variables['branch'] == 'staging':
- WriteLog('Staging branch detected')
- 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'
- fileName = ThisService.RootDirectory + "Carbon.Rust.zip"
- #File name above is incorrect as carbon uses OS specific names
- wc = WebClient()
- WriteLog("Downloading File " + fileName + " from " + url +"...\n\n")
- wc.DownloadFile(url,fileName)
- if File.Exists(ThisService.RootDirectory + 'Carbon.Rust.zip'):
- current_status = ThisService.Status.ServiceStatus
- if current_status == ServiceStatus.Running:
- WriteLog('Stopping the service.')
- Service(ThisService.ServiceId).Stop()
- c.Decompress(ThisService.RootDirectory + "Carbon.Rust.zip", ThisService.RootDirectory)
- File.Delete(ThisService.RootDirectory + 'Carebon.Rust.zip')
- else:
- WriteLog('Carbon not installed.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement