import some service packages from local dev env
This commit is contained in:
parent
2acb3a1e1f
commit
b04b03b64a
4
partman/package.cfg
Normal file
4
partman/package.cfg
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{["name"]="partman",
|
||||||
|
["description"]="Partition vcomponent management daemon",
|
||||||
|
["authors"]="Izaya",
|
||||||
|
["dependencies"]={"vcomponent"}}
|
40
partman/service/partman.lua
Normal file
40
partman/service/partman.lua
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
local diskpart = require "diskpart"
|
||||||
|
local vcomponent = require "vcomponent"
|
||||||
|
local partman = {}
|
||||||
|
local run = true
|
||||||
|
|
||||||
|
local function attach(addr)
|
||||||
|
for k,v in ipairs(diskpart.getPartitions(addr)) do
|
||||||
|
if v[4] > 0 then
|
||||||
|
syslog(string.format("Registering vcomponent for partition %s/%i",addr,k))
|
||||||
|
vcomponent.register(string.format("%s/%i",addr,k), "partition", diskpart.proxyPartition(addr, k))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function partman.start()
|
||||||
|
run = true
|
||||||
|
os.spawn(function()
|
||||||
|
for a,_ in component.list("drive") do
|
||||||
|
attach(a)
|
||||||
|
end
|
||||||
|
while run do
|
||||||
|
local tE = {coroutine.yield()}
|
||||||
|
if tE[1] == "component_added" and tE[3] == "drive" then
|
||||||
|
attach(tE[2])
|
||||||
|
elseif tE[1] == "component_removed" and tE[3] == "drive" then
|
||||||
|
for a,t in component.list("partition") do
|
||||||
|
if a:sub(1,tE[2]:len()) == tE[2] then
|
||||||
|
syslog("Removing partition vcomponent "..a)
|
||||||
|
vcomponent.unregister(a)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end, "partman")
|
||||||
|
end
|
||||||
|
function partman.stop()
|
||||||
|
run = false
|
||||||
|
end
|
||||||
|
|
||||||
|
return partman
|
4
rtfsman/package.cfg
Normal file
4
rtfsman/package.cfg
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{["name"]="rtfsman",
|
||||||
|
["description"]="rtfs auto-attach daemon",
|
||||||
|
["authors"]="Izaya",
|
||||||
|
["dependencies"]={"vcomponent"}}
|
38
rtfsman/service/rtfsman.lua
Normal file
38
rtfsman/service/rtfsman.lua
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
local vcomponent = require "vcomponent"
|
||||||
|
local rtfs = require "rtfs"
|
||||||
|
local rtfsman = {}
|
||||||
|
rtfsman.filesystems = {}
|
||||||
|
local run = true
|
||||||
|
|
||||||
|
local function attach(addr)
|
||||||
|
local w, e = pcall(rtfs.mount,component.proxy(addr))
|
||||||
|
if w then
|
||||||
|
syslog("rtfs filesystem found on " .. addr)
|
||||||
|
rtfsman.filesystems[addr] = true
|
||||||
|
vcomponent.register(addr .. "/rtfs", "filesystem", e)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function rtfsman.start()
|
||||||
|
run = true
|
||||||
|
return os.spawn(function()
|
||||||
|
for a,_ in component.list("partition") do
|
||||||
|
attach(a)
|
||||||
|
end
|
||||||
|
while run do
|
||||||
|
local tE = {coroutine.yield()}
|
||||||
|
if tE[1] == "component_added" and tE[3] == "partition" then
|
||||||
|
attach(tE[2])
|
||||||
|
elseif tE[1] == "component_removed" and rtfsman.filesystems[tE[2]] and tE[3] == "partition" then
|
||||||
|
syslog("Un-registering rtfs filesystem on " .. tE[2])
|
||||||
|
vcomponent.unregister(tE[2] .. "/rtfs")
|
||||||
|
rtfsman.filesystems[tE[2]] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,"rtfs-manager")
|
||||||
|
end
|
||||||
|
function rtfsman.stop()
|
||||||
|
run = false
|
||||||
|
end
|
||||||
|
|
||||||
|
return rtfsman
|
Loading…
Reference in New Issue
Block a user