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