Skip to content

Commit 85f1272

Browse files
committed
updated configuration script
1 parent 15d0ef0 commit 85f1272

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/OneOS-Core/Program.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ files including the configuration file. If the configuration file does
145145
// if entry address is not given, pick from one of the peers
146146
var config = Configuration.LoadConfig(mountPath);
147147
var random = new Random();
148-
var peerAddress = arguments.Count > 1 ? IPEndPoint.Parse(arguments[1]) : config.Peers.Values.ToList()[random.Next(0, config.Peers.Count)];
148+
var peerAddress = arguments.Count > 1 ? IPEndPoint.Parse(arguments[1]) : (config.Peers.Count > 0 ? config.Peers.Values.ToList()[random.Next(0, config.Peers.Count)] : IPEndPoint.Parse($"127.0.0.1:{config.Port}"));
149149

150150
Console.WriteLine($"Starting OneOS Terminal");
151151
var terminal = new Terminal(peerAddress);

src/OneOS/Runtime/Configuration.cs

+27
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ public static void CreateOrUpdateConfig(string mountPath = null)
9090
{
9191
if (mountPath == null) mountPath = OneOSPath;
9292

93+
// look for home directory
94+
if (!Directory.Exists(mountPath))
95+
{
96+
Console.WriteLine($"{mountPath} directory not found. Creating ...");
97+
Directory.CreateDirectory(mountPath);
98+
};
99+
93100
string configPath = Path.Combine(mountPath, "config.json");
94101

95102
var json = JObject.Parse("{}");
@@ -335,6 +342,26 @@ static JObject RunInteractiveConfigSetup(string mountPath = null, JObject json =
335342
vmAgents.Add(vmConfig);
336343
}
337344

345+
// io drivers
346+
if (!json.ContainsKey("io")) json["io"] = JArray.Parse("[]");
347+
348+
JArray ioAgents = (JArray)json["io"];
349+
350+
Console.WriteLine($"Current list of IO Agents - {ioAgents.Count} agents:\n{string.Join("\n", ioAgents.Select(item => " - " + ((JObject)item)["name"].ToObject<string>()))}");
351+
352+
while (Ask("Add an IO Agent? (y/n)") == "y")
353+
{
354+
string ioName = Ask("IO name (will be used in the public URI of the VM agent - e.g.: ffmpeg-1): ");
355+
string ioDriver = Ask("IO driver (e.g.: ffmpeg): ");
356+
357+
var ioConfig = new JObject();
358+
ioConfig["name"] = ioName;
359+
ioConfig["driver"] = ioDriver;
360+
ioConfig["args"] = new JArray();
361+
362+
ioAgents.Add(ioConfig);
363+
}
364+
338365
// cpu allocation
339366
if (!json.ContainsKey("cores")) json["cores"] = JArray.Parse("[ 0, 0 ]");
340367

0 commit comments

Comments
 (0)