2023-08-10 18:10:01 +08:00
# Reference: LuCI Modules
See [online wiki ](https://github.com/openwrt/luci/wiki/Modules ) for latest version.
## Categories
2015-06-16 16:11:03 +08:00
The LuCI modules are divided into several category directories, namely:
2023-08-10 18:10:01 +08:00
* applications - Single applications or plugins for other modules
* i18n - Translation files
* libs - libraries of Luci
* modules - main modules of Luci itself
* protocols - network related plugins
* themes - Frontend themes
2015-06-16 16:11:03 +08:00
2023-08-10 18:10:01 +08:00
Each module goes into a subdirectory of this category-directories.
2015-06-16 16:11:03 +08:00
2023-08-10 18:10:01 +08:00
## Module directory
2015-06-16 16:11:03 +08:00
The contents of a module directory are as follows:
2023-08-10 18:10:01 +08:00
### Makefile
2015-06-16 16:11:03 +08:00
This is the module's makefile. If the module just contains Lua sourcecode or resources then the following Makefile should suffice.
2023-08-10 18:10:01 +08:00
```Makefile
include $(TOPDIR)/rules.mk
LUCI_TITLE:=Title of my example applications
LUCI_DEPENDS:=+some-package +libsome-library +luci-app-anotherthing
include ../../luci.mk
# call BuildPackage - OpenWrt buildroot signature
```
2015-06-16 16:11:03 +08:00
2023-08-10 18:10:01 +08:00
If you have C(++) code in your module you should include a `src/` subdirectory containing another Makefile supporting a `clean` , a `compile` and an `install` target.
The `install` target should deploy its files relative to the predefined `$(DESTDIR)` variable, e.g.
```
mkdir -p $(DESTDIR)/usr/bin; cp myexecutable $(DESTDIR)/usr/bin/myexecutable
```
2015-06-16 16:11:03 +08:00
2023-08-10 18:10:01 +08:00
### src
The `src` directory is reserved for C sourcecode.
2015-06-16 16:11:03 +08:00
2023-08-10 18:10:01 +08:00
### luasrc
`luasrc` contains all Lua sourcecode files. These will automatically be stripped or compiled depending on the Make target and are installed in the LuCI installation directory.
2015-06-16 16:11:03 +08:00
2023-08-10 18:10:01 +08:00
### lua
`lua` is equivalent to `luasrc` but containing Lua files will be installed in the Lua document root.
2015-06-16 16:11:03 +08:00
2023-08-10 18:10:01 +08:00
### htdocs
All files under `htdocs` will be copied to the document root of the target webserver.
2015-06-16 16:11:03 +08:00
2023-08-10 18:10:01 +08:00
### root
All directories and files under `root` will be copied to the installation target as they are.
2015-06-16 16:11:03 +08:00
2023-08-10 18:10:01 +08:00
### dist
`dist` is reserved for the builder to create a working installation tree that will represent the filesystem on the target machine.
**DO NOT** put any files there as they will get deleted.
2015-06-16 16:11:03 +08:00
2023-08-10 18:10:01 +08:00
### ipkg
`ipkg` contains IPKG package control files, like `preinst` , `posinst` , `prerm` , `postrm` . `conffiles` .
2015-06-16 16:11:03 +08:00
See IPKG documentation for details.
2023-08-10 18:10:01 +08:00
## OpenWRT feed integration
If you want to add your module to the LuCI OpenWRT feed you have to add several sections to the `contrib/package/luci/Makefile` .
2015-06-16 16:11:03 +08:00
For a Web UI applications this is:
A package description:
2023-08-10 18:10:01 +08:00
```Makefile
define Package/luci-app-YOURMODULE
$(call Package/luci/webtemplate)
DEPENDS+=+some-package +some-other-package
TITLE:=SHORT DESCRIPTION OF YOURMODULE
endef
```
2015-06-16 16:11:03 +08:00
A package installation target:
2023-08-10 18:10:01 +08:00
```Makefile
define Package/luci-app-YOURMODULE/install
$(call Package/luci/install/template,$(1),applications/YOURMODULE)
endef
```
2015-06-16 16:11:03 +08:00
A module build instruction:
2023-08-10 18:10:01 +08:00
```Makefile
ifneq ($(CONFIG_PACKAGE_luci-app-YOURMODULE),)
PKG_SELECTED_MODULES+=applications/YOURMODULE
endif
```
2015-06-16 16:11:03 +08:00
A build package call:
2023-08-10 18:10:01 +08:00
```Makefile
$(eval $(call BuildPackage,luci-app-YOURMODULE))
```