Jump to content

Run Install/Uninstall Script?


Brett

Recommended Posts

A while ago the TCA staff provided me with scripts I can run on a machine that will run the install or uninstall scripts for all services on that box. We often find the need to run them again on individual servers though.

 

Is there any way to setup a script/custom icon combo that will allow us to do this from the Game Panel?

Link to comment
Share on other sites

I would not recommend having scripts in your web folder because anybody will be able to execute them.

 

If you still want to do this:

 

copy the code between:

 

<tcascript>
<language name="VB" />
<waitForUserAction value="true"/>

<scriptCode><![CDATA[

Imports System

Public Class XXX
    Public Shared Sub Main()

and

 

    End Sub
End Class

]]></scriptCode>

</tcascript>

Create a text file in the TCAdmin\Web folder with .aspx extension with the script like this:

<%
SCRIPT HERE
%>

Remove any lines with Console.ReadLine() that it might have. Replace Console.WriteLine("xxxxx") with Response.Write("xxxxx" & "</br>")

 

Save and you should be able to execute it from your browser.

Link to comment
Share on other sites

Is there no safe way to be able to re-issue the install/uninstall scripts from the Game Panel? This seems like it would be a pretty integral feature, especially when you take into account what they are responsible for handling for most GSPs.

Link to comment
Share on other sites

This script executes the install script for all services on the server where it is executed.

 

<tcascript>
<language name="VB" />
<waitForUserAction value="true"/>

<scriptCode><![CDATA[

Imports System

Class ExecuteScript
   Public Shared Sub Main()
       Dim services() As TCAdminSDK.Objects.Service = TCAdminSDK.Objects.Service.GetServicesByServerId(TCAdminSDK.Info.GetThisServerId())

       If Not services Is Nothing Then
           For Each service As TCAdminSDK.Objects.Service In services
               Try
                       Dim game As New TCAdminSDK.Objects.Game
                       game.GameID = service.GameId
                       game.Find()

                       Dim script As String = game.InstallScript()

                       Dim user As New TCAdminSDK.Objects.User(service.UserID)
                       'Load dynamic values 
                       Dim DynamicValues As TCAdminSDK.Remote.Plugins.GSAutomation.GameServerDynamicValues
                       With DynamicValues
                           .GameName = game.Name
                           .GameServerShortName = game.ShortName
                           .ServerIP = service.ServerIP
                           .ServerPort = service.ServerPort
                           .QueryPort = service.ServerQueryPort
                           .RCONPort = service.ServerRCONPort
                           .CustomPort1 = service.CustomPort1
                           .CustomPort2 = service.CustomPort2
                           .CustomPort3 = service.CustomPort3
                           .CustomPort4 = service.CustomPort4
                           .CustomPort5 = service.CustomPort5
                           .Slots = service.Slots
                           .HostName = String.Empty
                           .RCONPassword = String.Empty
                           .PrivatePassword = String.Empty
                           .IsPrivate = service.Private
                           .UserFilesPath = service.UserFilePath
                           .GameFilesPath = service.AutomationFilesPath
                           .OwnerUserID = service.UserID
                           .OwnerName = user.FullName
                           .OwnerPassword = TCAdminBase.Encryption.DecryptString128Bit(user.Password)
                           .PrimaryServiceID = service.PrimaryServiceID
                           .Application = service.Application
                           .GameKey = service.GameKey
                           .ServiceID = service.ServiceID
                       End With

                       Dim servicescript As String = TCAdminSDK.Remote.Plugins.GSAutomation.ReplaceGameServerValues(script, DynamicValues)
           Dim server as new TCAdminSDK.Objects.Server
           server.ServerId = service.ServerID
           server.Find()
           Console.WriteLine("Executing script on server {0}:", server.DisplayName)
           Console.WriteLine(servicescript)
                       Dim su As TCAdminBase.Plugins.IGenericPlugIn = TCAdminSDK.Remote.InstanceCreator.GetPluginFromServer(service.ServerID, "TCAdminMonitor.StandardPlugins.RemoteServers.ServerUtilities")
                       Dim exitcode As Integer = su.Execute(New Object() {"ExecuteScript", service.WorkingDirectory, servicescript})
                       Console.WriteLine("Executed script on {0} with exit code {1}", service.UniqueDisplayNameWithOwner, exitcode)
               Catch ex As Exception
                   Console.WriteLine("-------------------------")
                   Console.WriteLine("Error executing script on {0}: {1}", service.UniqueDisplayNameWithOwner, ex.ToString())
                   Console.WriteLine("-------------------------")
               End Try
           Next
       End If
       Console.WriteLine("Finished.")
   End Sub
End Class

]]></scriptCode>

</tcascript>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Who's Online   0 Members, 0 Anonymous, 17 Guests (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Terms of Use