module("ffluci.controller.admin.uci", package.seeall)
+require("ffluci.util")
+require("ffluci.sys")
-- This function has a higher priority than the admin_uci/apply template
function action_apply()
for k, v in pairs(apply) do
local cmd = ffluci.config.uci_oncommit[k]
if cmd then
- output = output .. cmd .. ":" .. ffluci.util.exec(cmd)
+ output = output .. cmd .. ":" .. ffluci.sys.exec(cmd)
end
end
end
-- ToDo: Translate, Add descriptions and help texts
-require("ffluci.util")
m = Map("wireless", "Geräte")
t:value("mac80211")
t:value("prism2")
--[[
+require("ffluci.sys")
local c = ". /etc/functions.sh;for i in /lib/wifi/*;do . $i;done;echo $DRIVERS"
-for driver in ffluci.util.execl(c)[1]:gmatch("[^ ]+") do
+for driver in ffluci.sys.execl(c)[1]:gmatch("[^ ]+") do
t:value(driver)
end
]]--
--- /dev/null
+--[[
+FFLuCI - IPKG wrapper library
+
+Description:
+Wrapper for the ipkg Package manager
+
+Any return value of false or nil can be interpreted as an error
+
+FileId:
+$Id$
+
+License:
+Copyright 2008 Steven Barth <steven@midlink.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+]]--
+module("ffluci.model.ipkg", package.seeall)
+require("ffluci.sys")
module("ffluci.model.uci", package.seeall)
require("ffluci.util")
require("ffluci.fs")
+require("ffluci.sys")
-- The OS uci command
ucicmd = "uci"
-- Internal functions --
function Session._uci(self, cmd)
- local res = ffluci.util.exec(self.ucicmd .. " 2>/dev/null " .. cmd)
+ local res = ffluci.sys.exec(self.ucicmd .. " 2>/dev/null " .. cmd)
if res:len() == 0 then
return nil
end
function Session._uci2(self, cmd)
- local res = ffluci.util.exec(self.ucicmd .. " 2>&1 " .. cmd)
+ local res = ffluci.sys.exec(self.ucicmd .. " 2>&1 " .. cmd)
if res:len() > 0 then
return false, res
end
function Session._uci3(self, cmd)
- local res = ffluci.util.execl(self.ucicmd .. " 2>&1 " .. cmd)
+ local res = ffluci.sys.execl(self.ucicmd .. " 2>&1 " .. cmd)
if res[1]:sub(1, ucicmd:len() + 1) == ucicmd .. ":" then
return nil, res[1]
end
module("ffluci.sys", package.seeall)
require("posix")
+-- Runs "command" and returns its output
+function exec(command)
+ local pp = io.popen(command)
+ local data = pp:read("*a")
+ pp:close()
+
+ return data
+end
+
+-- Runs "command" and returns its output as a array of lines
+function execl(command)
+ local pp = io.popen(command)
+ local line = ""
+ local data = {}
+
+ while true do
+ line = pp:read()
+ if (line == nil) then break end
+ table.insert(data, line)
+ end
+ pp:close()
+
+ return data
+end
+
-- Returns the hostname
function hostname()
return io.lines("/proc/sys/kernel/hostname")()
end
--- Runs "command" and returns its output
-function exec(command)
- local pp = io.popen(command)
- local data = pp:read("*a")
- pp:close()
-
- return data
-end
-
-
--- Runs "command" and returns its output as a array of lines
-function execl(command)
- local pp = io.popen(command)
- local line = ""
- local data = {}
-
- while true do
- line = pp:read()
- if (line == nil) then break end
- table.insert(data, line)
- end
- pp:close()
-
- return data
-end
-
-
-- Populate obj in the scope of f as key
function extfenv(f, key, obj)
local scope = getfenv(f)