Added new package

This commit is contained in:
2025-11-05 23:35:45 +01:00
parent 8cea5151b0
commit d518637947
8 changed files with 188 additions and 100 deletions

37
etc/rc.d/ocnet.lua Normal file
View File

@@ -0,0 +1,37 @@
local component = require("component")
local minitel = require("minitel")
local function loadConf()
local f = io.open("/etc/ocnet.conf", "r")
if not f then
return { gateway = "home", port = 5353 }
end
local txt = f:read("*a"); f:close()
local ok, t = pcall(load("return " .. txt))
if ok and type(t) == "table" then
if not t.gateway then t.gateway = "home1" end
if not t.port then t.port = 5353 end
return t
end
return { gateway = "home1", port = 5353 }
end
local conf = loadConf()
local f = io.open("/etc/hostname", "r")
local hostname = f and f:read("*l") or "unknown"
if f then f:close() end
local modemUUID
for addr in component.list("modem") do
modemUUID = addr
break
end
if not modemUUID then
io.stderr:write("[ocnet] kein modem gefunden\n")
return
end
print(string.format("[ocnet] REG %s (%s) -> %s:%d", hostname, modemUUID, conf.gateway, conf.port))
minitel.usend(conf.gateway, conf.port, "REG " .. hostname .. " " .. modemUUID)