Added new package
This commit is contained in:
14
usr/bin/dns.lua
Normal file
14
usr/bin/dns.lua
Normal file
@@ -0,0 +1,14 @@
|
||||
local ocdns = require("ocdns")
|
||||
|
||||
local name = ...
|
||||
if not name then
|
||||
io.stderr:write("Usage: resolve <hostname>\n")
|
||||
return
|
||||
end
|
||||
|
||||
local uuid, err = ocdns.resolve(name)
|
||||
if uuid then
|
||||
print(uuid)
|
||||
else
|
||||
print("error:", err)
|
||||
end
|
||||
23
usr/lib/ocnetlib.lua
Normal file
23
usr/lib/ocnetlib.lua
Normal file
@@ -0,0 +1,23 @@
|
||||
local component = require("component")
|
||||
local minitel = require("minitel")
|
||||
|
||||
local GATEWAY = "home1"
|
||||
local PORT = 5353
|
||||
|
||||
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, t in component.list("modem") do
|
||||
modemUUID = addr
|
||||
break
|
||||
end
|
||||
|
||||
if not modemUUID then
|
||||
io.stderr:write("[ocnet] Keine Netzwerkkarte gefunden!\n")
|
||||
return
|
||||
end
|
||||
|
||||
print("[ocnet] registriere " .. hostname .. " (" .. modemUUID .. ") bei " .. GATEWAY)
|
||||
minitel.usend(GATEWAY, PORT, "REG " .. hostname .. " " .. modemUUID)
|
||||
Reference in New Issue
Block a user