projects
/
project
/
luci.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #1808 from dibdot/lxc_fix
[project/luci.git]
/
applications
/
luci-app-lxc
/
luasrc
/
controller
/
lxc.lua
diff --git
a/applications/luci-app-lxc/luasrc/controller/lxc.lua
b/applications/luci-app-lxc/luasrc/controller/lxc.lua
index
cc490f0
..
e15915d
100644
(file)
--- a/
applications/luci-app-lxc/luasrc/controller/lxc.lua
+++ b/
applications/luci-app-lxc/luasrc/controller/lxc.lua
@@
-14,33
+14,33
@@
Author: Petar Koretic <petar.koretic@sartura.hr>
]]--
]]--
-local uci
= require "luci.model.uci"
+local uci
= require "luci.model.uci".cursor()
local util = require "luci.util"
local util = require "luci.util"
-local
nixio
= require "nixio"
+local
fs
= require "nixio"
module("luci.controller.lxc", package.seeall)
function fork_exec(command)
module("luci.controller.lxc", package.seeall)
function fork_exec(command)
- local pid =
nixio
.fork()
+ local pid =
fs
.fork()
if pid > 0 then
return
elseif pid == 0 then
-- change to root dir
if pid > 0 then
return
elseif pid == 0 then
-- change to root dir
-
nixio
.chdir("/")
+
fs
.chdir("/")
-- patch stdin, out, err to /dev/null
-- patch stdin, out, err to /dev/null
- local null =
nixio
.open("/dev/null", "w+")
+ local null =
fs
.open("/dev/null", "w+")
if null then
if null then
-
nixio.dup(null, nixio
.stderr)
-
nixio.dup(null, nixio
.stdout)
-
nixio.dup(null, nixio
.stdin)
+
fs.dup(null, fs
.stderr)
+
fs.dup(null, fs
.stdout)
+
fs.dup(null, fs
.stdin)
if null:fileno() > 2 then
null:close()
end
end
-- replace with target command
if null:fileno() > 2 then
null:close()
end
end
-- replace with target command
-
nixio
.exec("/bin/sh", "-c", command)
+
fs
.exec("/bin/sh", "-c", command)
end
end
end
end
@@
-71,9
+71,8
@@
function lxc_get_downloadable()
local target = lxc_get_arch_target()
local templates = {}
local target = lxc_get_arch_target()
local templates = {}
- local f = io.popen('sh /usr/share/lxc/templates/lxc-download --list --no-validate --server %s'
- % util.shellquote(uci.cursor():get("lxc", "lxc", "url")), 'r')
-
+ local f = io.popen('sh /usr/share/lxc/templates/lxc-download --list --no-validate --server %s 2>/dev/null'
+ % util.shellquote(uci:get("lxc", "lxc", "url")), 'r')
local line
for line in f:lines() do
local dist, version, dist_target = line:match("^(%S+)%s+(%S+)%s+(%S+)%s+default%s+%S+$")
local line
for line in f:lines() do
local dist, version, dist_target = line:match("^(%S+)%s+(%S+)%s+(%S+)%s+default%s+%S+$")
@@
-101,7
+100,7
@@
function lxc_create(lxc_name, lxc_template)
name = lxc_name,
template = "download",
args = {
name = lxc_name,
template = "download",
args = {
- "--server", uci
.cursor()
:get("lxc", "lxc", "url"),
+ "--server", uci:get("lxc", "lxc", "url"),
"--no-validate",
"--dist", lxc_dist,
"--release", lxc_release,
"--no-validate",
"--dist", lxc_dist,
"--release", lxc_release,
@@
-121,6
+120,7
@@
function lxc_get_config_path()
local f = io.open("/etc/lxc/lxc.conf", "r")
local content = f:read("*all")
f:close()
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 .. "/"
local ret = content:match('^%s*lxc.lxcpath%s*=%s*([^%s]*)')
if ret then
return ret .. "/"
@@
-160,7
+160,7
@@
function lxc_configuration_set(lxc_name)
end
function lxc_get_arch_target()
end
function lxc_get_arch_target()
- local target =
nixio
.uname().machine
+ local target =
fs
.uname().machine
local target_map = {
armv5 = "armel",
armv6 = "armel",
local target_map = {
armv5 = "armel",
armv6 = "armel",