diff --git a/src/Tgstation.Server.Host/Components/Byond/ByondManager.cs b/src/Tgstation.Server.Host/Components/Byond/ByondManager.cs
index f051d38dd1..638d6b612c 100644
--- a/src/Tgstation.Server.Host/Components/Byond/ByondManager.cs
+++ b/src/Tgstation.Server.Host/Components/Byond/ByondManager.cs
@@ -13,11 +13,14 @@ namespace Tgstation.Server.Host.Components.Byond
///
sealed class ByondManager : IByondManager
{
+ ///
+ /// The path to the BYOND bin folder
+ ///
+ public const string BinPath = "byond/bin";
+
const string VersionFileName = "Version.txt";
const string ActiveVersionFileName = "ActiveVersion.txt";
- const string BinPath = "byond/bin";
-
///
public Version ActiveVersion { get; private set; }
diff --git a/src/Tgstation.Server.Host/Components/Byond/PosixByondInstaller.cs b/src/Tgstation.Server.Host/Components/Byond/PosixByondInstaller.cs
index ded0d06a1e..19b62b0795 100644
--- a/src/Tgstation.Server.Host/Components/Byond/PosixByondInstaller.cs
+++ b/src/Tgstation.Server.Host/Components/Byond/PosixByondInstaller.cs
@@ -2,8 +2,10 @@
using System;
using System.Globalization;
using System.Net;
+using System.Text;
using System.Threading;
using System.Threading.Tasks;
+using Tgstation.Server.Host.Core;
using Tgstation.Server.Host.IO;
namespace Tgstation.Server.Host.Components.Byond
@@ -23,16 +25,21 @@ namespace Tgstation.Server.Host.Components.Byond
const string ByondCachePath = "~/.byond/cache";
///
- public string DreamDaemonName => "DreamDaemon";
+ public string DreamDaemonName => "DreamDaemon.sh";
///
- public string DreamMakerName => "DreamMaker";
+ public string DreamMakerName => "DreamMaker.sh";
///
/// The for the
///
readonly IIOManager ioManager;
+ ///
+ /// The for the
+ ///
+ readonly IPostWriteHandler postWriteHandler;
+
///
/// The for the
///
@@ -42,10 +49,12 @@ namespace Tgstation.Server.Host.Components.Byond
/// Construct a
///
/// The value of
+ /// The value of
/// The value of
- public PosixByondInstaller(IIOManager ioManager, ILogger logger)
+ public PosixByondInstaller(IIOManager ioManager, IPostWriteHandler postWriteHandler, ILogger logger)
{
this.ioManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager));
+ this.postWriteHandler = postWriteHandler ?? throw new ArgumentNullException(nameof(postWriteHandler));
this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
@@ -88,6 +97,24 @@ namespace Tgstation.Server.Host.Components.Byond
}
///
- public Task InstallByond(string path, Version version, CancellationToken cancellationToken) => Task.CompletedTask;
+ public Task InstallByond(string path, Version version, CancellationToken cancellationToken)
+ {
+ //write the scripts for running the ting
+ //need to add $ORIGIN to LD_LIBRARY_PATH
+ const string StandardScript = "#!/bin/sh\nexport LD_LIBRARY_PATH=\"\\$ORIGIN:$LD_LIBRARY_PATH\"\nBASEDIR=$(dirname \"$0\")\nexec \"$BASEDIR/{0}\" \"$@\"\n";
+
+ var dreamDaemonScript = String.Format(CultureInfo.InvariantCulture, StandardScript, "DreamDaemon");
+ var dreamMakerScript = String.Format(CultureInfo.InvariantCulture, StandardScript, "DreamMaker");
+
+ async Task WriteAndMakeExecutable(string fullPath, string script)
+ {
+ await ioManager.WriteAllBytes(fullPath, Encoding.ASCII.GetBytes(script), cancellationToken).ConfigureAwait(false);
+ postWriteHandler.HandleWrite(fullPath);
+ }
+
+ var basePath = ioManager.ConcatPath(path, ByondManager.BinPath);
+
+ return Task.WhenAll(WriteAndMakeExecutable(ioManager.ConcatPath(basePath, DreamDaemonName), dreamDaemonScript), WriteAndMakeExecutable(ioManager.ConcatPath(basePath, DreamMakerName), dreamMakerScript));
+ }
}
}
diff --git a/src/Tgstation.Server.Host/Core/Application.cs b/src/Tgstation.Server.Host/Core/Application.cs
index eaa3e40521..b0218e2dc4 100644
--- a/src/Tgstation.Server.Host/Core/Application.cs
+++ b/src/Tgstation.Server.Host/Core/Application.cs
@@ -21,7 +21,6 @@ using System.Threading.Tasks;
using Tgstation.Server.Host.Components;
using Tgstation.Server.Host.Components.Byond;
using Tgstation.Server.Host.Components.Chat;
-using Tgstation.Server.Host.Components.StaticFiles;
using Tgstation.Server.Host.Components.Watchdog;
using Tgstation.Server.Host.Configuration;
using Tgstation.Server.Host.Controllers;
diff --git a/src/Tgstation.Server.Host/Components/StaticFiles/IPostWriteHandler.cs b/src/Tgstation.Server.Host/Core/IPostWriteHandler.cs
similarity index 81%
rename from src/Tgstation.Server.Host/Components/StaticFiles/IPostWriteHandler.cs
rename to src/Tgstation.Server.Host/Core/IPostWriteHandler.cs
index a1db4b8d37..7209b44761 100644
--- a/src/Tgstation.Server.Host/Components/StaticFiles/IPostWriteHandler.cs
+++ b/src/Tgstation.Server.Host/Core/IPostWriteHandler.cs
@@ -1,4 +1,4 @@
-namespace Tgstation.Server.Host.Components.StaticFiles
+namespace Tgstation.Server.Host.Core
{
interface IPostWriteHandler
{
diff --git a/src/Tgstation.Server.Host/Components/StaticFiles/PosixPostWriteHandler.cs b/src/Tgstation.Server.Host/Core/PosixPostWriteHandler.cs
similarity index 92%
rename from src/Tgstation.Server.Host/Components/StaticFiles/PosixPostWriteHandler.cs
rename to src/Tgstation.Server.Host/Core/PosixPostWriteHandler.cs
index a028fe1c03..d121d2bca8 100644
--- a/src/Tgstation.Server.Host/Components/StaticFiles/PosixPostWriteHandler.cs
+++ b/src/Tgstation.Server.Host/Core/PosixPostWriteHandler.cs
@@ -1,7 +1,7 @@
using Mono.Unix;
using Mono.Unix.Native;
-namespace Tgstation.Server.Host.Components.StaticFiles
+namespace Tgstation.Server.Host.Core
{
///
/// for POSIX systems
diff --git a/src/Tgstation.Server.Host/Components/StaticFiles/ServerSideModifications.cs b/src/Tgstation.Server.Host/Core/ServerSideModifications.cs
similarity index 100%
rename from src/Tgstation.Server.Host/Components/StaticFiles/ServerSideModifications.cs
rename to src/Tgstation.Server.Host/Core/ServerSideModifications.cs
diff --git a/src/Tgstation.Server.Host/Components/StaticFiles/WindowsPostWriteHandler.cs b/src/Tgstation.Server.Host/Core/WindowsPostWriteHandler.cs
similarity index 79%
rename from src/Tgstation.Server.Host/Components/StaticFiles/WindowsPostWriteHandler.cs
rename to src/Tgstation.Server.Host/Core/WindowsPostWriteHandler.cs
index 61c8431662..42ed2cdf1b 100644
--- a/src/Tgstation.Server.Host/Components/StaticFiles/WindowsPostWriteHandler.cs
+++ b/src/Tgstation.Server.Host/Core/WindowsPostWriteHandler.cs
@@ -1,4 +1,4 @@
-namespace Tgstation.Server.Host.Components.StaticFiles
+namespace Tgstation.Server.Host.Core
{
///
/// for Windows systems