luci初探

来源:互联网 发布:淘宝风王的祝福 编辑:程序博客网 时间:2024/05/01 01:20

Lua是一个小巧的脚本语言,很容易嵌入其它语言。轻量级 LUA语言的官方版本只包括一个精简的核心和最基本的库。这使得LUA体积小、启动速度快,从而适合嵌入在别的程序里。

UCI是OpenWrt中为实现所有系统配置的一个统一接口,英文名Unified Configuration Interface,即统一配置接口。LuCI,即是这两个项目的合体,可以实现路由的网页配置界面。

直接进入正题:

(这里假设环境搭建完毕)详见:点击打开链接   ->有可能会遇到问题解决方案:点击打开链接


乱入rcp

LuCI在openwrt里的网址是:http://192.168.1.10/cgi-bin/luci/rpc/xxx,多了一个cgi-bin。这是因为openwrt默认使用uhttpd作为web server。而在PC里使用make runhttpd启动的是lua web server


step1:

找到*host/usr/lib/lua/luci/

此目录下有三个文件夹特别要注意,

controller //如果一个网页是一棵树状结构,这个就是这颗树的DNA,他直接决定了分叉和形状。(扯远了)

view //view部分就是相当与树上放了装饰,也就是整个 一棵树在过圣诞节。

model //model里面有个cbi,方便我们配置etc/config/的文件,方便读写。


step2:

按照此网页玩遍除了view之外的内容

点击打开链接


step3:

谈谈view

无非三个东西:html,javascript,css

先谈最容易修改的部分:

在*/host/www/luci-static/openwrt.org下有个cascade.css修改这里的代码就可以修改界面啦,修改内容无非页面布局,边框大小,边框颜色,字体,字号,字颜色。


再谈刚刚提到的三个文件夹中的view,


view的话我们举一个栗子。。。

host/usr/lib/lua/luci/view/admin_status这个是luci界面中status部分主要显示系统当前状态。


index.htm由三部分组成

(有先后顺序)

lua代码,用于逻辑处理。(相当于网页制作的php部分)

javascript,用于联系lua中数据使其放入容器中(条形框,饼图)

html,最终生成界面。



step4

OpenWrt's central configuration is split into several files located in the /etc/config/ directory. Each file roughly relates to the part of the system it configures. You can edit the configuration files with a text editor or with the command line utility program uci. UCI is also editable through various programming APIs (like Shell, Lua and C), which is also how web interfaces like LuCI make changes to the UCI files.

上面说的是,luci是为了创建一个web窗口来配置etc/config里面的openwrt的configuration,所以,其实我们完全可以使用text editor来修改。

一句话,luci就是换一种方式修改文件,使普通用户得以方便修改ect/config文件从而来实现配置openwrt系统。


uci配置文件含有uci配置工具。比awk,grep强大。


step5


深入linux(选读)

Daemon


http://en.wikipedia.org/wiki/Daemon_(computing)


init scripts


http://wiki.openwrt.org/doc/techref/initscripts


acpid(Advanced Configuration and Power Interface)


是为替代传统的APM电源管理标准而推出的新型电源管理标准。通常笔记本电脑需要启动电源进行管理。


etc/rc.local


This file runs after all other init level scripts have run, so it's safe to put various commands that you want to have issued upon startup. 




















0 0
原创粉丝点击