diff --git a/appveyor.yml b/appveyor.yml
index 98c9cb64f1..f326ed3b2d 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -16,12 +16,15 @@ configuration:
shallow_clone: true
artifacts:
- path: artifacts/ServerConsole
+ name: Server Console
+ - path: artifacts/ServerService
+ name: Server Service
cache:
- ~\.nuget\packages -> **\*.csproj
- C:\ProgramData\chocolatey\bin -> appveyor.yml
- C:\ProgramData\chocolatey\lib -> appveyor.yml
install:
- - choco install fciv doxygen.portable codecov
+ - choco install doxygen.portable codecov
- nuget restore tgstation-server.sln
build:
project: tgstation-server.sln
@@ -53,6 +56,7 @@ after_test:
- ps: build/UploadCoverage.ps1
- ps: build/BuildDox.ps1
- dotnet publish src/Tgstation.Server.Host.Console/Tgstation.Server.Host.Console.csproj -o ../../artifacts/ServerConsole -c %CONFIGURATION%
+ - ps: Copy-Item -path "src/Tgstation.Server.Host.Service/bin/$env:CONFIGURATION" -destination ../../artifacts/ServerService -recurse
deploy:
- provider: GitHub
release: "tgstation-server-v$(TGSVersion)"
diff --git a/src/Tgstation.Server.Api/Models/Administration.cs b/src/Tgstation.Server.Api/Models/Administration.cs
index 640a5c65ac..9e51bd7d3c 100644
--- a/src/Tgstation.Server.Api/Models/Administration.cs
+++ b/src/Tgstation.Server.Api/Models/Administration.cs
@@ -5,14 +5,8 @@ using Tgstation.Server.Api.Rights;
namespace Tgstation.Server.Api.Models
{
///
- public sealed class Administration : Internal.ServerSettings
+ public sealed class Administration
{
- ///
- /// If the instances will not be stopped when the server exits. Resets to when the server restarts
- ///
- [Permissions(ReadRight = AdministrationRights.SoftStop, WriteRight = AdministrationRights.SoftStop)]
- public bool SoftStop { get; set; }
-
///
/// The latest available version of the Tgstation.Server.Host assembly from the upstream repository. If is higher than 's the update cannot be applied due to API changes
///
diff --git a/src/Tgstation.Server.Api/Models/Byond.cs b/src/Tgstation.Server.Api/Models/Byond.cs
index 6654babe0a..17f5b1456c 100644
--- a/src/Tgstation.Server.Api/Models/Byond.cs
+++ b/src/Tgstation.Server.Api/Models/Byond.cs
@@ -9,22 +9,10 @@ namespace Tgstation.Server.Api.Models
[Model(RightsType.Byond, RequiresInstance = true)]
public sealed class Byond
{
- ///
- /// The for the installation
- ///
- [Permissions(DenyWrite = true, ReadRight = ByondRights.ReadStatus)]
- public ByondStatus ByondStatus { get; set; }
-
///
/// The of the installation used for new compiles. Will be if the user does not have permission to view it or there is no BYOND version installed. Only considers the and numbers
///
- [Permissions(ReadRight = ByondRights.ReadInstalled, WriteRight = ByondRights.ChangeVersion)]
+ [Permissions(ReadRight = ByondRights.ReadActive, WriteRight = ByondRights.ChangeVersion)]
public Version Version { get; set; }
-
- ///
- /// The of the that's currently running the game servers
- ///
- [Permissions(DenyWrite = true, ReadRight = ByondRights.ReadPrevious)]
- public Version PreviousVersion { get; set; }
}
}
diff --git a/src/Tgstation.Server.Api/Models/ByondStatus.cs b/src/Tgstation.Server.Api/Models/ByondStatus.cs
deleted file mode 100644
index 638a91e475..0000000000
--- a/src/Tgstation.Server.Api/Models/ByondStatus.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-namespace Tgstation.Server.Api.Models
-{
- ///
- /// The status of a update job
- ///
-#pragma warning disable CA1717 // Only FlagsAttribute enums should have plural names
- public enum ByondStatus
-#pragma warning restore CA1717 // Only FlagsAttribute enums should have plural names
- {
- ///
- /// No update in progress
- ///
- Idle,
- ///
- /// Preparing to update
- ///
- Starting,
- ///
- /// Revision is downloading
- ///
- Downloading,
- ///
- /// Revision is deflating
- ///
- Staging,
- ///
- /// Revision is ready and waiting for DreamDaemon reboot
- ///
- Staged,
- ///
- /// Revision is being applied
- ///
- Updating,
- ///
- /// User does not have permission to view the
- ///
- Hidden,
- }
-}
diff --git a/src/Tgstation.Server.Api/Models/Internal/ServerSettings.cs b/src/Tgstation.Server.Api/Models/Internal/ServerSettings.cs
deleted file mode 100644
index 3ab52adef5..0000000000
--- a/src/Tgstation.Server.Api/Models/Internal/ServerSettings.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using Tgstation.Server.Api.Rights;
-
-namespace Tgstation.Server.Api.Models.Internal
-{
- ///
- /// Metadata about an installation
- ///
- [Model(RightsType.Administration)]
- public class ServerSettings
- {
- ///
- /// Automatically send unhandled exception data to a public collection service. This will be limited to system information, path data, and game code compilation information.
- ///
- [Permissions(ReadRight = AdministrationRights.ChangeTelemetry, WriteRight = AdministrationRights.ChangeTelemetry)]
- public bool EnableTelemetry { get; set; }
-
- ///
- /// The git repository URL to recieve updates to Tgstation.Server.Host from, must include credentials if necessary. If set to upstream pulls will be disabled entirely. Should be https://github.com/tgstation/tgstation-server or a fork of it
- ///
- [Permissions(ReadRight = AdministrationRights.SetUpstreamRepository, WriteRight = AdministrationRights.SetUpstreamRepository)]
- public string UpstreamRepository { get; set; }
- }
-}
diff --git a/src/Tgstation.Server.Api/Rights/AdministrationRights.cs b/src/Tgstation.Server.Api/Rights/AdministrationRights.cs
index c8992b3575..58f208711c 100644
--- a/src/Tgstation.Server.Api/Rights/AdministrationRights.cs
+++ b/src/Tgstation.Server.Api/Rights/AdministrationRights.cs
@@ -13,24 +13,16 @@ namespace Tgstation.Server.Api.Rights
///
None = 0,
///
- /// User can change
- ///
- SetUpstreamRepository = 1,
- ///
- /// User can change
- ///
- ChangeTelemetry = 2,
- ///
/// User can edit themself and other s
///
- EditUsers = 4,
+ EditUsers = 1,
///
- /// User can change
+ /// User can gracefully restart the host
///
- SoftStop = 8,
+ SoftStop = 2,
///
/// User can change
///
- ChangeVersion = 16
+ ChangeVersion = 4
}
}
diff --git a/src/Tgstation.Server.Api/Rights/ByondRights.cs b/src/Tgstation.Server.Api/Rights/ByondRights.cs
index 142ea098b4..ae650b69af 100644
--- a/src/Tgstation.Server.Api/Rights/ByondRights.cs
+++ b/src/Tgstation.Server.Api/Rights/ByondRights.cs
@@ -13,24 +13,12 @@ namespace Tgstation.Server.Api.Rights
///
None = 0,
///
- /// User may check the installed BYOND version
+ /// User may check the active installed BYOND version
///
- ReadInstalled = 1,
- ///
- /// User may check the previous BYOND version
- ///
- ReadPrevious = 2,
+ ReadActive = 1,
///
/// User may change to any BYOND version
///
- ChangeVersion = 4,
- ///
- /// User may cancel a pending installation job
- ///
- Cancel = 8,
- ///
- /// User may read the of the installation job
- ///
- ReadStatus = 16,
+ ChangeVersion = 4
}
}
diff --git a/src/Tgstation.Server.Client/Components/IByondClient.cs b/src/Tgstation.Server.Client/Components/IByondClient.cs
index f7e064e0b2..9f9d8421c6 100644
--- a/src/Tgstation.Server.Client/Components/IByondClient.cs
+++ b/src/Tgstation.Server.Client/Components/IByondClient.cs
@@ -21,10 +21,9 @@ namespace Tgstation.Server.Client.Components
///
/// Updates the installed BYOND
///
- /// The to update
- /// Optional taking a to run when it changes
+ /// The to set to active
/// The for the operation
/// A representing the running operation
- Task Update(Byond byond, Action progressCallback, CancellationToken cancellationToken);
+ Task SetActiveVersion(Version version, CancellationToken cancellationToken);
}
}
diff --git a/src/Tgstation.Server.Host/Components/ByondExecutableLock.cs b/src/Tgstation.Server.Host/Components/ByondExecutableLock.cs
new file mode 100644
index 0000000000..2be7ab498a
--- /dev/null
+++ b/src/Tgstation.Server.Host/Components/ByondExecutableLock.cs
@@ -0,0 +1,26 @@
+using System;
+
+namespace Tgstation.Server.Host.Components
+{
+ ///
+ sealed class ByondExecutableLock : IByondExecutableLock
+ {
+ ///
+ public Version Version { get; set; }
+
+ ///
+ public string DreamDaemonPath { get; set; }
+
+ ///
+ public string DreamMakerPath { get; set; }
+
+ //at one point in design, byond versions were to delete themselves if they werent the active version
+ //That changed at some point so these functions are intentioanlly left blank
+
+ ///
+ public void Dispose() { }
+
+ ///
+ public void DoNotDeleteThisSession() { }
+ }
+}
diff --git a/src/Tgstation.Server.Host/Components/ByondManager.cs b/src/Tgstation.Server.Host/Components/ByondManager.cs
new file mode 100644
index 0000000000..e046bcf56c
--- /dev/null
+++ b/src/Tgstation.Server.Host/Components/ByondManager.cs
@@ -0,0 +1,166 @@
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.IO.Compression;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Tgstation.Server.Host.IO;
+
+using MemoryStream = System.IO.MemoryStream;
+
+namespace Tgstation.Server.Host.Components
+{
+ ///
+ sealed class ByondManager : IByondManager
+ {
+ const string VersionFileName = "Version.txt";
+ const string ActiveVersionFileName = "ActiveVersion.txt";
+
+ const string BinPath = "byond/bin";
+
+ ///
+ public Version ActiveVersion { get; private set; }
+
+ ///
+ /// The for the
+ ///
+ readonly IIOManager ioManager;
+
+ ///
+ /// The for the
+ ///
+ readonly IByondInstaller byondInstaller;
+
+ ///
+ /// The for the
+ ///
+ readonly ILogger logger;
+
+ ///
+ /// Map of byond s to s that complete when they are installed
+ ///
+ readonly Dictionary installedVersions;
+
+ ///
+ /// Construct a
+ ///
+ /// The value of
+ /// The value of
+ /// The value of
+ public ByondManager(IIOManager ioManager, IByondInstaller byondInstaller, ILogger logger)
+ {
+ this.ioManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager));
+ this.byondInstaller = byondInstaller ?? throw new ArgumentNullException(nameof(byondInstaller));
+ this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
+
+ installedVersions = new Dictionary();
+ }
+
+ static string VersionKey(Version version) => new Version(version.Major, version.Minor).ToString();
+
+ async Task InstallVersion(Version version, CancellationToken cancellationToken)
+ {
+ var ourTcs = new TaskCompletionSource