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 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 = {}
|
||||||
|
|
||||||
@ -9,6 +10,7 @@ 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
|
||||||
|
|
||||||
@ -16,7 +18,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
|
||||||
rpcs.register(path.."_"..k,v)
|
rpc.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 = {}
|
cfg.enabled = {"getty","minitel"}
|
||||||
|
|
||||||
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,8 +37,10 @@ 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
|
||||||
@ -63,6 +65,7 @@ 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(data) or {}
|
rt = serial.unserialize(tostring(data)) or {}
|
||||||
until rt[1] == rv or computer.uptime() > st + 30
|
until (type(rt) == "table" and 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,6 +87,7 @@ 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,6 +61,8 @@ 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
|
return fsmounts[fsi].type or "filesystem"
|
||||||
end
|
end
|
||||||
|
|
||||||
fsmounts["/"] = component.proxy(computer.tmpAddress())
|
fsmounts["/"] = component.proxy(computer.tmpAddress())
|
||||||
|
@ -11,11 +11,16 @@ 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()
|
||||||
|
return os.spawn(function()
|
||||||
|
while true do
|
||||||
local tE = {coroutine.yield()}
|
local tE = {coroutine.yield()}
|
||||||
if tE[1] == "component_added" and tE[3] == "filesystem" then
|
if tE[1] == "component_added" and tE[3] == "filesystem" then
|
||||||
mount(tE[2])
|
mount(tE[2])
|
||||||
elseif tE[1] == "component_removed" and tE[3] == "filesystem" then
|
elseif tE[1] == "component_removed" and tE[3] == "filesystem" then
|
||||||
fs.umount("/mnt/"..tE[2]:sub(1,3))
|
fs.umount("/mnt/"..tE[2]:sub(1,3))
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end,"fsmanager")
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
local lastkey = computer.uptime()
|
local lastkey = computer.uptime()
|
||||||
local state = true
|
local state = true
|
||||||
local delay = 60
|
local delay = 60
|
||||||
while true do
|
function start()
|
||||||
|
return os.spawn(function()
|
||||||
|
while true do
|
||||||
tEv = {coroutine.yield()}
|
tEv = {coroutine.yield()}
|
||||||
if tEv[1] == "key_down" then
|
if tEv[1] == "key_down" then
|
||||||
lastkey = computer.uptime()
|
lastkey = computer.uptime()
|
||||||
@ -18,4 +20,6 @@ while true do
|
|||||||
end
|
end
|
||||||
state = false
|
state = false
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end,"screenblank")
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user