openwrt luci管理的Web界面实例
2015-09-18 15:54
232 查看
第一部分:
template的方式实现网页显示hello world,如图显示:第一步:/usr/lib/lua/luci/controller/admin/system.lua中注册选项:
entry({"admin", "system", "test-template"}, template("test/hello"), _("test"), 3).dependent = false
第二步:在view目录下添加相应的test/hello.htm文件:
root@OpenWrt:~# cat /usr/lib/lua/luci/view/test/hello.htm
<%+header%>
<h1><%:hello world%></h1>
<%+footer%>第三步:将上面文件添加完成后,保存登录路由后台可以看到结果(有时可能需要先退出再登录)
第二部分:
cbi的方式实现ip地址的设置,如图所示:第一步:/usr/lib/lua/luci/controller/admin/system.lua中注册选项:
entry({"admin", "system", "test-cbi"}, cbi("admin_system/test"), _("test-cbi"), 4).dependent = false
第二步:
root@OpenWrt:~# cat /usr/lib/lua/luci/model/cbi/admin_system/test.lua
m = Map("network", translate("Test Page by Wayne"), translate("On this page we can learn how the .lua work"))
m:chain("luci")
s = m:section(TypedSection, "netset", translate("Network Configuration"))
s.anonymous = true
s.addremove = true
s:tab("wan1", translate("Config wan1"))
ipaddr1 = s:taboption("wan1", Value, "ipaddr1", translate("address"))
ipaddr1.datatype = "ip4addr"
netmask1 = s:taboption("wan1", Value, "netmask1", translate("netmask"))
netmask1.datatype = "ip4addr"
netmask1:value("255.255.255.0")
netmask1:value("255.255.0.0")
netmask1:value("255.0.0.0")
gateway1 = s:taboption("wan1", Value, "gateway1", translate("gateway"))
gateway1.datatype = "ip4addr"
return m
第三步,在/etc/config/network文件后面添加:
config netset
保存后登录设置ip地址,再看/etc/config/network文件的变化,如下:
config netset
option ipaddr1 '192.168.1.11'
option netmask1 '255.255.255.0'
option gateway1 '192.168.1.1'
相关文章推荐
- setsockopt :SO_LINGER 选项设置
- CentOS服务器下安装Webmin管理系统的步骤
- 如何在Linux中统计一个进程的线程数
- v$session_longops 查看进程的进度
- 蔡学镛:让架构接地气,不再云里雾里
- Linux多进程之间的文件锁详解
- OpenGL 法线贴图 切线空间 整理
- Centos7搭建php+mysql环境(整理篇)
- Centos硬件信息查看命令
- 最近学习hadoop和spark的一些心得
- 关于openssl几个API的一点小收获
- Linux下安装nginx
- CentOS安装JAVA后JAVA版本不对的问题
- 为你的Archlinux Chromium安装flash插件
- shell测试
- nginx+tomcat反向代理做负载均衡常见的问题
- Linux系统下MySQL数据库的备份和恢复
- Linux系统函数read说明
- eshop截取字符串长度 和去掉省略号
- SuperMap iServer 7C(2015) war包在Linux上的WebSphere 部署