Skip to content

Instantly share code, notes, and snippets.

@dch
Last active December 29, 2024 22:59
Show Gist options
  • Save dch/ec05fa084a58040d4d5760447cd31d0d to your computer and use it in GitHub Desktop.
Save dch/ec05fa084a58040d4d5760447cd31d0d to your computer and use it in GitHub Desktop.
lua jail API
#!/usr/libexec/flua
local jail = require("jail")
local i = 0;
for j in jail.list({"name"}) do
i = i + 1
if i % 100 == 0 then
print(j["name"])
end
end
print(i .. " jails")
#!/usr/libexec/flua
local jail = require("jail")
for j in jail.list({"name", "host.hostname", "path", "ip4.addr"}) do
print(j["jid"] .. " " .. j["ip4.addr"] .. " " .. j["name"] .. " " .. j["host.hostname"] .. " " .. j["path"])
end
#!/usr/libexec/flua
local jail = require("jail")
local create = {
path = "/",
persist = "true",
}
local destroy = {
persist = "false",
}
for i=1,999999 do
local name = "woop_" .. string.format("%07d", i)
local jid, err = jail.setparams(name, create, jail.CREATE or jail.UPDATE)
if not jid then
print(string.format("FAIL: creating %s: %s", name, err))
end
if i % 1000 == 0 then
print("DONE " .. name)
end
end
#!/usr/libexec/flua
local jail = require("jail")
local i = 0;
for j in jail.list({"name"}) do
i = i + 1
print(j["name"])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment