Run install scripts
This commit is contained in:
@@ -148,7 +148,7 @@ public class PluginManager
|
|||||||
{
|
{
|
||||||
installProgress?.Report(0f);
|
installProgress?.Report(0f);
|
||||||
|
|
||||||
int totalSteps = pluginData.HasDependencies ? pluginData.Dependencies.Count + 1 : 1;
|
int totalSteps = pluginData.HasDependencies ? pluginData.Dependencies.Count + pluginData.ScriptDependencies.Count + 1: 1;
|
||||||
|
|
||||||
float stepProgress = 1f / totalSteps;
|
float stepProgress = 1f / totalSteps;
|
||||||
|
|
||||||
@@ -166,9 +166,21 @@ public class PluginManager
|
|||||||
currentProgress += stepProgress;
|
currentProgress += stepProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginInfo pluginInfo = new PluginInfo(pluginData.Name,
|
foreach(var scriptDependency in pluginData.ScriptDependencies)
|
||||||
|
{
|
||||||
|
|
||||||
|
string console = OperatingSystem.IsWindows() ? "cmd" : "bash";
|
||||||
|
string arguments = OperatingSystem.IsWindows() ? $"/c {scriptDependency.ScriptContent}" : scriptDependency.ScriptContent;
|
||||||
|
|
||||||
|
await ServerCom.RunConsoleCommand(console, arguments);
|
||||||
|
currentProgress += stepProgress;
|
||||||
|
}
|
||||||
|
|
||||||
|
PluginInfo pluginInfo = new PluginInfo(
|
||||||
|
pluginData.Name,
|
||||||
pluginData.Version,
|
pluginData.Version,
|
||||||
pluginData.Dependencies.Select(dep => dep.DownloadLocation).ToList());
|
pluginData.Dependencies.Select(dep => dep.DownloadLocation).ToList()
|
||||||
|
);
|
||||||
|
|
||||||
await AppendPluginToDatabase(pluginInfo);
|
await AppendPluginToDatabase(pluginInfo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
@@ -75,4 +76,15 @@ public static class ServerCom
|
|||||||
return DownloadFileAsync(URl, location, progress, null);
|
return DownloadFileAsync(URl, location, progress, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async Task<string> RunConsoleCommand(string console, string command)
|
||||||
|
{
|
||||||
|
Process process = new();
|
||||||
|
process.StartInfo.FileName = console;
|
||||||
|
process.StartInfo.Arguments = command;
|
||||||
|
process.Start();
|
||||||
|
await process.WaitForExitAsync();
|
||||||
|
return await process.StandardOutput.ReadToEndAsync();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user