2014/06/03

Install luci on ubuntu 12.04


Abstract


After struggling around 1 hour, I have successfully installed luci on my ubuntu VM. For future reference, here is the steps I have tried.

Dependencies


  • lua
  • cmake
  • uci
  • luci

# lua

Installation

    $> sudo apt-get install lua5.1 liblua5.1-0-dev

Notes

Hopefully, you can run lua interpreter on your terminal by typing lua directly on terminal for now on.


# cmake

Installation

$> sudo apt-get install cmake

# uci

Installation

Edited from here
# Some extra package are required:
$> sudo apt-get install cmake lua5.1

# The libubox library is required. It should to compiled from source.
# To do this, first you have to get the source from git:  
$> git clone git://nbd.name/luci2/libubox.git libubox
$> cd libubox

# Please follow the next steps to build libubox:
$> mkdir build
$> cd build
$> cmake ..
$> make ubox

# Install libubox:
$> sudo mkdir -p /usr/local/include/libubox
$> sudo cp ../*.h /usr/local/include/libubox
$> sudo cp libubox.so /usr/local/lib
$> sudo ldconfig

# Get UCI source from git:
$> git clone git://nbd.name/uci.git uci
$> cd uci

# Please follow the next steps to build uci:
$> mkdir build
$> cd build
$> cmake ..
$> make all

# Install uci:
$> sudo mkdir -p /usr/local/include/uci
$> sudo cp ../uci.h ../uci_config.h /usr/local/include/uci
$> sudo cp ../uci_blob.h ../ucimap.h /usr/local/include/uci
$> sudo cp libuci.so /usr/local/lib
$> sudo cp uci /usr/local/bin
$> sudo cp lua/uci.so /usr/local/lib/lua/5.1/
$> sudo ldconfig

# Testing:
$> mkdir test
$> cat > test/test << EOF
> config 'test' 'abc'
> option 'test_var' 'value'
> EOF

$> uci -c `pwd`/test show test
Output:
test.abc=test
test.abc.test_var=value

$> uci -c `pwd`/test set test.abc.test_var=foobar
$> uci -c `pwd`/test commit test

$> uci -c `pwd`/test show test
Output:
test.abc=test
test.abc.test_var=foobar

# luci

Installation

# According to the official news,
# luci's repository has been merged with openwrt.
# Below are updated commands for downloading their sources.
$> git clone https://github.com/openwrt/luci.git
$> cd luci
$> git checkout luci-0.12
# Remove builtin folders if fail
$> rm -fr contrib/uhttpd

# compilataion
$> make runshell

Notes


1. This is not a permanent installation

Above installation is not a permanent one, you need to run above commands for every terminal session in order to use luci.

Actually, missing environment variables are the root cause for this phenomenon. For advanced Linux users, I strongly recommend you put those environment variables (named with LUA_*) into your ~/.bashrc after calling make runshell so that you do not need to run them again and again.

Write down following contents at the end of ~/.bashrc
# make sure you have update the home directory :)
export LUA_PATH="/home/mondwan/Documents/git/luci/host//usr/lib/lua/?.lua;/home/mondwan/Documents/git/luci/host//usr/lib/lua/?/init.lua;$LUA_PATH;"
export LUA_CPATH="/home/mondwan/Documents/git/luci/host//usr/lib/lua/?.so;$LUA_CPATH;"
export LUCI_SYSROOT='/home/mondwan/Documents/git/luci/host'
export LD_LIBRARY_PATH='/home/mondwan/Documents/git/luci/host/usr/lib:'

2. Missing iwinfo.h

If it tells you about missing iwinfo.h, please read this link. Try to revert those files will be good enough. Below are extracted commands from the link.

$> git checkout 89678917~1 contrib/package/luci/Makefile
$> git checkout 89678917~1 modules/admin-full/src/luci-bwc.c

Test installation


Before doing anything, here is the script for testing whether you have installed luci successfully or not.

$> lua
> UCI = require 'luci.model.uci'
> UCI.cursor() 

if you can run them without errors you have accomplished the installation.

Further reading


References


* http://www.wakoond.hu/2013/06/using-uci-on-ubuntu.html

Update history


Update on 26/1/2015: Fix the incorrect directory structure CSS
Update on 16/2/2015: A new guide to compile luci
Update on 12/3/2015: Update text format and add notes about make runshell
Update on 21/5/2015: Add a reference forurther reading
Update on 2/6/2015:  Update bashrc contents
Update on 3/8/2015:  Update notes about installing uci
Update on 4/2/2016:  Update documents for UCI installation
Update on 26/8/2016: Update make commands for uci and luci installation

沒有留言:

張貼留言