以编译ipk包方式修改openwrt web界面。

来源:互联网 发布:阿里算法工程师 编辑:程序博客网 时间:2024/06/02 14:31

一.在/home/wfly/mt7620/op/openwrt/package/下 建立/test/files目录。

二.

1.进入/test/files目录建立test.lua文件,如下:

module("luci.controller.admin.test", package.seeall)function index()local pageentry({"admin", "test"}, alias("admin", "test", "testconfig"), _("test 管理"), 35).index = trueentry({"admin", "test", "testconfig"}, cbi("admin_test/testconfig"), _("test 管理"), 1)end

2.建立testconfig.lua文件,如下:

local fs = require "nixio.fs"if fs.access("/etc/config/test") thenm2 = Map("test", translate("test 管理"),translate("test 管理!"))s = m2:section(TypedSection, "test", translate("test 管理"))s.anonymous = trues.addremove = falsets = s:option(Value, "time", translate("探针数据回传服务器间隔"),translate("探针数据回传服务器间隔"))us = s:option(Value, "url", translate("探针数据回传服务器地址"),translate("探针数据回传服务器地址"))ps = s:option(Value, "power", translate("探针探测范围"),translate("探针探测范围"))        function m2.on_commit(map)endendreturn m2

3.建立test文件,如下:

config test testoption time35option urlyk.shang-wifi.comoption power-68

三.进入test目录,建立Makefile文件,如下:

include $(TOPDIR)/rules.mk# Name and release number of this packagePKG_NAME:=testPKG_RELEASE:=1PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)include $(INCLUDE_DIR)/package.mkdefine Package/testSECTION:=utilsCATEGORY:=UtilitiesTITLE:=test -- prints a snarky messageendefdefine Package/test/descriptionIf you can't figure out what this program does, you're probably brain-dead and need immediate medical attention.endefdefine Build/Prepareendefdefine Build/Configureendefdefine Build/Compileendefdefine Package/test/install$(INSTALL_DIR) $(1)/usr/lib/luamkdir -p $(1)/usr/lib/lua/test$(INSTALL_DIR) $(1)/usr/lib/lua/test$(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller/admincp ./files/test.lua $(1)/usr/lib/lua/luci/controller/admin$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbimkdir -p $(1)/usr/lib/lua/luci/model/cbi/admin_testcp ./files/testconfig.lua $(1)/usr/lib/lua/luci/model/cbi/admin_test$(INSTALL_DIR) $(1)/etc/init.d$(INSTALL_DIR) $(1)/etc/configcp ./files/test $(1)/etc/configendef$(eval $(call BuildPackage,test))

四:进入openwrt根目录(我的是/home/wfly/mt7620/op/openwrt)

make package/test/compile 编译ipk包。

find -name test*.ipk 查看是否生成包。



 scp ./bin/ramips/packages/base/test_1_ramips_24kec.ipk root@192.168.1.1:~/   将生成的包上传到路由器。


opkg install test_1_ramips_24kec.ipk  安装ipk包。


效果如下:test管理即为添加模块。




0 0
原创粉丝点击