45 lines
862 B
Lua
45 lines
862 B
Lua
local calls = {}
|
|
|
|
local function version_info()
|
|
print("SKS Coreutils version $[{SKS_COREUTILS_VERSION}]")
|
|
end
|
|
|
|
@[[function add_util(name)]]
|
|
calls["@[{name}]"] = function(...)
|
|
--#include @[{"coreutils/"..name..".lua"}]
|
|
end
|
|
@[[end]]
|
|
|
|
@[[
|
|
add_util("init")
|
|
add_util("reboot")
|
|
add_util("sh")
|
|
add_util("shutdown")
|
|
add_util("svc-ctl")
|
|
add_util("uname")
|
|
]]
|
|
|
|
calls.sks = function(prog, ...)
|
|
if not prog then
|
|
version_info()
|
|
print("SKS Coreutils multicall binary.\n")
|
|
print("Calls:")
|
|
local t = {}
|
|
for k, v in pairs(calls) do
|
|
t[#t+1] = k
|
|
end
|
|
print(table.concat(t, " "))
|
|
return 0
|
|
end
|
|
return calls[prog](...)
|
|
end
|
|
|
|
setmetatable(calls, {__index=function(_, i)
|
|
return function()
|
|
io.stderr:write("call "..i.." not found. run `sks' without args for list of calls.\n")
|
|
end
|
|
end})
|
|
|
|
local call = os.getenv("_"):match("/(.+)%.[^%.]+")
|
|
|
|
return calls[call](...) |