Make LuCIttpd work OOTB
authorSteven Barth <steven@midlink.org>
Sun, 7 Dec 2008 11:47:59 +0000 (11:47 +0000)
committerSteven Barth <steven@midlink.org>
Sun, 7 Dec 2008 11:47:59 +0000 (11:47 +0000)
libs/lucittpd/ipkg/postinst [new file with mode: 0755]
libs/lucittpd/luasrc/ttpd/server.lua
libs/lucittpd/root/etc/config/lucittpd [new file with mode: 0644]
libs/lucittpd/root/etc/init.d/lucittpd [new file with mode: 0755]
libs/sgi-luci/root/usr/lib/lucittpd/plugins/luci-webui.lua

diff --git a/libs/lucittpd/ipkg/postinst b/libs/lucittpd/ipkg/postinst
new file mode 100755 (executable)
index 0000000..3c25ea6
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+[ -n "${IPKG_INSTROOT}" ] || {
+        /etc/init.d/lucittpd enable
+       /etc/init.d/lucittpd start
+}
+
index 4cb246a..a2c7ffc 100644 (file)
@@ -18,6 +18,7 @@ local pcall, assert = pcall, assert
 
 local os = require "os"
 local io = require "io"
 
 local os = require "os"
 local io = require "io"
+local uci = require "luci.model.uci"
 local util = require "luci.util"
 local ltn12 = require "luci.ltn12"
 local proto = require "luci.http.protocol"
 local util = require "luci.util"
 local ltn12 = require "luci.ltn12"
 local proto = require "luci.http.protocol"
@@ -91,6 +92,7 @@ end
 Server = util.class()
 
 function Server.__init__(self, host)
 Server = util.class()
 
 function Server.__init__(self, host)
+       self.uci = uci.cursor()
        self.host = host
        self.vhosts = {}
        
        self.host = host
        self.vhosts = {}
        
@@ -329,7 +331,7 @@ function Server.process(self, functions)
                        close = not message.env.HTTP_CONNECTION or message.env.HTTP_CONNECTION == "close"
                end
                -- Uncomment this to disable keep-alive
                        close = not message.env.HTTP_CONNECTION or message.env.HTTP_CONNECTION == "close"
                end
                -- Uncomment this to disable keep-alive
-               -- close = true
+               close = not (self.uci:get("lucittpd", "lucittpd", "keepalive") == "1")
        
                if message.request_method == "get" or message.request_method == "head" then
                        -- Be happy
        
                if message.request_method == "get" or message.request_method == "head" then
                        -- Be happy
diff --git a/libs/lucittpd/root/etc/config/lucittpd b/libs/lucittpd/root/etc/config/lucittpd
new file mode 100644 (file)
index 0000000..803a6e5
--- /dev/null
@@ -0,0 +1,6 @@
+config lucittpd lucittpd
+       option port 80
+       option timeout 90       
+       option keepalive 0
+       option path /usr/lib/lucittpd/plugins/
+       option root /www
diff --git a/libs/lucittpd/root/etc/init.d/lucittpd b/libs/lucittpd/root/etc/init.d/lucittpd
new file mode 100755 (executable)
index 0000000..139f30b
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/sh /etc/rc.common
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+DAEMON=/usr/bin/lucittpd
+NAME=lucittpd
+DESC="HTTP server"
+START=49
+
+test -x $DAEMON || exit 0
+set -e
+
+start() {
+       echo -n "Starting $DESC: $NAME"
+       start-stop-daemon -S -q -x $DAEMON
+       echo "."
+}
+
+stop() {
+       echo -n "Stopping $DESC: $NAME"
+       start-stop-daemon -K -q -x $DAEMON
+       echo "."
+}
+
+restart() {
+       # echo -n "Restarting $DESC: $NAME... "
+       # start-stop-daemon -K -s HUP -q -x $DAEMON
+       # echo "done."
+       stop
+       sleep 3
+       start
+}
+
+reload() {
+       #
+       #       If the daemon can reload its config files on the fly
+       #       for example by sending it SIGHUP, do it here.
+       #
+       #       If the daemon responds to changes in its config file
+       #       directly anyway, make this a do-nothing entry.
+       #
+       # echo -n "Reloading $DESC configuration... "
+       # start-stop-daemon -K -s 1 -q -x $DAEMON
+       # echo "done."
+       restart
+}
index f237b85..1204667 100644 (file)
@@ -11,6 +11,7 @@ end
 
 -- Register luci
 function register()
 
 -- Register luci
 function register()
-       local lucihnd = require "luci.ttpd.handler.luci"
-       httpd.server:get_default_vhost():set_handler("/luci", lucihnd.Luci())
-end
\ No newline at end of file
+       local lucihnd = require "luci.ttpd.handler.luci".Luci()
+       httpd.server:get_default_vhost():set_handler("/luci", lucihnd)
+       httpd.server:get_default_vhost():set_handler("/cgi-bin/luci", lucihnd)
+end