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

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

二.

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

module("luci.controller.admin.test", package.seeall)


function index()
	

	

	local page
	entry({"admin", "test"}, alias("admin", "test", "testconfig"), _("test 管理"), 35).index = true
	entry({"admin", "test", "testconfig"}, cbi("admin_test/testconfig"), _("test 管理"), 1)

end

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

local fs = require "nixio.fs"


if fs.access("/etc/config/test") then

m2 = Map("test", translate("test 管理"),
	translate("test 管理!"))

s = m2:section(TypedSection, "test", translate("test 管理"))
s.anonymous = true
s.addremove = false


ts = 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)
			
	end


end

return m2

3.建立test文件,如下:

config test test
	option time			35
	option url		yk.shang-wifi.com
	option power			-68
	

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

include $(TOPDIR)/rules.mk
# Name and release number of this package
PKG_NAME:=test
PKG_RELEASE:=1

PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)

include $(INCLUDE_DIR)/package.mk

define Package/test
	SECTION:=utils
	CATEGORY:=Utilities
	TITLE:=test -- prints a snarky message
endef


define Package/test/description
	If you can't figure out what this program does, you're probably brain-dead and need immediate medical attention.
endef


define Build/Prepare
endef


define Build/Configure
endef

define Build/Compile
endef
define Package/test/install
	$(INSTALL_DIR) $(1)/usr/lib/lua
	mkdir -p $(1)/usr/lib/lua/test
	$(INSTALL_DIR) $(1)/usr/lib/lua/test
	$(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller/admin
	cp ./files/test.lua $(1)/usr/lib/lua/luci/controller/admin
	$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi
	mkdir -p $(1)/usr/lib/lua/luci/model/cbi/admin_test
	cp ./files/testconfig.lua $(1)/usr/lib/lua/luci/model/cbi/admin_test
	$(INSTALL_DIR) $(1)/etc/init.d
	$(INSTALL_DIR) $(1)/etc/config
	cp ./files/test $(1)/etc/config
	
endef


$(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 [email protected]:~/   将生成的包上传到路由器。


opkg install test_1_ramips_24kec.ipk  安装ipk包。


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




你可能感兴趣的:(Web,openwrt,openwrt,界面,ipk包编译)