mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-25 05:56:58 +01:00
Merge upstream
This commit is contained in:
+66
-45
@@ -9,7 +9,7 @@ namespace TGCommandLine
|
||||
public DDCommand()
|
||||
{
|
||||
Keyword = "dd";
|
||||
Children = new Command[] { new DDStartCommand(), new DDStopCommand(), new DDRestartCommand(), new DDStatusCommand(), new DDAutostartCommand(), new DDPortCommand(), new DDVisibilityCommand(), new DDSecurityCommand() };
|
||||
Children = new Command[] { new DDStartCommand(), new DDStopCommand(), new DDRestartCommand(), new DDStatusCommand(), new DDAutostartCommand(), new DDPortCommand(), new DDSecurityCommand(), new DDWorldAnnounceCommand(), new DDWebclientCommand() };
|
||||
}
|
||||
public override string GetHelpText()
|
||||
{
|
||||
@@ -17,6 +17,32 @@ namespace TGCommandLine
|
||||
}
|
||||
}
|
||||
|
||||
class DDWorldAnnounceCommand : Command
|
||||
{
|
||||
public DDWorldAnnounceCommand()
|
||||
{
|
||||
Keyword = "announce";
|
||||
RequiredParameters = 1;
|
||||
}
|
||||
|
||||
public override string GetHelpText()
|
||||
{
|
||||
return "Sends a message all players on the server";
|
||||
}
|
||||
|
||||
public override string GetArgumentString()
|
||||
{
|
||||
return "<message>";
|
||||
}
|
||||
|
||||
protected override ExitCode Run(IList<string> parameters)
|
||||
{
|
||||
var res = Server.GetComponent<ITGDreamDaemon>().WorldAnnounce(String.Join(" ", parameters));
|
||||
OutputProc(res ?? "Success!");
|
||||
return res == null ? ExitCode.Normal : ExitCode.ServerError;
|
||||
}
|
||||
}
|
||||
|
||||
class DDStartCommand : Command
|
||||
{
|
||||
public DDStartCommand()
|
||||
@@ -165,6 +191,45 @@ namespace TGCommandLine
|
||||
return "Change or check autostarting of the game server with the service";
|
||||
}
|
||||
}
|
||||
class DDWebclientCommand : Command
|
||||
{
|
||||
public DDWebclientCommand()
|
||||
{
|
||||
Keyword = "webclient";
|
||||
RequiredParameters = 1;
|
||||
}
|
||||
|
||||
protected override ExitCode Run(IList<string> parameters)
|
||||
{
|
||||
var DD = Server.GetComponent<ITGDreamDaemon>();
|
||||
switch (parameters[0].ToLower())
|
||||
{
|
||||
case "on":
|
||||
DD.SetWebclient(true);
|
||||
break;
|
||||
case "off":
|
||||
DD.SetWebclient(false);
|
||||
break;
|
||||
case "check":
|
||||
OutputProc("Webclient is: " + (DD.Webclient() ? "Enabled" : "Disabled"));
|
||||
break;
|
||||
default:
|
||||
OutputProc("Invalid parameter: " + parameters[0]);
|
||||
return ExitCode.BadCommand;
|
||||
}
|
||||
return ExitCode.Normal;
|
||||
}
|
||||
|
||||
public override string GetArgumentString()
|
||||
{
|
||||
return "<on|off|check>";
|
||||
}
|
||||
public override string GetHelpText()
|
||||
{
|
||||
return "Change or check if the BYOND webclient is enabled for the game server";
|
||||
}
|
||||
}
|
||||
|
||||
class DDPortCommand : Command
|
||||
{
|
||||
public DDPortCommand()
|
||||
@@ -201,50 +266,6 @@ namespace TGCommandLine
|
||||
}
|
||||
}
|
||||
|
||||
class DDVisibilityCommand : Command
|
||||
{
|
||||
public DDVisibilityCommand()
|
||||
{
|
||||
Keyword = "set-visibility";
|
||||
RequiredParameters = 1;
|
||||
}
|
||||
|
||||
protected override ExitCode Run(IList<string> parameters)
|
||||
{
|
||||
TGDreamDaemonVisibility vis;
|
||||
switch (parameters[0].ToLower())
|
||||
{
|
||||
case "invisible":
|
||||
case "invis":
|
||||
vis = TGDreamDaemonVisibility.Invisible;
|
||||
break;
|
||||
case "private":
|
||||
case "priv":
|
||||
vis = TGDreamDaemonVisibility.Private;
|
||||
break;
|
||||
case "public":
|
||||
case "pub":
|
||||
vis = TGDreamDaemonVisibility.Public;
|
||||
break;
|
||||
default:
|
||||
OutputProc("Invalid visiblity word!");
|
||||
return ExitCode.BadCommand;
|
||||
}
|
||||
Server.GetComponent<ITGDreamDaemon>().SetVisibility(vis);
|
||||
return ExitCode.Normal;
|
||||
}
|
||||
|
||||
public override string GetHelpText()
|
||||
{
|
||||
return "Sets the visibility option for the DreamDaemon world. Requires a server restart to apply and queues a graceful one up";
|
||||
}
|
||||
|
||||
public override string GetArgumentString()
|
||||
{
|
||||
return "<public|private|invisible>";
|
||||
}
|
||||
}
|
||||
|
||||
class DDSecurityCommand : Command
|
||||
{
|
||||
public DDSecurityCommand()
|
||||
|
||||
@@ -27,22 +27,44 @@ namespace TGCommandLine
|
||||
protected override ExitCode Run(IList<string> parameters)
|
||||
{
|
||||
var gen_cl = parameters.Count > 1 && parameters[1].ToLower() == "--cl";
|
||||
TGRepoUpdateMethod method;
|
||||
var Repo = Server.GetComponent<ITGRepository>();
|
||||
switch (parameters[0].ToLower())
|
||||
{
|
||||
case "hard":
|
||||
method = TGRepoUpdateMethod.Hard;
|
||||
var res = Repo.Update(true);
|
||||
if (res != null)
|
||||
{
|
||||
OutputProc(res);
|
||||
return ExitCode.ServerError;
|
||||
}
|
||||
break;
|
||||
case "merge":
|
||||
method = TGRepoUpdateMethod.Merge;
|
||||
res = Repo.Update(false);
|
||||
if (res != null)
|
||||
{
|
||||
OutputProc(res);
|
||||
return ExitCode.ServerError;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
OutputProc("Please specify hard or merge");
|
||||
return ExitCode.BadCommand;
|
||||
}
|
||||
var result = Server.GetComponent<ITGServerUpdater>().UpdateServer(method, gen_cl);
|
||||
OutputProc(result ?? "Compilation started!");
|
||||
return result == null ? ExitCode.Normal : ExitCode.ServerError;
|
||||
if (gen_cl)
|
||||
{
|
||||
Repo.GenerateChangelog(out string res);
|
||||
if (res != null)
|
||||
OutputProc(res);
|
||||
else
|
||||
{
|
||||
res = Repo.PushChangelog();
|
||||
if (res != null)
|
||||
OutputProc(res);
|
||||
}
|
||||
}
|
||||
var resu = Server.GetComponent<ITGCompiler>().Compile(true);
|
||||
OutputProc(resu ? "Compilation started!" : "Compilation could not be started!");
|
||||
return resu ? ExitCode.Normal : ExitCode.ServerError;
|
||||
}
|
||||
|
||||
public override string GetArgumentString()
|
||||
@@ -77,9 +99,22 @@ namespace TGCommandLine
|
||||
OutputProc("Invalid tesmerge #: " + parameters[0]);
|
||||
return ExitCode.BadCommand;
|
||||
}
|
||||
var result = Server.GetComponent<ITGServerUpdater>().UpdateServer(TGRepoUpdateMethod.None, false, tm);
|
||||
OutputProc(result ?? "Compilation started!");
|
||||
return result == null ? ExitCode.Normal : ExitCode.ServerError;
|
||||
var Repo = Server.GetComponent<ITGRepository>();
|
||||
var res = Repo.MergePullRequest(tm);
|
||||
if (res != null)
|
||||
{
|
||||
OutputProc(res);
|
||||
return ExitCode.ServerError;
|
||||
}
|
||||
Repo.GenerateChangelog(out res);
|
||||
if (res != null)
|
||||
{
|
||||
OutputProc(res);
|
||||
return ExitCode.ServerError;
|
||||
}
|
||||
var resu = Server.GetComponent<ITGCompiler>().Compile(true);
|
||||
OutputProc(resu ? "Compilation started!" : "Compilation could not be started!");
|
||||
return resu ? ExitCode.Normal : ExitCode.ServerError;
|
||||
}
|
||||
public override string GetArgumentString()
|
||||
{
|
||||
|
||||
Generated
+60
-37
@@ -71,7 +71,10 @@
|
||||
this.MajorVersionNumeric = new System.Windows.Forms.NumericUpDown();
|
||||
this.UpdateProgressBar = new System.Windows.Forms.ProgressBar();
|
||||
this.ServerPanel = new System.Windows.Forms.TabPage();
|
||||
this.VisibilitySelector = new System.Windows.Forms.ComboBox();
|
||||
this.AutostartCheckbox = new System.Windows.Forms.CheckBox();
|
||||
this.WebclientCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.WorldAnnounceButton = new System.Windows.Forms.Button();
|
||||
this.WorldAnnounceField = new System.Windows.Forms.TextBox();
|
||||
this.VisibilityTitle = new System.Windows.Forms.Label();
|
||||
this.SecuritySelector = new System.Windows.Forms.ComboBox();
|
||||
this.SecurityTitle = new System.Windows.Forms.Label();
|
||||
@@ -96,7 +99,6 @@
|
||||
this.ServerRestartButton = new System.Windows.Forms.Button();
|
||||
this.ServerStopButton = new System.Windows.Forms.Button();
|
||||
this.ServerStartButton = new System.Windows.Forms.Button();
|
||||
this.AutostartCheckbox = new System.Windows.Forms.CheckBox();
|
||||
this.CompilerStatusLabel = new System.Windows.Forms.Label();
|
||||
this.CompilerLabel = new System.Windows.Forms.Label();
|
||||
this.compileButton = new System.Windows.Forms.Button();
|
||||
@@ -722,7 +724,10 @@
|
||||
// ServerPanel
|
||||
//
|
||||
this.ServerPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(39)))), ((int)(((byte)(40)))), ((int)(((byte)(34)))));
|
||||
this.ServerPanel.Controls.Add(this.VisibilitySelector);
|
||||
this.ServerPanel.Controls.Add(this.AutostartCheckbox);
|
||||
this.ServerPanel.Controls.Add(this.WebclientCheckBox);
|
||||
this.ServerPanel.Controls.Add(this.WorldAnnounceButton);
|
||||
this.ServerPanel.Controls.Add(this.WorldAnnounceField);
|
||||
this.ServerPanel.Controls.Add(this.VisibilityTitle);
|
||||
this.ServerPanel.Controls.Add(this.SecuritySelector);
|
||||
this.ServerPanel.Controls.Add(this.SecurityTitle);
|
||||
@@ -747,7 +752,6 @@
|
||||
this.ServerPanel.Controls.Add(this.ServerRestartButton);
|
||||
this.ServerPanel.Controls.Add(this.ServerStopButton);
|
||||
this.ServerPanel.Controls.Add(this.ServerStartButton);
|
||||
this.ServerPanel.Controls.Add(this.AutostartCheckbox);
|
||||
this.ServerPanel.Controls.Add(this.CompilerStatusLabel);
|
||||
this.ServerPanel.Controls.Add(this.CompilerLabel);
|
||||
this.ServerPanel.Controls.Add(this.compileButton);
|
||||
@@ -762,20 +766,52 @@
|
||||
this.ServerPanel.TabIndex = 2;
|
||||
this.ServerPanel.Text = "Server";
|
||||
//
|
||||
// VisibilitySelector
|
||||
// AutostartCheckbox
|
||||
//
|
||||
this.VisibilitySelector.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.VisibilitySelector.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.VisibilitySelector.FormattingEnabled = true;
|
||||
this.VisibilitySelector.Items.AddRange(new object[] {
|
||||
"Public",
|
||||
"Private",
|
||||
"Invisible"});
|
||||
this.VisibilitySelector.Location = new System.Drawing.Point(566, 136);
|
||||
this.VisibilitySelector.Name = "VisibilitySelector";
|
||||
this.VisibilitySelector.Size = new System.Drawing.Size(121, 21);
|
||||
this.VisibilitySelector.TabIndex = 40;
|
||||
this.VisibilitySelector.SelectedIndexChanged += new System.EventHandler(this.VisibilitySelector_SelectedIndexChanged);
|
||||
this.AutostartCheckbox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.AutostartCheckbox.AutoSize = true;
|
||||
this.AutostartCheckbox.Font = new System.Drawing.Font("Verdana", 12F);
|
||||
this.AutostartCheckbox.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(242)))));
|
||||
this.AutostartCheckbox.Location = new System.Drawing.Point(758, 0);
|
||||
this.AutostartCheckbox.Name = "AutostartCheckbox";
|
||||
this.AutostartCheckbox.Size = new System.Drawing.Size(104, 22);
|
||||
this.AutostartCheckbox.TabIndex = 15;
|
||||
this.AutostartCheckbox.Text = "Autostart";
|
||||
this.AutostartCheckbox.UseVisualStyleBackColor = true;
|
||||
this.AutostartCheckbox.CheckedChanged += new System.EventHandler(this.AutostartCheckbox_CheckedChanged);
|
||||
//
|
||||
// WebclientCheckBox
|
||||
//
|
||||
this.WebclientCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.WebclientCheckBox.AutoSize = true;
|
||||
this.WebclientCheckBox.Font = new System.Drawing.Font("Verdana", 12F);
|
||||
this.WebclientCheckBox.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(242)))));
|
||||
this.WebclientCheckBox.Location = new System.Drawing.Point(758, 28);
|
||||
this.WebclientCheckBox.Name = "WebclientCheckBox";
|
||||
this.WebclientCheckBox.Size = new System.Drawing.Size(108, 22);
|
||||
this.WebclientCheckBox.TabIndex = 42;
|
||||
this.WebclientCheckBox.Text = "Webclient";
|
||||
this.WebclientCheckBox.UseVisualStyleBackColor = true;
|
||||
this.WebclientCheckBox.CheckedChanged += new System.EventHandler(this.WebclientCheckBox_CheckedChanged);
|
||||
//
|
||||
// WorldAnnounceButton
|
||||
//
|
||||
this.WorldAnnounceButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.WorldAnnounceButton.Location = new System.Drawing.Point(785, 136);
|
||||
this.WorldAnnounceButton.Name = "WorldAnnounceButton";
|
||||
this.WorldAnnounceButton.Size = new System.Drawing.Size(77, 20);
|
||||
this.WorldAnnounceButton.TabIndex = 41;
|
||||
this.WorldAnnounceButton.Text = "Send";
|
||||
this.WorldAnnounceButton.UseVisualStyleBackColor = true;
|
||||
this.WorldAnnounceButton.Click += new System.EventHandler(this.WorldAnnounceButton_Click);
|
||||
//
|
||||
// WorldAnnounceField
|
||||
//
|
||||
this.WorldAnnounceField.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.WorldAnnounceField.Location = new System.Drawing.Point(566, 136);
|
||||
this.WorldAnnounceField.Name = "WorldAnnounceField";
|
||||
this.WorldAnnounceField.Size = new System.Drawing.Size(213, 20);
|
||||
this.WorldAnnounceField.TabIndex = 40;
|
||||
//
|
||||
// VisibilityTitle
|
||||
//
|
||||
@@ -783,11 +819,11 @@
|
||||
this.VisibilityTitle.AutoSize = true;
|
||||
this.VisibilityTitle.Font = new System.Drawing.Font("Verdana", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.VisibilityTitle.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(242)))));
|
||||
this.VisibilityTitle.Location = new System.Drawing.Point(474, 139);
|
||||
this.VisibilityTitle.Location = new System.Drawing.Point(466, 139);
|
||||
this.VisibilityTitle.Name = "VisibilityTitle";
|
||||
this.VisibilityTitle.Size = new System.Drawing.Size(86, 18);
|
||||
this.VisibilityTitle.Size = new System.Drawing.Size(94, 18);
|
||||
this.VisibilityTitle.TabIndex = 39;
|
||||
this.VisibilityTitle.Text = "Visibility:";
|
||||
this.VisibilityTitle.Text = "Announce:";
|
||||
this.VisibilityTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// SecuritySelector
|
||||
@@ -1079,20 +1115,6 @@
|
||||
this.ServerStartButton.UseVisualStyleBackColor = true;
|
||||
this.ServerStartButton.Click += new System.EventHandler(this.ServerStartButton_Click);
|
||||
//
|
||||
// AutostartCheckbox
|
||||
//
|
||||
this.AutostartCheckbox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.AutostartCheckbox.AutoSize = true;
|
||||
this.AutostartCheckbox.Font = new System.Drawing.Font("Verdana", 12F);
|
||||
this.AutostartCheckbox.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(242)))));
|
||||
this.AutostartCheckbox.Location = new System.Drawing.Point(758, 17);
|
||||
this.AutostartCheckbox.Name = "AutostartCheckbox";
|
||||
this.AutostartCheckbox.Size = new System.Drawing.Size(104, 22);
|
||||
this.AutostartCheckbox.TabIndex = 15;
|
||||
this.AutostartCheckbox.Text = "Autostart";
|
||||
this.AutostartCheckbox.UseVisualStyleBackColor = true;
|
||||
this.AutostartCheckbox.CheckedChanged += new System.EventHandler(this.AutostartCheckbox_CheckedChanged);
|
||||
//
|
||||
// CompilerStatusLabel
|
||||
//
|
||||
this.CompilerStatusLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
@@ -1608,7 +1630,6 @@
|
||||
this.AdminModeSpecial.TabStop = true;
|
||||
this.AdminModeSpecial.Text = "Channel Mode";
|
||||
this.AdminModeSpecial.UseVisualStyleBackColor = true;
|
||||
this.AdminModeNormal.CheckedChanged += new System.EventHandler(this.AdminModeSpecial_CheckedChanged);
|
||||
//
|
||||
// AdminModeNormal
|
||||
//
|
||||
@@ -2082,7 +2103,6 @@
|
||||
private System.Windows.Forms.NumericUpDown PortSelector;
|
||||
private System.Windows.Forms.Label ProjectPathLabel;
|
||||
private System.Windows.Forms.TextBox projectNameText;
|
||||
private System.Windows.Forms.Button CompileCancelButton;
|
||||
private System.Windows.Forms.Label ServerPathLabel;
|
||||
private System.Windows.Forms.TextBox ServerPathTextbox;
|
||||
private System.Windows.Forms.Label LatestVersionLabel;
|
||||
@@ -2159,7 +2179,6 @@
|
||||
private System.Windows.Forms.ComboBox SecuritySelector;
|
||||
private System.Windows.Forms.Label SecurityTitle;
|
||||
private System.Windows.Forms.Label VisibilityTitle;
|
||||
private System.Windows.Forms.ComboBox VisibilitySelector;
|
||||
private System.ComponentModel.BackgroundWorker ServerStartBGW;
|
||||
private System.Windows.Forms.Button RepoRefreshButton;
|
||||
private System.Windows.Forms.ComboBox IRCModesComboBox;
|
||||
@@ -2175,5 +2194,9 @@
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Button WorldAnnounceButton;
|
||||
private System.Windows.Forms.TextBox WorldAnnounceField;
|
||||
private System.Windows.Forms.Button CompileCancelButton;
|
||||
private System.Windows.Forms.CheckBox WebclientCheckBox;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace TGControlPanel
|
||||
}
|
||||
|
||||
FullUpdateAction fuAction;
|
||||
int testmergePR;
|
||||
ushort testmergePR;
|
||||
string updateError;
|
||||
bool updatingFields = false;
|
||||
|
||||
@@ -104,6 +104,7 @@ namespace TGControlPanel
|
||||
initializeButton.Visible = RepoExists;
|
||||
NudgePortSelector.Visible = RepoExists;
|
||||
AutostartCheckbox.Visible = RepoExists;
|
||||
WebclientCheckBox.Visible = RepoExists;
|
||||
PortSelector.Visible = RepoExists;
|
||||
projectNameText.Visible = RepoExists;
|
||||
compilerProgressBar.Visible = RepoExists;
|
||||
@@ -125,6 +126,8 @@ namespace TGControlPanel
|
||||
UpdateMergeButton.Visible = RepoExists;
|
||||
UpdateTestmergeButton.Visible = RepoExists;
|
||||
ResetTestmerge.Visible = RepoExists;
|
||||
WorldAnnounceField.Visible = RepoExists;
|
||||
WorldAnnounceButton.Visible = RepoExists;
|
||||
|
||||
var DM = Server.GetComponent<ITGCompiler>();
|
||||
var DD = Server.GetComponent<ITGDreamDaemon>();
|
||||
@@ -137,8 +140,7 @@ namespace TGControlPanel
|
||||
|
||||
if (!ServerPathTextbox.Focused)
|
||||
ServerPathTextbox.Text = Config.ServerDirectory();
|
||||
|
||||
VisibilitySelector.SelectedIndex = (int)DD.VisibilityLevel();
|
||||
|
||||
SecuritySelector.SelectedIndex = (int)DD.SecurityLevel();
|
||||
|
||||
if (!RepoExists)
|
||||
@@ -156,6 +158,7 @@ namespace TGControlPanel
|
||||
ServerGStopButton.Enabled = !ShuttingDown;
|
||||
|
||||
AutostartCheckbox.Checked = DD.Autostart();
|
||||
WebclientCheckBox.Checked = DD.Webclient();
|
||||
if (!PortSelector.Focused)
|
||||
PortSelector.Value = DD.Port();
|
||||
if (!projectNameText.Focused)
|
||||
@@ -246,7 +249,7 @@ namespace TGControlPanel
|
||||
Server.GetComponent<ITGDreamDaemon>().SetPort((ushort)PortSelector.Value);
|
||||
}
|
||||
|
||||
private void RunServerUpdate(FullUpdateAction fua, int tm = 0)
|
||||
private void RunServerUpdate(FullUpdateAction fua, ushort tm = 0)
|
||||
{
|
||||
if (FullUpdateWorker.IsBusy)
|
||||
return;
|
||||
@@ -373,25 +376,64 @@ namespace TGControlPanel
|
||||
return;
|
||||
Server.GetComponent<ITGDreamDaemon>().RequestRestart();
|
||||
}
|
||||
|
||||
|
||||
private void FullUpdateWorker_DoWork(object sender, DoWorkEventArgs e)
|
||||
{
|
||||
var Updater = Server.GetComponent<ITGServerUpdater>();
|
||||
var Repo = Server.GetComponent<ITGRepository>();
|
||||
var DM = Server.GetComponent<ITGCompiler>();
|
||||
switch (fuAction)
|
||||
{
|
||||
case FullUpdateAction.Testmerge:
|
||||
updateError = Updater.UpdateServer(TGRepoUpdateMethod.None, false, (ushort)testmergePR);
|
||||
updateError = Repo.MergePullRequest(testmergePR);
|
||||
if (updateError == null)
|
||||
{
|
||||
Repo.GenerateChangelog(out updateError);
|
||||
updateError = DM.Compile(true) ? updateError : "Compilation failed!";
|
||||
}
|
||||
break;
|
||||
case FullUpdateAction.UpdateHard:
|
||||
updateError = Updater.UpdateServer(TGRepoUpdateMethod.Hard, true);
|
||||
updateError = Repo.Update(true);
|
||||
if (updateError == null)
|
||||
{
|
||||
Repo.GenerateChangelog(out updateError);
|
||||
if(updateError == null)
|
||||
updateError = Repo.PushChangelog();
|
||||
updateError = DM.Compile(true) ? updateError : "Compilation failed!";
|
||||
}
|
||||
break;
|
||||
case FullUpdateAction.UpdateHardTestmerge:
|
||||
updateError = Updater.UpdateServer(TGRepoUpdateMethod.Hard, true, (ushort)testmergePR);
|
||||
updateError = Repo.Update(true);
|
||||
if (updateError == null)
|
||||
{
|
||||
Repo.GenerateChangelog(out updateError);
|
||||
if (updateError == null)
|
||||
updateError = Repo.PushChangelog();
|
||||
updateError = Repo.MergePullRequest(testmergePR);
|
||||
if (updateError == null)
|
||||
{
|
||||
Repo.GenerateChangelog(out updateError);
|
||||
updateError = DM.Compile(true) ? updateError : "Compilation failed!";
|
||||
}
|
||||
}
|
||||
break;
|
||||
case FullUpdateAction.UpdateMerge:
|
||||
updateError = Updater.UpdateServer(TGRepoUpdateMethod.Merge, true, (ushort)testmergePR);
|
||||
updateError = Repo.Update(false);
|
||||
if (updateError == null)
|
||||
{
|
||||
Repo.GenerateChangelog(out updateError);
|
||||
if (updateError == null)
|
||||
Repo.PushChangelog(); //not an error 99% of the time if this fails, just a dirty tree
|
||||
updateError = DM.Compile(true) ? updateError : "Compilation failed!";
|
||||
}
|
||||
break;
|
||||
case FullUpdateAction.Reset:
|
||||
updateError = Updater.UpdateServer(TGRepoUpdateMethod.Reset, false, 0);
|
||||
updateError = Repo.Reset(true);
|
||||
if (updateError == null)
|
||||
{
|
||||
Repo.GenerateChangelog(out updateError);
|
||||
updateError = DM.Compile(true) ? updateError : "Compilation failed!";
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -407,7 +449,7 @@ namespace TGControlPanel
|
||||
|
||||
private void UpdateTestmergeButton_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
RunServerUpdate(FullUpdateAction.UpdateHardTestmerge, (int)ServerTestmergeInput.Value);
|
||||
RunServerUpdate(FullUpdateAction.UpdateHardTestmerge, (ushort)ServerTestmergeInput.Value);
|
||||
}
|
||||
|
||||
private void UpdateMergeButton_Click(object sender, System.EventArgs e)
|
||||
@@ -416,7 +458,7 @@ namespace TGControlPanel
|
||||
}
|
||||
private void TestmergeButton_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
RunServerUpdate(FullUpdateAction.Testmerge, (int)ServerTestmergeInput.Value);
|
||||
RunServerUpdate(FullUpdateAction.Testmerge, (ushort)ServerTestmergeInput.Value);
|
||||
}
|
||||
|
||||
private void NudgePortSelector_ValueChanged(object sender, EventArgs e)
|
||||
@@ -432,11 +474,24 @@ namespace TGControlPanel
|
||||
MessageBox.Show("Security change will be applied after next server reboot.");
|
||||
}
|
||||
|
||||
private void VisibilitySelector_SelectedIndexChanged(object sender, EventArgs e)
|
||||
private void WorldAnnounceButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var msg = WorldAnnounceField.Text;
|
||||
if (!String.IsNullOrWhiteSpace(msg)) {
|
||||
var res = Server.GetComponent<ITGDreamDaemon>().WorldAnnounce(msg);
|
||||
if(res != null)
|
||||
{
|
||||
MessageBox.Show(res);
|
||||
return;
|
||||
}
|
||||
}
|
||||
WorldAnnounceField.Text = "";
|
||||
}
|
||||
|
||||
private void WebclientCheckBox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!updatingFields)
|
||||
if (!Server.GetComponent<ITGDreamDaemon>().SetVisibility((TGDreamDaemonVisibility)VisibilitySelector.SelectedIndex))
|
||||
MessageBox.Show("Visibility change will be applied after next server reboot.");
|
||||
Server.GetComponent<ITGDreamDaemon>().SetWebclient(WebclientCheckBox.Checked);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+15
-15
@@ -68,6 +68,21 @@ namespace TGInstallerWrapper
|
||||
string logfile = null;
|
||||
try
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
var res = PromptKillProcess("TGCommandLine");
|
||||
if (res == PKillType.Aborted)
|
||||
return;
|
||||
else if (res == PKillType.Killed)
|
||||
continue;
|
||||
res = PromptKillProcess("TGControlPanel");
|
||||
if (res == PKillType.Aborted)
|
||||
return;
|
||||
else if (res == PKillType.Killed)
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
|
||||
var args = new List<string>();
|
||||
if (!pathIsDefault)
|
||||
args.Add(String.Format("INSTALLFOLDER=\"{0}\"", PathTextBox.Text));
|
||||
@@ -114,21 +129,6 @@ namespace TGInstallerWrapper
|
||||
}
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
var res = PromptKillProcess("TGCommandLine");
|
||||
if (res == PKillType.Aborted)
|
||||
return;
|
||||
else if (res == PKillType.Killed)
|
||||
continue;
|
||||
res = PromptKillProcess("TGControlPanel");
|
||||
if (res == PKillType.Aborted)
|
||||
return;
|
||||
else if (res == PKillType.Killed)
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
|
||||
InstallCancelButton.Enabled = true;
|
||||
|
||||
if (ShowLogCheckbox.Checked)
|
||||
|
||||
@@ -31,9 +31,6 @@
|
||||
<setting name="ServerSecurity" serializeAs="String">
|
||||
<value>0</value>
|
||||
</setting>
|
||||
<setting name="ServerVisiblity" serializeAs="String">
|
||||
<value>2</value>
|
||||
</setting>
|
||||
<setting name="DDAutoStart" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
@@ -64,6 +61,9 @@
|
||||
<setting name="ReattachCommsKey" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="Webclient" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
</TGServerService.Properties.Settings>
|
||||
</userSettings>
|
||||
</configuration>
|
||||
|
||||
@@ -147,7 +147,9 @@ namespace TGServerService
|
||||
Server = this,
|
||||
};
|
||||
TGServerService.WriteInfo(String.Format("Chat Command from {0} ({2}): {1}", speaker, String.Join(" ", asList), channel), TGServerService.EventID.ChatCommand);
|
||||
new RootChatCommand().DoRun(asList);
|
||||
if (ServerChatCommands == null)
|
||||
LoadServerChatCommands();
|
||||
new RootChatCommand(ServerChatCommands).DoRun(asList);
|
||||
}
|
||||
|
||||
//cleanup and save
|
||||
|
||||
+38
-133
@@ -1,7 +1,7 @@
|
||||
using TGServiceInterface;
|
||||
using System.Threading;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
namespace TGServerService
|
||||
{
|
||||
@@ -36,12 +36,42 @@ namespace TGServerService
|
||||
return base.DoRun(parameters);
|
||||
}
|
||||
}
|
||||
|
||||
class ServerChatCommand : ChatCommand
|
||||
{
|
||||
readonly string HelpText;
|
||||
public ServerChatCommand(string name, string helpText, bool adminOnly, int requiredParameters)
|
||||
{
|
||||
Keyword = name;
|
||||
RequiresAdmin = adminOnly;
|
||||
HelpText = helpText;
|
||||
RequiredParameters = requiredParameters;
|
||||
}
|
||||
|
||||
public override string GetHelpText()
|
||||
{
|
||||
return HelpText;
|
||||
}
|
||||
|
||||
protected override ExitCode Run(IList<string> parameters)
|
||||
{
|
||||
var res = Instance.SendCommand(String.Format("{0};sender={1};custom=\"{2}\"", Keyword, CommandInfo.Value.Speaker, String.Join(" ", parameters)));
|
||||
if (res != "SUCESS" && !String.IsNullOrWhiteSpace(res))
|
||||
OutputProc(res);
|
||||
return ExitCode.Normal;
|
||||
}
|
||||
}
|
||||
|
||||
class RootChatCommand : RootCommand
|
||||
{
|
||||
public RootChatCommand()
|
||||
public RootChatCommand(List<Command> serverCommands)
|
||||
{
|
||||
var tmp = new List<Command> { new PRsCommand(), new VersionCommand(), new RevisionCommand(), new ByondCommand(), new KekCommand() };
|
||||
if (serverCommands != null)
|
||||
tmp.AddRange(serverCommands);
|
||||
Children = tmp.ToArray();
|
||||
serverCommands = new List<Command>();
|
||||
PrintHelpList = true;
|
||||
Children = new Command[] { new CheckCommand(), new StatusCommand(), new PRsCommand(), new VersionCommand(), new AHelpCommand(), new NameCheckCommand(), new RevisionCommand(), new AdminWhoCommand(), new ByondCommand(), new KekCommand(), new RelayRestartCommand() };
|
||||
}
|
||||
}
|
||||
class RevisionCommand : ChatCommand
|
||||
@@ -52,58 +82,13 @@ namespace TGServerService
|
||||
}
|
||||
protected override ExitCode Run(IList<string> parameters)
|
||||
{
|
||||
OutputProc(Instance.GetHead(out string error) ?? error);
|
||||
OutputProc(String.Format("^{0}", Instance.GetHead(out string error)) ?? error);
|
||||
return error == null ? ExitCode.Normal : ExitCode.ServerError;
|
||||
}
|
||||
|
||||
public override string GetHelpText()
|
||||
{
|
||||
return "Returns mob info of the specified target";
|
||||
}
|
||||
}
|
||||
class NameCheckCommand : ChatCommand
|
||||
{
|
||||
public NameCheckCommand()
|
||||
{
|
||||
Keyword = "namecheck";
|
||||
RequiredParameters = 1;
|
||||
RequiresAdmin = true;
|
||||
}
|
||||
protected override ExitCode Run(IList<string> parameters)
|
||||
{
|
||||
OutputProc(Instance.NameCheck(parameters[0], CommandInfo.Value.Speaker));
|
||||
return ExitCode.Normal;
|
||||
}
|
||||
|
||||
public override string GetHelpText()
|
||||
{
|
||||
return "Returns mob info of the specified target";
|
||||
}
|
||||
public override string GetArgumentString()
|
||||
{
|
||||
return "<target>";
|
||||
}
|
||||
}
|
||||
class AdminWhoCommand : ChatCommand
|
||||
{
|
||||
public AdminWhoCommand()
|
||||
{
|
||||
Keyword = "adminwho";
|
||||
RequiresAdmin = true;
|
||||
}
|
||||
protected override ExitCode Run(IList<string> parameters)
|
||||
{
|
||||
OutputProc(Instance.SendCommand(TGStationServer.SCAdminWho));
|
||||
return ExitCode.Normal;
|
||||
}
|
||||
|
||||
public override string GetHelpText()
|
||||
{
|
||||
return "Returns mob info of the specified target";
|
||||
}
|
||||
public override string GetArgumentString()
|
||||
{
|
||||
return "<target>";
|
||||
return "Prints the current code revision of the repository (not the server)";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,42 +119,6 @@ namespace TGServerService
|
||||
return "[--staged|--latest]";
|
||||
}
|
||||
}
|
||||
class CheckCommand : ChatCommand
|
||||
{
|
||||
public CheckCommand()
|
||||
{
|
||||
Keyword = "check";
|
||||
}
|
||||
protected override ExitCode Run(IList<string> parameters)
|
||||
{
|
||||
OutputProc(Instance.StatusString(CommandInfo.Value.IsAdmin && CommandInfo.Value.IsAdminChannel));
|
||||
return ExitCode.Normal;
|
||||
}
|
||||
|
||||
public override string GetHelpText()
|
||||
{
|
||||
return "Gets the playercount, gamemode, and address of the server";
|
||||
}
|
||||
}
|
||||
|
||||
class StatusCommand : ChatCommand
|
||||
{
|
||||
public StatusCommand()
|
||||
{
|
||||
Keyword = "status";
|
||||
RequiresAdmin = true;
|
||||
}
|
||||
protected override ExitCode Run(IList<string> parameters)
|
||||
{
|
||||
OutputProc(Instance.SendCommand(TGStationServer.SCIRCStatus));
|
||||
return ExitCode.Normal;
|
||||
}
|
||||
|
||||
public override string GetHelpText()
|
||||
{
|
||||
return "Gets the admincount, playercount, gamemode, and true game mode of the server";
|
||||
}
|
||||
}
|
||||
class VersionCommand : ChatCommand
|
||||
{
|
||||
public VersionCommand()
|
||||
@@ -224,7 +173,7 @@ namespace TGServerService
|
||||
{
|
||||
res = "";
|
||||
foreach (var I in PRs)
|
||||
res += I.Number + " ";
|
||||
res += "#" + I.Number + " ";
|
||||
OutputProc(res);
|
||||
}
|
||||
return ExitCode.Normal;
|
||||
@@ -235,49 +184,5 @@ namespace TGServerService
|
||||
return "Gets the currently merged pull requests in the repository";
|
||||
}
|
||||
}
|
||||
|
||||
class AHelpCommand : ChatCommand
|
||||
{
|
||||
public AHelpCommand()
|
||||
{
|
||||
Keyword = "ahelp";
|
||||
RequiresAdmin = true;
|
||||
RequiredParameters = 2;
|
||||
}
|
||||
protected override ExitCode Run(IList<string> parameters)
|
||||
{
|
||||
var ckey = parameters[0];
|
||||
parameters.RemoveAt(0);
|
||||
OutputProc(Instance.SendPM(ckey, CommandInfo.Value.Speaker, String.Join(" ", parameters)));
|
||||
return ExitCode.Normal;
|
||||
}
|
||||
|
||||
public override string GetHelpText()
|
||||
{
|
||||
return "Respond to a relayed admin help request";
|
||||
}
|
||||
|
||||
public override string GetArgumentString()
|
||||
{
|
||||
return "<ckey> <message|ticket <close|resolve|icissue|reject|reopen <ticket #>|list>>";
|
||||
}
|
||||
}
|
||||
class RelayRestartCommand : ChatCommand
|
||||
{
|
||||
public RelayRestartCommand()
|
||||
{
|
||||
Keyword = "relayrestart";
|
||||
RequiresAdmin = true;
|
||||
}
|
||||
protected override ExitCode Run(IList<string> parameters)
|
||||
{
|
||||
Instance.InitInterop();
|
||||
return ExitCode.Normal;
|
||||
}
|
||||
|
||||
public override string GetHelpText()
|
||||
{
|
||||
return "Restart the relay listener. This is a massive hack but it'll do for now";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -352,6 +352,11 @@ namespace TGServerService
|
||||
//just the tip
|
||||
const string GitLogsDir = "/.git/logs";
|
||||
Program.CopyDirectory(RepoPath + GitLogsDir, resurrectee + GitLogsDir);
|
||||
try
|
||||
{
|
||||
File.Copy(PRJobFile, resurrectee + Path.DirectorySeparatorChar + PRJobFile);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -31,7 +31,6 @@ namespace TGServerService
|
||||
bool RestartInProgress = false;
|
||||
|
||||
TGDreamDaemonSecurity StartingSecurity;
|
||||
TGDreamDaemonVisibility StartingVisiblity;
|
||||
|
||||
ShutdownRequestPhase AwaitingShutdown;
|
||||
|
||||
@@ -57,6 +56,7 @@ namespace TGServerService
|
||||
currentStatus = TGDreamDaemonStatus.Online;
|
||||
DDWatchdog = new Thread(new ThreadStart(Watchdog));
|
||||
DDWatchdog.Start();
|
||||
RequestRestart(); //TODO: Remove this when DD -> Service communication is more
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -364,23 +364,6 @@ namespace TGServerService
|
||||
}
|
||||
}
|
||||
|
||||
//same thing with visibility
|
||||
string VisibilityWord(bool starting = false)
|
||||
{
|
||||
var level = starting ? StartingVisiblity : (TGDreamDaemonVisibility)Properties.Settings.Default.ServerVisiblity;
|
||||
switch (level)
|
||||
{
|
||||
case TGDreamDaemonVisibility.Invisible:
|
||||
return "invisible";
|
||||
case TGDreamDaemonVisibility.Private:
|
||||
return "private";
|
||||
case TGDreamDaemonVisibility.Public:
|
||||
return "public";
|
||||
default:
|
||||
throw new Exception(String.Format("Bad DreamDaemon visibility level: {0}", level));
|
||||
}
|
||||
}
|
||||
|
||||
//used by Start and Watchdog to start a DD instance
|
||||
string StartImpl(bool watchdog)
|
||||
{
|
||||
@@ -396,9 +379,8 @@ namespace TGServerService
|
||||
var DMB = GameDirLive + "/" + Config.ProjectName + ".dmb";
|
||||
|
||||
GenCommsKey();
|
||||
StartingVisiblity = (TGDreamDaemonVisibility)Config.ServerVisiblity;
|
||||
StartingSecurity = (TGDreamDaemonSecurity)Config.ServerSecurity;
|
||||
Proc.StartInfo.Arguments = String.Format("{0} -port {1} -close -verbose -params server_service={4} -{2} -{3}", DMB, Config.ServerPort, SecurityWord(), VisibilityWord(), serviceCommsKey);
|
||||
Proc.StartInfo.Arguments = String.Format("{0} -port {1} {5}-close -verbose -params \"server_service={3}&server_service_version={4}\" -{2} -public", DMB, Config.ServerPort, SecurityWord(), serviceCommsKey, Version(), Config.Webclient ? "-webclient" : "");
|
||||
InitInterop();
|
||||
Proc.Start();
|
||||
|
||||
@@ -429,31 +411,6 @@ namespace TGServerService
|
||||
}
|
||||
}
|
||||
|
||||
//public api
|
||||
public TGDreamDaemonVisibility VisibilityLevel()
|
||||
{
|
||||
lock (watchdogLock)
|
||||
{
|
||||
return (TGDreamDaemonVisibility)Properties.Settings.Default.ServerVisiblity;
|
||||
}
|
||||
}
|
||||
|
||||
//public api
|
||||
public bool SetVisibility(TGDreamDaemonVisibility NewVis)
|
||||
{
|
||||
var Config = Properties.Settings.Default;
|
||||
var visInt = (int)NewVis;
|
||||
bool needReboot;
|
||||
lock (watchdogLock)
|
||||
{
|
||||
needReboot = Config.ServerVisiblity != visInt;
|
||||
Config.ServerVisiblity = visInt;
|
||||
}
|
||||
if (needReboot)
|
||||
RequestRestart();
|
||||
return DaemonStatus() != TGDreamDaemonStatus.Online;
|
||||
}
|
||||
|
||||
//public api
|
||||
public TGDreamDaemonSecurity SecurityLevel()
|
||||
{
|
||||
@@ -494,7 +451,7 @@ namespace TGServerService
|
||||
//public api
|
||||
public string StatusString(bool includeMetaInfo)
|
||||
{
|
||||
const string visSecStr = " (Vis: {0}, Sec: {1})";
|
||||
const string visSecStr = " (Sec: {0})";
|
||||
string res;
|
||||
var ds = DaemonStatus();
|
||||
switch (ds)
|
||||
@@ -506,13 +463,13 @@ namespace TGServerService
|
||||
res = "REBOOTING";
|
||||
break;
|
||||
case TGDreamDaemonStatus.Online:
|
||||
res = SendCommand(SCIRCCheck);
|
||||
res = "ONLINE";
|
||||
if (includeMetaInfo)
|
||||
{
|
||||
string secandvis;
|
||||
lock (watchdogLock)
|
||||
{
|
||||
secandvis = String.Format(visSecStr, VisibilityWord(true), SecurityWord(true));
|
||||
secandvis = String.Format(visSecStr, SecurityWord(true));
|
||||
}
|
||||
res += secandvis;
|
||||
}
|
||||
@@ -522,7 +479,7 @@ namespace TGServerService
|
||||
break;
|
||||
}
|
||||
if (includeMetaInfo && ds != TGDreamDaemonStatus.Online)
|
||||
res += String.Format(visSecStr, VisibilityWord(), SecurityWord());
|
||||
res += String.Format(visSecStr, SecurityWord());
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -540,5 +497,34 @@ namespace TGServerService
|
||||
return AwaitingShutdown != ShutdownRequestPhase.None;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string WorldAnnounce(string message)
|
||||
{
|
||||
var res = SendCommand(SCWorldAnnounce + ";message=" + message);
|
||||
if (res == "SUCCESS")
|
||||
return null;
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Webclient()
|
||||
{
|
||||
return Properties.Settings.Default.Webclient;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void SetWebclient(bool on)
|
||||
{
|
||||
var Config = Properties.Settings.Default;
|
||||
lock (watchdogLock) {
|
||||
var diff = on != Config.Webclient;
|
||||
if (diff)
|
||||
{
|
||||
Config.Webclient = on;
|
||||
RequestRestart();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace TGServerService
|
||||
|
||||
//this line basically says make one instance of the service, use it multithreaded for requests, and never delete it
|
||||
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.Single)]
|
||||
partial class TGStationServer : IDisposable, ITGSService, ITGServerUpdater
|
||||
partial class TGStationServer : IDisposable, ITGSService
|
||||
{
|
||||
|
||||
//call partial constructors/destructors from here
|
||||
@@ -32,59 +32,12 @@ namespace TGServerService
|
||||
DisposeChat();
|
||||
}
|
||||
|
||||
//public api
|
||||
public string Version()
|
||||
{
|
||||
return TGServerService.Version;
|
||||
}
|
||||
|
||||
//one stop update
|
||||
public string UpdateServer(TGRepoUpdateMethod updateType, bool push_changelog_if_enabled, ushort testmerge_pr)
|
||||
{
|
||||
try
|
||||
{
|
||||
string res;
|
||||
switch (updateType)
|
||||
{
|
||||
case TGRepoUpdateMethod.Hard:
|
||||
case TGRepoUpdateMethod.Merge:
|
||||
res = Update(updateType == TGRepoUpdateMethod.Hard);
|
||||
if (res != null && res != RepoErrorUpToDate)
|
||||
return res;
|
||||
break;
|
||||
case TGRepoUpdateMethod.Reset:
|
||||
res = Reset(true);
|
||||
if (res != null)
|
||||
return res;
|
||||
break;
|
||||
case TGRepoUpdateMethod.None:
|
||||
break;
|
||||
}
|
||||
|
||||
if (testmerge_pr != 0)
|
||||
{
|
||||
res = MergePullRequestImpl(testmerge_pr, true);
|
||||
if (res != null && res != RepoErrorUpToDate)
|
||||
return res;
|
||||
}
|
||||
|
||||
GenerateChangelog(out res);
|
||||
if (res == null && push_changelog_if_enabled && SSHAuth())
|
||||
{
|
||||
res = Commit();
|
||||
if (res == null)
|
||||
res = Push();
|
||||
}
|
||||
|
||||
if (!Compile(true))
|
||||
return "Compilation could not be started!";
|
||||
return res;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return e.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
//public api
|
||||
public void VerifyConnection() { }
|
||||
|
||||
|
||||
+29
-22
@@ -4,6 +4,7 @@ using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Web.Security;
|
||||
using TGServiceInterface;
|
||||
|
||||
@@ -23,17 +24,36 @@ namespace TGServerService
|
||||
const string SCHardReboot = "hard_reboot"; //requests that dreamdaemon restarts when the round ends
|
||||
const string SCGracefulShutdown = "graceful_shutdown"; //requests that dreamdaemon stops when the round ends
|
||||
const string SCWorldAnnounce = "world_announce"; //sends param 'message' to the world
|
||||
public const string SCIRCCheck = "irc_check"; //returns game stats
|
||||
public const string SCIRCStatus = "irc_status"; //returns admin stats
|
||||
public const string SCNameCheck = "namecheck"; //returns keywords lookup
|
||||
const string SCAdminPM = "adminmsg"; //pms a target ckey
|
||||
public const string SCAdminWho = "adminwho"; //lists admins
|
||||
const string SCListCustomCommands = "list_custom_commands"; //Get a list of commands supported by the server
|
||||
|
||||
const string SRKillProcess = "killme";
|
||||
const string SRIRCBroadcast = "irc";
|
||||
const string SRIRCAdminChannelMessage = "send2irc";
|
||||
const string SRWorldReboot = "worldreboot";
|
||||
|
||||
const string CCPHelpText = "help_text";
|
||||
const string CCPAdminOnly = "admin_only";
|
||||
const string CCPRequiredParameters = "required_parameters";
|
||||
|
||||
List<Command> ServerChatCommands;
|
||||
|
||||
void LoadServerChatCommands()
|
||||
{
|
||||
if (DaemonStatus() != TGDreamDaemonStatus.Online)
|
||||
return;
|
||||
var json = SendCommand(SCListCustomCommands);
|
||||
if (String.IsNullOrWhiteSpace(json))
|
||||
return;
|
||||
List<Command> tmp = new List<Command>();
|
||||
try
|
||||
{
|
||||
foreach(var I in new JavaScriptSerializer().Deserialize<IDictionary<string, IDictionary<string, object>>>(json))
|
||||
tmp.Add(new ServerChatCommand(I.Key, (string)I.Value[CCPHelpText], ((int)I.Value[CCPAdminOnly]) == 1, (int)I.Value[CCPRequiredParameters]));
|
||||
ServerChatCommands = tmp;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
//raw command string sent here via world.ExportService
|
||||
void HandleCommand(string cmd)
|
||||
{
|
||||
@@ -54,6 +74,7 @@ namespace TGServerService
|
||||
break;
|
||||
case SRWorldReboot:
|
||||
TGServerService.WriteInfo("World Rebooted", TGServerService.EventID.WorldReboot);
|
||||
ServerChatCommands = null;
|
||||
lock (CompilerLock)
|
||||
{
|
||||
if (UpdateStaged)
|
||||
@@ -76,21 +97,6 @@ namespace TGServerService
|
||||
}
|
||||
}
|
||||
|
||||
bool WorldAnnounce(string message)
|
||||
{
|
||||
return SendCommand(SCWorldAnnounce + ";message=" + message) == "SUCCESS" ;
|
||||
}
|
||||
|
||||
public string SendPM(string targetCkey, string sender, string message)
|
||||
{
|
||||
return SendCommand(String.Format("{3};target={0};sender={1};message={2}", targetCkey, sender, message, SCAdminPM));
|
||||
}
|
||||
|
||||
public string NameCheck(string targetCkey, string sender)
|
||||
{
|
||||
return SendCommand(String.Format("{2};target={0};sender={1}", targetCkey, sender, SCNameCheck));
|
||||
}
|
||||
|
||||
//Fuckery to diddle byond with the right packet to accept our girth
|
||||
string SendTopic(string topicdata, ushort port)
|
||||
{
|
||||
@@ -122,7 +128,7 @@ namespace TGServerService
|
||||
string returnedString = "NULL";
|
||||
try
|
||||
{
|
||||
var returnedData = new byte[512];
|
||||
var returnedData = new byte[UInt16.MaxValue];
|
||||
topicSender.Receive(returnedData);
|
||||
var raw_string = Encoding.ASCII.GetString(returnedData).TrimEnd(new char[] { (char)0 }).Trim();
|
||||
if (raw_string.Length > 6)
|
||||
@@ -247,7 +253,8 @@ namespace TGServerService
|
||||
catch (Exception e)
|
||||
{
|
||||
TGServerService.WriteError("Nudge handler thread crashed: " + e.ToString(), TGServerService.EventID.NudgeCrash);
|
||||
SendMessage("SERVICE: The relay handler crashed, use relayrestart to restore it! Error: " + e.Message, ChatMessageType.AdminInfo);
|
||||
SendMessage("SERVICE: The relay handler crashed, I will attempt to restore it when the server reboots! Error: " + e.Message, ChatMessageType.AdminInfo);
|
||||
RequestRestart();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+13
-13
@@ -12,7 +12,7 @@ namespace TGServerService.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.3.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
@@ -107,18 +107,6 @@ namespace TGServerService.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("2")]
|
||||
public int ServerVisiblity {
|
||||
get {
|
||||
return ((int)(this["ServerVisiblity"]));
|
||||
}
|
||||
set {
|
||||
this["ServerVisiblity"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("False")]
|
||||
@@ -238,5 +226,17 @@ namespace TGServerService.Properties {
|
||||
this["ReattachCommsKey"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("False")]
|
||||
public bool Webclient {
|
||||
get {
|
||||
return ((bool)(this["Webclient"]));
|
||||
}
|
||||
set {
|
||||
this["Webclient"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,9 +23,6 @@
|
||||
<Setting Name="ServerSecurity" Type="System.Int32" Scope="User">
|
||||
<Value Profile="(Default)">0</Value>
|
||||
</Setting>
|
||||
<Setting Name="ServerVisiblity" Type="System.Int32" Scope="User">
|
||||
<Value Profile="(Default)">2</Value>
|
||||
</Setting>
|
||||
<Setting Name="DDAutoStart" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
@@ -56,5 +53,8 @@
|
||||
<Setting Name="ReattachCommsKey" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="Webclient" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
@@ -300,6 +300,17 @@ namespace TGServerService
|
||||
SendMessage("REPO: Checking out object: " + sha, ChatMessageType.DeveloperInfo);
|
||||
try
|
||||
{
|
||||
if(Repo.Branches[sha] == null)
|
||||
{
|
||||
//see if origin has the branch
|
||||
var trackedBranch = Repo.Branches[String.Format("origin/{0}", sha)];
|
||||
if(trackedBranch != null)
|
||||
{
|
||||
var newBranch = Repo.CreateBranch(sha, trackedBranch.Tip);
|
||||
//track it
|
||||
Repo.Branches.Update(newBranch, b => b.TrackedBranch = trackedBranch.CanonicalName);
|
||||
}
|
||||
}
|
||||
var Opts = new CheckoutOptions()
|
||||
{
|
||||
CheckoutModifiers = CheckoutModifiers.Force,
|
||||
@@ -307,6 +318,7 @@ namespace TGServerService
|
||||
};
|
||||
Commands.Checkout(Repo, sha, Opts);
|
||||
var res = ResetNoLock(null);
|
||||
UpdateSubmodules();
|
||||
SendMessage("REPO: Checkout complete!", ChatMessageType.DeveloperInfo);
|
||||
TGServerService.WriteInfo("Repo checked out " + sha, TGServerService.EventID.RepoCheckout);
|
||||
return res;
|
||||
@@ -364,11 +376,12 @@ namespace TGServerService
|
||||
};
|
||||
fos.OnTransferProgress += HandleTransferProgress;
|
||||
Commands.Fetch(Repo, R.Name, refSpecs, fos, logMessage);
|
||||
|
||||
|
||||
var originBranch = Repo.Head.TrackedBranch;
|
||||
if (reset)
|
||||
{
|
||||
var error = ResetNoLock(Repo.Head.TrackedBranch);
|
||||
UpdateSubmodules();
|
||||
if (error != null)
|
||||
throw new Exception(error);
|
||||
DeletePRList();
|
||||
@@ -378,6 +391,7 @@ namespace TGServerService
|
||||
var res = MergeBranch(originBranch.FriendlyName);
|
||||
if (res != null)
|
||||
throw new Exception(res);
|
||||
UpdateSubmodules();
|
||||
TGServerService.WriteInfo("Repo merge updated to " + originBranch.Tip.Sha, TGServerService.EventID.RepoMergeUpdate);
|
||||
return null;
|
||||
}
|
||||
@@ -390,6 +404,35 @@ namespace TGServerService
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSubmodules()
|
||||
{
|
||||
var suo = new SubmoduleUpdateOptions
|
||||
{
|
||||
Init = true
|
||||
};
|
||||
foreach (var I in Repo.Submodules)
|
||||
try
|
||||
{
|
||||
Repo.Submodules.Update(I.Name, suo);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//workaround for https://github.com/libgit2/libgit2/issues/3820
|
||||
//kill off the modules/ folder in .git and try again
|
||||
try
|
||||
{
|
||||
Program.DeleteDirectory(String.Format("{0}/.git/modules/{1}", RepoPath, I.Path));
|
||||
}
|
||||
catch {
|
||||
throw e;
|
||||
}
|
||||
Repo.Submodules.Update(I.Name, suo);
|
||||
var msg = String.Format("I had to reclone submodule {0}. If this is happening a lot find a better hack or fix https://github.com/libgit2/libgit2/issues/3820!", I.Name);
|
||||
SendMessage(String.Format("REPO: {0}", msg), ChatMessageType.DeveloperInfo);
|
||||
TGServerService.WriteWarning(msg, TGServerService.EventID.SubmoduleReclone);
|
||||
}
|
||||
}
|
||||
|
||||
string CreateBackup()
|
||||
{
|
||||
try
|
||||
@@ -557,6 +600,16 @@ namespace TGServerService
|
||||
//so we'll know if this fails
|
||||
var Result = MergeBranch(LocalBranchName);
|
||||
|
||||
if (Result == null)
|
||||
try
|
||||
{
|
||||
UpdateSubmodules();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Result = e.ToString();
|
||||
}
|
||||
|
||||
if (Result == null)
|
||||
{
|
||||
TGServerService.WriteInfo(String.Format("Merged pull request #{0}", PRNumber), TGServerService.EventID.RepoPRMerge);
|
||||
@@ -671,7 +724,32 @@ namespace TGServerService
|
||||
}
|
||||
}
|
||||
|
||||
//public api
|
||||
public string PushChangelog()
|
||||
{
|
||||
if (!SSHAuth())
|
||||
return null;
|
||||
return LocalIsRemote() ? Commit() ?? Push() : "Can't push changelog: HEAD does not match tracked remote branch";
|
||||
}
|
||||
|
||||
bool LocalIsRemote()
|
||||
{
|
||||
lock (RepoLock)
|
||||
{
|
||||
if (LoadRepo() != null)
|
||||
return false;
|
||||
var R = Repo.Network.Remotes["origin"];
|
||||
try
|
||||
{
|
||||
Commands.Fetch(Repo, R.Name, R.FetchRefSpecs.Select(X => X.Specification), null, null);
|
||||
return Repo.Head.IsTracking && Repo.Head.TrackedBranch.Tip.Sha == Repo.Head.Tip.Sha;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string Commit()
|
||||
{
|
||||
lock (RepoLock)
|
||||
|
||||
@@ -75,7 +75,8 @@ namespace TGServerService
|
||||
ServerUpdateApplied = 6300,
|
||||
ChatBroadcastFail = 6400,
|
||||
IRCLogModes = 6500,
|
||||
InteropCallException = 6600,
|
||||
SubmoduleReclone = 6600,
|
||||
InteropCallException = 6700,
|
||||
}
|
||||
|
||||
static TGServerService ActiveService; //So everyone else can write to our eventlog
|
||||
|
||||
@@ -39,26 +39,7 @@ namespace TGServiceInterface
|
||||
/// </summary>
|
||||
Ultrasafe
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DreamDaemon's hub visibility
|
||||
/// </summary>
|
||||
public enum TGDreamDaemonVisibility
|
||||
{
|
||||
/// <summary>
|
||||
/// Server will be visible on the hub
|
||||
/// </summary>
|
||||
Public,
|
||||
/// <summary>
|
||||
/// Server will not be visible on the hub to anyone but the host's friends. Since the service does not have a BYOND account, this is effectively the same as Invisible
|
||||
/// </summary>
|
||||
Private,
|
||||
/// <summary>
|
||||
/// Server will not be visible on the hub
|
||||
/// </summary>
|
||||
Invisible = 2, //default config
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Interface for managing the actual BYOND game server
|
||||
/// </summary>
|
||||
@@ -140,22 +121,6 @@ namespace TGServiceInterface
|
||||
[OperationContract]
|
||||
bool SetSecurityLevel(TGDreamDaemonSecurity level);
|
||||
|
||||
/// <summary>
|
||||
/// Get the configured (not running) visibility level
|
||||
/// </summary>
|
||||
/// <returns>The configured (not running) visibility level</returns>
|
||||
[OperationContract]
|
||||
TGDreamDaemonVisibility VisibilityLevel();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the visiblity level of the server. Requires reboot to apply
|
||||
/// Implies a call to RequestRestart()
|
||||
/// </summary>
|
||||
/// <param name="vis">The new visibility level</param>
|
||||
/// <returns>True if the change was immediately applied, false if a graceful restart was queued</returns>
|
||||
[OperationContract]
|
||||
bool SetVisibility(TGDreamDaemonVisibility vis);
|
||||
|
||||
/// <summary>
|
||||
/// Get the configured port. Not necessarily the running port if it has since changed
|
||||
/// </summary>
|
||||
@@ -185,11 +150,33 @@ namespace TGServiceInterface
|
||||
[OperationContract]
|
||||
void SetAutostart(bool on);
|
||||
|
||||
/// <summary>
|
||||
/// Check if the byond webclient is currently enabled for the server
|
||||
/// </summary>
|
||||
/// <returns>true if the webclient is enabled, false otherwise</returns>
|
||||
[OperationContract]
|
||||
bool Webclient();
|
||||
|
||||
/// <summary>
|
||||
/// Set the webclient config. Calls <see cref="RequestRestart"/>
|
||||
/// </summary>
|
||||
/// <param name="on">true to enable the byond webclient for the server, false otherwise</param>
|
||||
[OperationContract]
|
||||
void SetWebclient(bool on);
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a server stop has bee requested
|
||||
/// </summary>
|
||||
/// <returns>true if RequestStop has been called since the last server start, false otherwise</returns>
|
||||
[OperationContract]
|
||||
bool ShutdownInProgress();
|
||||
|
||||
/// <summary>
|
||||
/// Sends a message to everyone on the server
|
||||
/// </summary>
|
||||
/// <param name="msg">The message to send</param>
|
||||
/// <returns>null on success, error message on failure</returns>
|
||||
[OperationContract]
|
||||
string WorldAnnounce(string msg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,6 +187,13 @@ namespace TGServiceInterface
|
||||
[OperationContract]
|
||||
string GenerateChangelog(out string error);
|
||||
|
||||
/// <summary>
|
||||
/// Pushes the changelog to the currently git, this operation will only run if the changelog is the only difference to be pushed (i.e. no PRs merged)
|
||||
/// </summary>
|
||||
/// <returns>null on success, error on failure</returns>
|
||||
[OperationContract]
|
||||
string PushChangelog();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the path to the python 2.7 installation
|
||||
/// </summary>
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace TGServiceInterface
|
||||
/// <summary>
|
||||
/// List of types that can be used with GetComponen
|
||||
/// </summary>
|
||||
public static readonly IList<Type> ValidInterfaces = new List<Type> { typeof(ITGByond), typeof(ITGChat), typeof(ITGCompiler), typeof(ITGConfig), typeof(ITGDreamDaemon), typeof(ITGRepository), typeof(ITGServerUpdater), typeof(ITGSService), typeof(ITGServiceBridge) };
|
||||
public static readonly IList<Type> ValidInterfaces = new List<Type> { typeof(ITGByond), typeof(ITGChat), typeof(ITGCompiler), typeof(ITGConfig), typeof(ITGDreamDaemon), typeof(ITGRepository), typeof(ITGSService), typeof(ITGServiceBridge) };
|
||||
|
||||
/// <summary>
|
||||
/// Base name of the communication pipe
|
||||
@@ -81,6 +81,7 @@ namespace TGServiceInterface
|
||||
[OperationContract]
|
||||
string Version();
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
|
||||
/// <summary>
|
||||
/// How to modify the repo during the UpdateServer operation
|
||||
@@ -158,4 +159,6 @@ namespace TGServiceInterface
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
=======
|
||||
>>>>>>> bb1f31822a7e3adcdb8441fa765cfe8916a83adc
|
||||
}
|
||||
|
||||
+3
-3
@@ -12,6 +12,6 @@ using System.Reflection;
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
//It's impossible to make these a define, don't say I didn't warn you
|
||||
[assembly: AssemblyVersion("3.0.89.0")]
|
||||
[assembly: AssemblyFileVersion("3.0.89.0")]
|
||||
[assembly: AssemblyInformationalVersion("3.0.89.0")]
|
||||
[assembly: AssemblyVersion("3.0.90.2")]
|
||||
[assembly: AssemblyFileVersion("3.0.90.2")]
|
||||
[assembly: AssemblyInformationalVersion("3.0.90.2")]
|
||||
|
||||
Reference in New Issue
Block a user