Compare commits
No commits in common. "67de47ebd437d3b31cd7d2e66b90776aa918b678" and "928a1db13c8662b8ea366301ea13cc1629ba9c52" have entirely different histories.
67de47ebd4
...
928a1db13c
@ -1,7 +1,6 @@
|
|||||||
local computer = require "computer"
|
local computer = require "computer"
|
||||||
local minitel = require "minitel"
|
local minitel = require "minitel"
|
||||||
local event = require "event"
|
local event = require "event"
|
||||||
local ufs = require "unionfs"
|
|
||||||
local rpc = require "rpc"
|
local rpc = require "rpc"
|
||||||
local netutil = {}
|
local netutil = {}
|
||||||
|
|
||||||
@ -10,7 +9,6 @@ function netutil.importfs(host,rpath,lpath) -- import filesystem *rpath* from *h
|
|||||||
function px.getLabel()
|
function px.getLabel()
|
||||||
return host..":"..rpath
|
return host..":"..rpath
|
||||||
end
|
end
|
||||||
px.address = host..":"..rpath
|
|
||||||
return fs.mount(lpath,px)
|
return fs.mount(lpath,px)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -18,7 +16,7 @@ function netutil.exportfs(path) -- export the directory *path* over RPC
|
|||||||
local path = "/"..table.concat(fs.segments(path),"/")
|
local path = "/"..table.concat(fs.segments(path),"/")
|
||||||
local px = ufs.create(path)
|
local px = ufs.create(path)
|
||||||
for k,v in pairs(px) do
|
for k,v in pairs(px) do
|
||||||
rpc.register(path.."_"..k,v)
|
rpcs.register(path.."_"..k,v)
|
||||||
print(path.."_"..k)
|
print(path.."_"..k)
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
|
@ -4,7 +4,7 @@ local rc = {}
|
|||||||
rc.pids = {}
|
rc.pids = {}
|
||||||
local service = {}
|
local service = {}
|
||||||
local cfg = {}
|
local cfg = {}
|
||||||
cfg.enabled = {"getty","minitel"}
|
cfg.enabled = {}
|
||||||
|
|
||||||
local function loadConfig()
|
local function loadConfig()
|
||||||
local f = io.open("/boot/cfg/rc.cfg","rb")
|
local f = io.open("/boot/cfg/rc.cfg","rb")
|
||||||
@ -37,10 +37,8 @@ end
|
|||||||
|
|
||||||
function rc.stop(name,...)
|
function rc.stop(name,...)
|
||||||
if not service[name] then return false, "service not found" end
|
if not service[name] then return false, "service not found" end
|
||||||
if service[name].stop then
|
service[name].stop(...)
|
||||||
service[name].stop(...)
|
coroutine.yield()
|
||||||
coroutine.yield()
|
|
||||||
end
|
|
||||||
if rc.pids[name] then
|
if rc.pids[name] then
|
||||||
os.kill(rc.pids[name])
|
os.kill(rc.pids[name])
|
||||||
end
|
end
|
||||||
@ -65,7 +63,6 @@ function rc.enable(name)
|
|||||||
for k,v in pairs(cfg.enabled) do
|
for k,v in pairs(cfg.enabled) do
|
||||||
if v == name then return false end
|
if v == name then return false end
|
||||||
end
|
end
|
||||||
cfg.enabled[#cfg.enabled+1] = name
|
|
||||||
saveConfig()
|
saveConfig()
|
||||||
end
|
end
|
||||||
function rc.disable(name)
|
function rc.disable(name)
|
||||||
|
@ -37,8 +37,8 @@ function rpc.call(hostname,fn,...)
|
|||||||
local rt = {}
|
local rt = {}
|
||||||
repeat
|
repeat
|
||||||
local _, from, port, data = event.pull(30, "net_msg", hostname, rpc.port)
|
local _, from, port, data = event.pull(30, "net_msg", hostname, rpc.port)
|
||||||
rt = serial.unserialize(tostring(data)) or {}
|
rt = serial.unserialize(data) or {}
|
||||||
until (type(rt) == "table" and rt[1] == rv) or computer.uptime() > st + 30
|
until rt[1] == rv or computer.uptime() > st + 30
|
||||||
if table.remove(rt,1) == rv then
|
if table.remove(rt,1) == rv then
|
||||||
return table.unpack(rt)
|
return table.unpack(rt)
|
||||||
end
|
end
|
||||||
|
@ -87,7 +87,6 @@ function shutil.mount(addr,path)
|
|||||||
if not addr then
|
if not addr then
|
||||||
local mt = fs.mounts()
|
local mt = fs.mounts()
|
||||||
for k,v in pairs(mt) do
|
for k,v in pairs(mt) do
|
||||||
v = "/"..table.concat(fs.segments(v),"/")
|
|
||||||
print(tostring(fs.address(v)).." on "..tostring(v).." type "..fs.type(v))
|
print(tostring(fs.address(v)).." on "..tostring(v).." type "..fs.type(v))
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -61,8 +61,6 @@ function devfs.component.seek(fd,...)
|
|||||||
end
|
end
|
||||||
function devfs.component.remove(fname)
|
function devfs.component.remove(fname)
|
||||||
end
|
end
|
||||||
devfs.component.address = "devfs"
|
|
||||||
devfs.component.type = "devfs"
|
|
||||||
|
|
||||||
function devfs.register(fname,fopen) -- Register a new devfs node with the name *fname* that will run the function *fopen* when opened. This function should return a function for read, a function for write, function for close, and optionally, a function for seek, in that order.
|
function devfs.register(fname,fopen) -- Register a new devfs node with the name *fname* that will run the function *fopen* when opened. This function should return a function for read, a function for write, function for close, and optionally, a function for seek, in that order.
|
||||||
devfs.files[fname] = fopen
|
devfs.files[fname] = fopen
|
||||||
|
@ -111,7 +111,7 @@ function fs.address(path) -- returns the address of the filesystem at a given pa
|
|||||||
end
|
end
|
||||||
function fs.type(path) -- returns the component type of the filesystem at a given path, if applicable
|
function fs.type(path) -- returns the component type of the filesystem at a given path, if applicable
|
||||||
local fsi,_ = fs.resolve(path)
|
local fsi,_ = fs.resolve(path)
|
||||||
return fsmounts[fsi].type or "filesystem"
|
return fsmounts[fsi].type
|
||||||
end
|
end
|
||||||
|
|
||||||
fsmounts["/"] = component.proxy(computer.tmpAddress())
|
fsmounts["/"] = component.proxy(computer.tmpAddress())
|
||||||
|
@ -11,16 +11,11 @@ end
|
|||||||
for addr, _ in component.list("filesystem") do
|
for addr, _ in component.list("filesystem") do
|
||||||
mount(addr)
|
mount(addr)
|
||||||
end
|
end
|
||||||
|
while true do
|
||||||
function start()
|
local tE = {coroutine.yield()}
|
||||||
return os.spawn(function()
|
if tE[1] == "component_added" and tE[3] == "filesystem" then
|
||||||
while true do
|
mount(tE[2])
|
||||||
local tE = {coroutine.yield()}
|
elseif tE[1] == "component_removed" and tE[3] == "filesystem" then
|
||||||
if tE[1] == "component_added" and tE[3] == "filesystem" then
|
fs.umount("/mnt/"..tE[2]:sub(1,3))
|
||||||
mount(tE[2])
|
end
|
||||||
elseif tE[1] == "component_removed" and tE[3] == "filesystem" then
|
|
||||||
fs.umount("/mnt/"..tE[2]:sub(1,3))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,"fsmanager")
|
|
||||||
end
|
end
|
||||||
|
@ -1,25 +1,21 @@
|
|||||||
local lastkey = computer.uptime()
|
local lastkey = computer.uptime()
|
||||||
local state = true
|
local state = true
|
||||||
local delay = 60
|
local delay = 60
|
||||||
function start()
|
while true do
|
||||||
return os.spawn(function()
|
tEv = {coroutine.yield()}
|
||||||
while true do
|
if tEv[1] == "key_down" then
|
||||||
tEv = {coroutine.yield()}
|
lastkey = computer.uptime()
|
||||||
if tEv[1] == "key_down" then
|
if not state then
|
||||||
lastkey = computer.uptime()
|
for addr in component.list("screen") do
|
||||||
if not state then
|
component.invoke(addr,"turnOn")
|
||||||
for addr in component.list("screen") do
|
|
||||||
component.invoke(addr,"turnOn")
|
|
||||||
end
|
|
||||||
state = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if computer.uptime() > lastkey + delay and state then
|
|
||||||
for addr in component.list("screen") do
|
|
||||||
component.invoke(addr,"turnOff")
|
|
||||||
end
|
|
||||||
state = false
|
|
||||||
end
|
end
|
||||||
|
state = true
|
||||||
end
|
end
|
||||||
end,"screenblank")
|
end
|
||||||
|
if computer.uptime() > lastkey + delay and state then
|
||||||
|
for addr in component.list("screen") do
|
||||||
|
component.invoke(addr,"turnOff")
|
||||||
|
end
|
||||||
|
state = false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user