mirror of
https://github.com/novatiq/packages.git
synced 2026-04-30 07:28:39 +01:00
luci-app-lxc: Use correct path for configuration
Adjusting LuCI app for LXC to try to read path to your LXC containers from configuration file and if not succeeding falling back to /srv/lxc to match previous commit. Signed-off-by: Michal Hrusecky <michal.hrusecky@nic.cz>
This commit is contained in:
@@ -93,10 +93,22 @@ function lxc_action(lxc_action, lxc_name)
|
|||||||
luci.http.write_json(ec and {} or data)
|
luci.http.write_json(ec and {} or data)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function lxc_get_config_path()
|
||||||
|
local f = io.open("/etc/lxc/lxc.conf", "r")
|
||||||
|
local content = f:read("*all")
|
||||||
|
f:close()
|
||||||
|
local ret = content:match('^%s*lxc.lxcpath%s*=%s*([^%s]*)')
|
||||||
|
if ret then
|
||||||
|
return ret .. "/"
|
||||||
|
else
|
||||||
|
return "/srv/lxc/"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function lxc_configuration_get(lxc_name)
|
function lxc_configuration_get(lxc_name)
|
||||||
luci.http.prepare_content("text/plain")
|
luci.http.prepare_content("text/plain")
|
||||||
|
|
||||||
local f = io.open("/lxc/" .. lxc_name .. "/config", "r")
|
local f = io.open(lxc_get_config_path() .. lxc_name .. "/config", "r")
|
||||||
local content = f:read("*all")
|
local content = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
@@ -112,7 +124,7 @@ function lxc_configuration_set(lxc_name)
|
|||||||
return luci.http.write("1")
|
return luci.http.write("1")
|
||||||
end
|
end
|
||||||
|
|
||||||
local f, err = io.open("/lxc/" .. lxc_name .. "/config","w+")
|
local f, err = io.open(lxc_get_config_path() .. lxc_name .. "/config","w+")
|
||||||
if not f then
|
if not f then
|
||||||
return luci.http.write("2")
|
return luci.http.write("2")
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user