From 722606b419df8fd722961d57b3cbeefb3a2fab23 Mon Sep 17 00:00:00 2001 From: Ocawesome101 <50844998+Ocawesome101@users.noreply.github.com> Date: Thu, 18 Jun 2020 16:01:42 -0400 Subject: [PATCH 1/2] Add Monolith loader This is untested as I unfortunately couldn't get Zorya to build. --- mods/loader_monolith/init.lua | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 mods/loader_monolith/init.lua diff --git a/mods/loader_monolith/init.lua b/mods/loader_monolith/init.lua new file mode 100644 index 0000000..bb5e9f9 --- /dev/null +++ b/mods/loader_monolith/init.lua @@ -0,0 +1,35 @@ +-- monolith loader -- +local zy = krequire("zorya") +local utils = krequire("utils") +local thd = krequire("thd") +local vdev = krequire("util_vcomponent") +local function proxytable(t) + return setmetatable({}, {__index=function(self, i) + if (type(t[i]) == "table") then + self[i] = proxytable(t[i]) + return rawget(self, i) + else + return t[i] + end + end}) +end +local monolith_count = 0 +return function(addr) + local fs = component.proxy(addr) + thd.add("monolith$"..monolith_count, function() + local env = utils.make_env() + function env.computer.getBootAddress() + return addr + end + function env.computer.setBootAddress()end + local old_dl = utils.debug_log + load(utils.readfile(fs.address, fs.open("/boot/kernel/loader")), "=/boot/kernel/loader", "t", env)() + computer.pushSignal("monolith_dead") + end) + while true do + if computer.pullSignal() == "monolith_dead" then + utils.debug_log("Got signal.") + break + end + end +end From 813bf473193ba1466fd4ffcd7838dc150bf5ec3b Mon Sep 17 00:00:00 2001 From: Ocawesome101 <50844998+Ocawesome101@users.noreply.github.com> Date: Thu, 18 Jun 2020 17:02:05 -0400 Subject: [PATCH 2/2] Add monolith detection --- util/OpenOS/config.d/05_monolith.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 util/OpenOS/config.d/05_monolith.lua diff --git a/util/OpenOS/config.d/05_monolith.lua b/util/OpenOS/config.d/05_monolith.lua new file mode 100644 index 0000000..aec12b2 --- /dev/null +++ b/util/OpenOS/config.d/05_monolith.lua @@ -0,0 +1,12 @@ +local cfgadd = ... +local component = require("component") +for fs in component.list("filesystem") do + if (component.invoke(fs, "getLabel") == "Monolith" or component.invoke(fs, "exists", "/boot/monolith")) and component.invoke(fs, "exists", "init.lua") then + print("Monolith discovered on " .. fs) + cfgadd(string.format([[ +menu.add("Monolith on %s", function() + return loadmod("loader_monolith")("%s") +end) + ]], fs:sub(1,3), fs)) + end +end