1 module("luci-plugin", package.seeall)
3 function normalize(path)
5 while newpath ~= path do
9 newpath = string.gsub(path, "/[^/]+/../", "/")
15 -- NB: path points to ROOT/usr/lib/boa, change it to /usr/lib/lua
16 root = normalize(path .. '/../../../')
17 path = normalize(path .. '/../lua/')
18 package.cpath = path..'?.so;'..package.cpath
19 package.path = path..'?.lua;'..package.path
21 require("luci.dispatcher")
22 require("luci.sgi.webuci")
26 -- Entering dummy mode
27 uci.set_savedir(root..'/tmp/.uci')
28 uci.set_confdir(root..'/etc/config')
30 luci.sys.hostname = function() return "" end
31 luci.sys.loadavg = function() return 0,0,0,0,0 end
32 luci.sys.reboot = function() return end
33 luci.sys.sysinfo = function() return "","","" end
34 luci.sys.syslog = function() return "" end
36 luci.sys.net.arptable = function() return {} end
37 luci.sys.net.devices = function() return {} end
38 luci.sys.net.routes = function() return {} end
39 luci.sys.wifi.getiwconfig = function() return {} end
40 luci.sys.wifi.iwscan = function() return {} end
44 function prepare_req(uri)
45 luci.dispatcher.createindex()
50 function handle_req(context)
51 env.SERVER_PROTOCOL = context.server_proto
52 env.REMOTE_ADDR = context.remote_addr
53 env.REQUEST_METHOD = context.request_method
54 env.PATH_INFO = context.uri
55 env.REMOTE_PORT = context.remote_port
56 env.SERVER_ADDR = context.server_addr
57 env.SCRIPT_NAME = env.REQUEST_URI:sub(1, #env.REQUEST_URI - #env.PATH_INFO)
59 luci.sgi.webuci.initenv(env, vars)
60 luci.dispatcher.httpdispatch()