summaryrefslogtreecommitdiffhomepage
path: root/libs/httpd/host/runluci
blob: 65c6b6cf1c31f162667e878014fbbbf3d00d087d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env lua
require("luci.httpd")
require("luci.httpd.server")
require("luci.httpd.handler.file")
require("luci.httpd.handler.luci")

SYSROOT = arg[1]
DOCROOT = SYSROOT .. arg[2]
PORT = 8080

collectgarbage("setpause", 150)

serversocket = luci.httpd.Socket("0.0.0.0", PORT)

server  = luci.httpd.server.Server()
vhost   = luci.httpd.server.VHost()

server:set_default_vhost(vhost)

pcall(function()
	require "uci"
	require "luci.model.uci".cursor = function(config, save)
		return uci.cursor(config or SYSROOT .. "/etc/config", save or SYSROOT .. "/tmp/.uci")
	end
end)

require("luci.sys")
luci.sys.user.checkpasswd = function() return true end


filehandler = luci.httpd.handler.file.Simple(DOCROOT)
vhost:set_default_handler(filehandler)

lucihandler = luci.httpd.handler.luci.Luci()
vhost:set_handler("/luci", lucihandler)

io.stderr:write("Starting LuCI HTTPD on port " .. PORT .. "...\n")
io.stderr:write("Point your browser to http://localhost:" .. PORT .. "/luci\n")

--daemon = luci.httpd.Daemon()
--daemon.debug = true
luci.httpd.register(serversocket, server:create_daemon_handlers())
luci.httpd.run()