Getting a Debian environment on this relatively old (3 yr old) board was fairly painful because they let you download the development image to put on a flash drive but don't tell you how to do it. Even though the documentation implies you can unpack the tar file onto a VFAT drive from Windows, you have to do it from a running Linux system (you can use a Live CD) by plugging the flash drive in, then doing "fdisk /dev/sdb" (assuming the flash drive shows up as sdb; you create one partition on it and mark it bootable), then you have to "mkfs.ext2 /dev/sdb1" before you can untar their development image on it. To make it more complicated, the image I had to use (to match the kernel on boards in the field) was missing the rcS.USB startup file (it was on the previous Woody tar image on their site and I used the Sarge image) so that loadUSB.sh failed to load. Always remember to do a "sync" before switching between the board and the Debian flash drive.
Once you get the Debian environment running, it's not as simple as running "apt-get install" to build the binaries you need because when you do this, it will want to install the latest version of gcc which requires the latest 2.6 kernel; you cannot use luarocks for the same reason...dependency updates inevitably suck down newer updates for gcc and the kernel. You end up having to do grab all the dependencies yourself and compiling them and installing them to the right place by looking at the makefile's install target.
The haserl web framework (used on various wifi routers and the ddwrt open source firmware replacement) required lua to be installed (haserl can only be compiled to use /bin/sh as the scripting language, but lua offers a lot more programming capability). In order to get lua compiled, you have to compile and install the Gnu readline and ncurses libraries (ncurses might fail compiling the c++ directory but you can do "make install.libs" to install what's been compiled to make lua happy). As part of the install of haserl, you have to make the executable file setuid or it will have problems handling file uploads and any other file operations. If you want to avoid any shared library dependencies, you can also configure it with "LDFLAGS=--static" to force it to build a statically linked executable (you can run ldd on the executable to make sure it doesn't use any shared libraries); this will make the file size grow to 324K (the shared library linked version is only 33K).
The cgilua web framework requires fastcgi and wsapi before it can be compiled. After you compile it, you still can't run cgilua scripts until you download Kepler's tarball and grab the cgilua.cgi and cgilua.fcgi files (if you want to install Orbit, grab the op.cgi and op.fcgi files as well); these files are needed to parse the web page headers before loading the lua server page files (they're lua server page launchers that you stick in your app's cgi-bin directory).
Unfortunately, these files are tied into Kepler's Xavante server, so you have to modify a few things to get them to work. The cgilua.cgi scripts get global variables from kepler_init.lua (you can get this out of any kepler installation and modify the paths appropriately; I put cgilua's config.lua in my apache/conf/cgilua directory); I renamed this file to cgilua_init.lua and put it in the usual /usr/local/share/lua/5.1 directory. The global variables that are important are CGILUA_CONF and CGILUA_TMP and RINGS_CGILUA_GLOBALS and CGI_LUA_ISDIRECT (CGILUA_APPS doesn't seem to be used). You then have to modify your cgilua.cgi file to initialize from this file instead of kepler_init.lua and also comment out the check for luarocks since luarocks can't be used in embedded systems. Once you get all that done, put the *.cgi scripts in apache's cgi-bin directory and make them executable and setuid so they have access to the file system. You can then do this to bring up a test page:
http://localhost/cgi-bin/cgilua.cgi/testcgi.lp?language=english
Note also that your lua page file *must* have an extension because the cgi files parse for it. If your embedded system has Apache's mod_rewrite module compiled/installed, you can also follow the directions on the Kepler site on how to set up a .htaccess file so the URLs look nicer. If you want to use FastCGI support, your Apache system also needs to have the mod_fcgid module installed.
Orbit is another webwork for lua which supports the MVC pattern (though it doesn't seem to have functions to support file uploads at this point so you have to use cgilua's support). Orbit pages are similar to PHP pages, so it needs the LPeg library (and the re.lua included in it) to parse the embedded function syntax in the web pages. When you finish setting it up, you can do something like this to bring up an Orbit page:
http://localhost/cgi-bin/op.cgi/testorbit.op
Finally, here's the list of files I added to the embedded system:
/usr/bin/haserl
/usr/local/share/lua/5.1/wsapi (dir)
/usr/local/lib/lua/5.1/lfcgi.so (fastcgi)
/usr/bin/wsapi.cgi
/usr/bin/wsapi.fcgi
/usr/bin/cgi-fcgi
/usr/local/lib/lua/5.1/lfs.so (luafilesystem)
/usr/local/share/lua/5.1/cgilua.lua
/usr/local/share/lua/5.1/cgilua_init.lua (bastardized from kepler_init.lua)
/usr/local/share/lua/5.1/cgilua (dir)
/www/apache/conf/cgilua/config.lua
/usr/local/share/lua/5.1/sajax.lua
/usr/local/share/lua/5.1/json
/www/apache/cgi-bin/cgilua.cgi
/www/apache/cgi-bin/op.cgi
/usr/local/share/lua/5.1/orbit.lua
/usr/local/share/lua/5.1/orbit (dir)
/usr/local/share/lua/5.1/cosmo.lua
/usr/local/share/lua/5.1/cosmo (dir)
/usr/local/lib/lua/5.1/lpeg.so (lpeg grammar parsing)
/usr/local/share/lua/5.1/re.lua (used w/ lpeg)
p.s., I found the cgilua web site's examples to be fairly sparse for file upload.
The test page at http://www.lua.inf.puc-rio.br/~mascarenhas/kepler-rocks/current/web/test.lp was useful:
The examples at http://web.tecgraf.puc-rio.br/cgilua/frame_secao2.html were also good.
And there's also the Lua Tutorial Wiki.
1. Felipe06/14/2015 23:24:03
Five years after your post, the content from the page is the only true example I found. Thank you for posting it!
2. Ken Yee03/09/2010 13:25:30
This is from a basic install via luarocks on Windows:
--
-- Kepler bootstrap file
-- Defines the default directories for Kepler
--
-- Kepler applications directory
KEPLER_APPS = [[c:\LuaRocks\kepler/apps]]
-- Kepler configuration directory
KEPLER_CONF = [[c:\LuaRocks\kepler/etc]]
-- Kepler logs directory
KEPLER_LOG = [[c:\LuaRocks\kepler/log]]
-- Kepler temporary directory
KEPLER_TMP = [[c:\WINDOWS\Temp]]
-- Kepler default web directory
KEPLER_WEB = [[c:\LuaRocks\kepler/htdocs]]
-- CGILua globals (usually defined using KEPLER globals)
CGILUA_APPS = KEPLER_APPS.."/cgilua"
CGILUA_CONF = KEPLER_CONF.."/cgilua"
CGILUA_TMP = KEPLER_TMP
CGILUA_ISDIRECT = true
RINGS_CGILUA_GLOBALS = {
"KEPLER_APPS", "KEPLER_CONF", "KEPLER_LIB",
"KEPLER_LOG", "KEPLER_LUA", "KEPLER_TMP", "KEPLER_WEB",
"CGILUA_APPS", "CGILUA_CONF", "CGILUA_TMP", "CGILUA_ISDIRECT",
}
3. rory toma02/27/2010 01:40:31
Can you post the contents of your kepler_init file? It seems that this file is empty in the distribution. Thx
Su | Mo | Tu | We | Th | Fr | Sa |
---|---|---|---|---|---|---|
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 |