### Install luci-app-example using APK Source: https://github.com/openwrt/luci/blob/master/applications/luci-app-example/README.md Installs the luci-app-example package on your OpenWrt installation. After installation, log in to the web UI and 'Example' should appear in the navigation menu. ```sh apk add luci-app-example ``` -------------------------------- ### Install LuCI and Start Web Server Source: https://github.com/openwrt/luci/wiki/DevelopmentEnvironmentHowTo Install the LuCI package and enable/start the uhttpd web server if they are not already present. This ensures LuCI is accessible via the browser. ```bash opkg update; opkg install luci /etc/init.d/uhttpd enable; /etc/init.d/uhttpd start ``` -------------------------------- ### install Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.model.ipkg.html Installs one or more packages using opkg. ```APIDOC ## install ### Description Installs one or more packages. Accepts a variable number of package names as arguments. ### Parameters * `...` (string) - A list of package names to install. ### Return Values * `boolean` - True if the installation was successful, false otherwise. * `number` - The opkg return code. * `string` - The standard output from the opkg command. * `string` - The standard error from the opkg command. ``` -------------------------------- ### Install luci-app-example from Git Source: https://github.com/openwrt/luci/blob/master/applications/luci-app-example/README.md Installs the luci-app-example by copying files and executing a UCI defaults script. Ensure you log out and back in to refresh the cache. ```sh scp -r root/* root@192.168.1.1:/ scp -r htdocs/* root@192.168.1.1:/www/ # execute the UCI defaults script to create the /etc/config/example ssh root@192.168.1.1 "sh /etc/uci-defaults/80_example" ``` -------------------------------- ### Install luci-app-rustdesk-server from Repository Source: https://github.com/openwrt/luci/blob/master/applications/luci-app-rustdesk-server/README.md Install the RustDesk server LuCI application using the opkg package manager on OpenWrt. This is the recommended method for most users. ```bash opkg update opkg install luci-app-rustdesk-server ``` -------------------------------- ### Synchronize PO files for a specific application (example) Source: https://github.com/openwrt/luci/blob/master/doc_gen/tutorials/i18n.md Example of synchronizing PO files for the 'luci-app-acl' application. ```shell ./build/i18n-sync.sh applications/luci-app-acl ``` -------------------------------- ### Install and Restart RPC Packages Source: https://github.com/openwrt/luci/wiki/JsonRpcHowTo Install necessary packages for the JSON-RPC API and restart the uhttpd service to enable it. ```bash opkg install luci-mod-rpc luci-lib-ipkg luci-compat /etc/init.d/uhttpd restart ``` -------------------------------- ### Manual Installation of luci-app-rustdesk-server Source: https://github.com/openwrt/luci/blob/master/applications/luci-app-rustdesk-server/README.md Manually install the luci-app-rustdesk-server by copying the application files to the appropriate locations on your OpenWrt device. This method requires setting execute permissions for the init script and reloading the rpcd service. ```bash # Copy htdocs to /www cp -r htdocs/luci-static /www/luci-static/ # Copy root files cp -r root/* / # Set permissions chmod +x /etc/init.d/rustdesk-server ``` ```bash /etc/init.d/rpcd reload ``` ```bash rm -rf /tmp/luci-* ``` -------------------------------- ### LuCI Plugins UCI Configuration Example Source: https://github.com/openwrt/luci/blob/master/plugins/luci-plugin-auth-example/README.md Example configuration for enabling and setting up authentication plugins via the `luci_plugins` UCI config. ```uci config global 'global' option enabled '1' # Global plugin system option auth_login_enabled '1' # Auth plugin class config auth_login 'd0ecde1b009d44ff82faa8b0ff219cef' option name 'Example Auth Plugin' option enabled '1' option priority '10' option challenge_field 'verification_code' option help_text 'Enter your code' option test_code '123456' ``` -------------------------------- ### Verify RustDesk Server Binary Installation Source: https://github.com/openwrt/luci/blob/master/applications/luci-app-rustdesk-server/README.md After installing the RustDesk server binaries, verify their installation by checking their versions using the command line. This ensures that the binaries are accessible and functional. ```bash /usr/bin/hbbs --version /usr/bin/hbbr --version ``` -------------------------------- ### Install luci-app-advanced-reboot Source: https://github.com/openwrt/luci/blob/master/applications/luci-app-advanced-reboot/README.md Installs the luci-app-advanced-reboot package using opkg. Ensure your package lists are updated first. ```sh opkg update opkg install luci-app-advanced-reboot ``` -------------------------------- ### UCI Configuration Example for WifiSchedule Source: https://github.com/openwrt/luci/blob/master/applications/luci-app-wifischedule/README.md This is an example of the UCI configuration file for wifi_schedule. It defines global settings and specific schedule entries for enabling/disabling WiFi on certain days and times. ```uci config global option logging '0' option enabled '0' option recheck_interval '10' option modules_retries '10' config entry 'Businesshours' option enabled '0' option daysofweek 'Monday Tuesday Wednesday Thursday Friday' option starttime '06:00' option stoptime '22:00' option forcewifidown '0' config entry 'Weekend' option enabled '0' option daysofweek 'Saturday Sunday' option starttime '00:00' option stoptime '00:00' option forcewifidown '1' ``` -------------------------------- ### OpenWrt Feed Integration: Package Installation Target Source: https://github.com/openwrt/luci/wiki/Modules Specifies the installation template for a LuCI Web UI application package within the OpenWrt feed. ```makefile define Package/luci-app-YOURMODULE/install $(call Package/luci/install/template,$(1),applications/YOURMODULE) endef ``` -------------------------------- ### Install RustDesk Server Binaries on OpenWrt Source: https://github.com/openwrt/luci/blob/master/applications/luci-app-rustdesk-server/README.md Steps to download and install RustDesk server binaries (hbbs and hbbr) on an OpenWrt device. Ensure you check your architecture and use the correct download link from GitHub releases. After extraction, copy the binaries to /usr/bin and make them executable. ```bash # Check your architecture uname -m # Download appropriate binaries from: # https://github.com/rustdesk/rustdesk-server/releases # Example for aarch64: wget https://github.com/rustdesk/rustdesk-server/releases/download/1.1.11/rustdesk-server-linux-arm64v8.zip unzip rustdesk-server-linux-arm64v8.zip cp amd64/hbbs amd64/hbbr /usr/bin/ chmod +x /usr/bin/hbbs /usr/bin/hbbr ``` -------------------------------- ### Using OpenWrt SDK for Package Development Source: https://github.com/openwrt/luci/wiki/Source-Code Instructions for using the OpenWrt SDK to test and develop packages. Place your package directory in the 'package/' subdirectory and run 'make'. Use './scripts/feeds' to install core packages. ```bash make ``` ```bash ./scripts/feeds ``` -------------------------------- ### Update and Install LuCI Feed Packages Source: https://github.com/openwrt/luci/blob/master/README.md Run these commands after adding the LuCI feed to your configuration to update and install all its package definitions. ```shell ./scripts/feeds update luci ./scripts/feeds install -a -p luci ``` -------------------------------- ### LuCI Theme Post-Installation Script Source: https://github.com/openwrt/luci/wiki/ThemesHowTo This 'postinst' script handles the registration of the theme during package installation. It executes the UCI defaults script and then removes it. ```sh #!/bin/sh [ -n "${IPKG_INSTROOT}" ] || { ( . /etc/uci-defaults/luci-theme-mytheme ) && rm -f /etc/uci-defaults/luci-theme-mytheme } ``` -------------------------------- ### LuCI Module Makefile for C/C++ Code Source: https://github.com/openwrt/luci/wiki/Modules Instructions for modules containing C/C++ source code, requiring a src/ subdirectory with its own Makefile for compilation and installation. The install target must use $(DESTDIR). ```makefile mkdir -p $(DESTDIR)/usr/bin; cp myexecutable $(DESTDIR)/usr/bin/myexecutable ``` -------------------------------- ### Query System Net Conntrack Source: https://github.com/openwrt/luci/wiki/JsonRpcHowTo This example demonstrates how to query the system's net conntrack information using the RPC API. Replace `` and `yourtoken` with your specific details. ```sh curl http:///cgi-bin/luci/rpc/sys?auth=yourtoken --data ' { "method": "net.conntrack" }' ``` -------------------------------- ### installed Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.model.ipkg.html Checks if a specific package is currently installed. ```APIDOC ## installed ### Description Determines whether a given package is installed on the system. ### Parameters * `pkg` (string) - The name of the package to check. ### Return Value * `boolean` - True if the package is installed, false otherwise. ``` -------------------------------- ### uname Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/nixio.html Gets information about the current system and kernel. ```APIDOC ## uname ### Description (POSIX) Get information about current system and kernel. ### Return value Table containing: * sysname (string) - operating system * nodename (string) - network name (usually hostname) * release (string) - OS release * version (string) - OS version * machine (string) - hardware identifier ``` -------------------------------- ### ipkg Post-installation Script Source: https://github.com/openwrt/luci/wiki/HowTo:-Create-Themes Registers the theme with LuCI upon package installation. It ensures the UCI defaults are applied correctly. ```sh #!/bin/sh [ -n "${IPKG_INSTROOT}" ] || { ( . /etc/uci-defaults/luci-theme-mytheme ) && rm -f /etc/uci-defaults/luci-theme-mytheme } ``` -------------------------------- ### Get Auth Token Response Source: https://github.com/openwrt/luci/blob/master/doc_gen/tutorials/JsonRpcHowTo.md This is an example of a successful response from the 'login' method, containing the authentication token. ```json {"id":1,"result":"65e60c5a93b2f2c05e61681bf5e94b49","error":null} ``` -------------------------------- ### info Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.model.ipkg.html Retrieves detailed information about installed and available packages. ```APIDOC ## info ### Description Returns detailed information about installed and available packages. The output can be filtered to a specific set of packages. ### Parameters * `pkg` (string | table) - A package name or a table of package names to retrieve information for. ### Return Value * `table` - A table containing package information. ``` -------------------------------- ### uname Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/nixio.html (POSIX) Get information about the current system and kernel. ```APIDOC ## uname ### Description (POSIX) Get information about the current system and kernel. ### Parameters None. ``` -------------------------------- ### ACL Declarations for UCI Access Source: https://github.com/openwrt/luci/blob/master/applications/luci-app-example/README.md Example ACL declarations for granting read and write access to UCI configuration nodes. The 'example' node name maps to '/etc/config/example'. ```json { "luci-app-example": { "read": { "uci": ["example"] }, "write": { "uci": ["example"] } } } ``` -------------------------------- ### luci.sys.hostname Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.sys.html Gets or sets the system's hostname. ```APIDOC ## luci.sys.hostname ### Description Get or set the current hostname. ### Parameters * `String`: containing a new hostname to set (optional). ### Return Value String containing the system hostname. ``` -------------------------------- ### list_installed Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.model.ipkg.html Lists all currently installed packages, optionally filtered by a pattern. ```APIDOC ## list_installed ### Description Lists all packages that are currently installed on the system. A callback function is invoked for each installed package. ### Parameters * `pat` (string | nil) - A pattern to filter the list of installed packages. If nil, all installed packages are listed. * `cb` (function) - A callback function that receives the package name, version, and description as arguments for each installed package. ### Return Value * None ``` -------------------------------- ### Make RustDesk Binaries Executable Source: https://github.com/openwrt/luci/blob/master/applications/luci-app-rustdesk-server/README.md Ensure the hbbs and hbbr binaries have execute permissions. This is necessary for the service to start correctly. ```bash chmod +x /usr/bin/hbbs /usr/bin/hbbr ``` -------------------------------- ### sysinfo Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/nixio.html Gets overall system statistics. ```APIDOC ## sysinfo ### Description (Linux) Get overall system statistics. ### Return value Table containing: * uptime (number) - system uptime in seconds * loads (table) - {loadavg1, loadavg5, loadavg15} * totalram (number) - total RAM * freeram (number) - free RAM * sharedram (number) - shared RAM * bufferram (number) - buffered RAM * totalswap (number) - total SWAP * freeswap (number) - free SWAP * procs (number) - number of running processes ``` -------------------------------- ### Referencing Static Media in HTML Source: https://github.com/openwrt/luci/wiki/HowTo:-Create-Themes Example of how to link to static assets like stylesheets within your theme's HTML templates. The `<%=media%>` variable points to the theme's static directory. ```html ``` -------------------------------- ### Get All UCI Configuration Source: https://github.com/openwrt/luci/blob/master/doc_gen/tutorials/JsonRpcHowTo.md This command retrieves all configuration settings for a specified section (e.g., 'network') from the UCI RPC library. Ensure you replace 'yourtoken' with a valid authentication token. ```shell curl http:///cgi-bin/luci/rpc/uci?auth=yourtoken --data ' { "method": "get_all", "params": [ "network" ] }' ``` -------------------------------- ### Initialize PO files for all applications Source: https://github.com/openwrt/luci/blob/master/doc_gen/tutorials/i18n.md Run this script from the LuCI repository root to create skeleton .po files for all existing languages across all sub-folders. ```shell ./build/i18n-add-language.sh ``` -------------------------------- ### Initialize PO files for a specific application Source: https://github.com/openwrt/luci/blob/master/doc_gen/tutorials/i18n.md Run this script from within an application's folder to create skeleton .po files for all available languages for that app. ```shell ../../build/i18n-add-language.sh ``` -------------------------------- ### Initialize translation files for a new language Source: https://github.com/openwrt/luci/wiki/i18n Run `i18n-add-language.sh` from an application's directory or the LuCI root to create skeleton `.po` files for all available languages. ```bash ../../build/i18n-add-language.sh ``` ```bash ./build/i18n-add-language.sh ``` -------------------------------- ### Build luci-app-rustdesk-server from Source Source: https://github.com/openwrt/luci/blob/master/applications/luci-app-rustdesk-server/README.md For development purposes, you can build the luci-app-rustdesk-server package from its source code. This involves cloning the LuCI repository and then compiling the specific package. ```bash # Clone the LuCI repository git clone https://github.com/openwrt/luci.git cd luci # Build the package make package/luci-app-rustdesk-server/compile ``` -------------------------------- ### luci.sys.init Functions Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.sys.init.html This section details the functions available in the luci.sys.init module for managing init scripts. ```APIDOC ## init.disable(name) ### Description Disable the given init script. ### Parameters * name (string) - Name of the init script ### Return Value * boolean - Indicating success ## init.enable(name) ### Description Enable the given init script. ### Parameters * name (string) - Name of the init script ### Return Value * boolean - Indicating success ## init.enabled(name) ### Description Test whether the given init script is enabled. ### Parameters * name (string) - Name of the init script ### Return Value * boolean - Indicating whether init is enabled ## init.index(name) ### Description Get the index of the given init script. ### Parameters * name (string) - Name of the init script ### Return Value * number - Numeric index value ## init.names() ### Description Get the names of all installed init scripts. ### Return Value * table - Containing the names of all installed init scripts ## init.start(name) ### Description Start the given init script. ### Parameters * name (string) - Name of the init script ### Return Value * boolean - Indicating success ## init.stop(name) ### Description Stop the given init script. ### Parameters * name (string) - Name of the init script ### Return Value * boolean - Indicating success ``` -------------------------------- ### Get or Set CIDR Prefix Size Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.ip.cidr.html Use the `prefix` function to get the current prefix size of a CIDR instance. Optionally, provide a number or netmask string to set a new prefix size. ```lua local range = luci.ip.new("192.168.1.1/255.255.255.0") print(range:prefix()) -- 24 range:prefix(16) print(range:prefix()) -- 16 range:prefix("255.255.255.255") print(range:prefix()) -- 32 ``` -------------------------------- ### nixio.exece Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/nixio.html Executes a file with a custom environment to replace the current process. ```APIDOC ## nixio.exece ### Description Execute a file with a custom environment to replace the current process. ### Parameters - **executable** (string) - The path to the executable file. - **arguments** (table) - A table of arguments to pass to the executable. - **environment** (table) - A table representing the environment variables. ``` -------------------------------- ### times Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/nixio.html Gets process times. ```APIDOC ## times ### Description (POSIX) Get process times. ### Return value Table containing: * utime (number) - user time * utime (number) - system time * cutime (number) - children user time * cstime (number) - children system time ``` -------------------------------- ### times Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/nixio.html (POSIX) Get process times. ```APIDOC ## times ### Description (POSIX) Get process times. ### Parameters None. ``` -------------------------------- ### sysinfo Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/nixio.html (Linux) Get overall system statistics. ```APIDOC ## sysinfo ### Description (Linux) Get overall system statistics. ### Parameters None. ``` -------------------------------- ### OpenWrt Feed Integration: Module Build Instruction Source: https://github.com/openwrt/luci/wiki/Modules Conditionally selects a LuCI module for building based on the OpenWrt configuration, adding it to PKG_SELECTED_MODULES. ```makefile ifneq ($(CONFIG_PACKAGE_luci-app-YOURMODULE),) PKG_SELECTED_MODULES+=applications/YOURMODULE endif ``` -------------------------------- ### mkdirr(dest, mode) Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/nixio.fs.html Recursively creates a directory and any necessary parent directories. ```APIDOC ## mkdirr(dest, mode) ### Description Create a directory and all needed parent directories recursively. ### Parameters * dest: The destination path for the directory. * mode: The mode for the created directories. ``` -------------------------------- ### HTML/Lua for Displaying Network Interface Options Source: https://github.com/openwrt/luci/blob/master/modules/luci-compat/luasrc/view/cbi/network_ifacelist.htm Renders individual network interface options within a list. It displays the interface name, icon (indicating status), and localized name. Optionally shows associated networks with links. ```html+lua <% for _, iface in ipairs(ifaces) do if (not self.noaliases or iface:type() ~= "alias") and (not self.nobridges or not iface:is_bridge()) and (not self.noinactive or iface:is_up()) and iface:name() ~= self.exclude then %> <% end %><% ``` -------------------------------- ### source Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.http.html Gets the raw HTTP input source. ```APIDOC ## source ### Description Get the RAW HTTP input source. ``` -------------------------------- ### upgrade Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.model.ipkg.html Upgrades all installed packages to their latest available versions. ```APIDOC ## upgrade ### Description Upgrades all installed packages. ### Return values: 1. Boolean indicating the status of the action 2. OPKG return code, STDOUT and STDERR ``` -------------------------------- ### nixio.open Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/nixio.html Opens a file at the specified path with the given flags and mode. ```APIDOC ## nixio.open ### Description Open a file. ### Parameters - **path** (string) - The path to the file. - **flags** (number) - Flags for opening the file (e.g., O_RDONLY, O_WRONLY, O_CREAT). - **mode** (number, optional) - The file mode if creating the file. ``` -------------------------------- ### Cursor:load Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.model.uci.html Manually loads a UCI configuration file. ```APIDOC ## Cursor:load ### Description Manually loads a specified UCI configuration file into the cursor's memory. ### Parameters #### Path Parameters - **config** (string) - Required - The configuration file name to load. ``` -------------------------------- ### upgrade Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.model.ipkg.html Upgrades all installed packages to their latest available versions. ```APIDOC ## upgrade ### Description Upgrades all installed packages on the system to their latest available versions based on the current package lists. ### Return Value * None ``` -------------------------------- ### Cursor:load Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.model.uci.html Manually loads a UCI configuration file. ```APIDOC ## Cursor:load ### Description Manually load a config. ### Parameters * config: UCI config (string) ### Return value Boolean whether operation succeeded ### See also: * [Cursor:save](#Cursor.save) * [Cursor:unload](#Cursor.unload) ``` -------------------------------- ### strerror Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/nixio.html Gets the error message for the corresponding error code. ```APIDOC ## strerror ### Description Get the error message for the corresponding error code. ### Parameters * **errno** (number) - System error code ### Return value Error message ``` -------------------------------- ### open Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/nixio.html Opens a file with specified path, flags, and mode. ```APIDOC ## open(path, flags, mode) ### Description Open a file. ### Parameters * path: Filesystem path to open * flags: Flag string or number (see open_flags). ["r", "r+", "w", "w+", "a", "a+"] * mode: File mode for newly created files (see chmod, umask). ### Usage: Although this function also supports the traditional fopen() file flags it does not create a file stream but uses the open() syscall. ### Return value: File Object ### See also: * [umask](#nixio.umask) * [open_flags](#nixio.open_flags) ``` -------------------------------- ### strerror Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/nixio.html Get the error message for the corresponding error code. ```APIDOC ## strerror ### Description Get the error message for the corresponding error code. ### Parameters - **errno** (number) - The error number. ``` -------------------------------- ### Cursor:get_all Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.model.uci.html Retrieves all sections of a configuration or all options within a specific section. ```APIDOC ## Cursor:get_all ### Description Gets all sections of a given configuration, or all options within a specified section. ### Parameters #### Path Parameters - **config** (string) - Required - The configuration file name. - **section** (string) - Optional - The name or type of the section to retrieve options from. If omitted, all sections of the config are returned. ``` -------------------------------- ### Initialize CBI and Include Footer Partial Source: https://github.com/openwrt/luci/blob/master/modules/luci-compat/luasrc/view/cbi/footer.htm Initializes the CBI system and includes the standard footer partial. This should be called at the end of the page rendering process. ```html cbi_init(); <%+footer%> ``` -------------------------------- ### mkdirr(dest, mode) Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/nixio.fs.html Recursively creates a directory and all necessary parent directories with an optional file mode. ```APIDOC ## mkdirr(dest, mode) ### Description Create a directory and all needed parent directories recursively. ### Parameters * dest: Destination path * mode: File mode (optional, see chmod and umask) ### Return value: true ### See also: * [chmod](#nixio.fs.chmod) * umask ``` -------------------------------- ### formvalue Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.http.html Gets a specific HTTP input value or all input values. ```APIDOC ## formvalue ### Description Get a certain HTTP input value or a table of all input values. ### Parameters * name: Name of the GET or POST variable to fetch * noparse: Don't parse POST data before getting the value ### Return value: HTTP input value or table of all input value ``` -------------------------------- ### Cursor:get Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.model.uci.html Retrieves the value of a specific option or the type of a section from a UCI configuration. ```APIDOC ## Cursor:get ### Description Get a section type or an option ### Parameters * config: UCI config (string) * section: UCI section name (string) * option: UCI option (string, optional) ### Return value UCI value ``` -------------------------------- ### cidr:prefix Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.ip.cidr.html Gets or sets the prefix size (mask length) of the CIDR instance. ```APIDOC ## cidr:prefix ### Description Get or set prefix size of CIDR instance. ### Method `prefix(mask)` ### Parameters * **mask** (number, optional) - The new prefix size to set. If omitted, the current prefix size is returned. ### Return Value If `mask` is provided, returns the `cidr` object itself (for chaining). If `mask` is omitted, returns the current prefix size (number). ``` -------------------------------- ### Cursor:get Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.model.uci.html Retrieves the value of a specific option within a section, or the type of a section. ```APIDOC ## Cursor:get ### Description Gets the value of a specific option within a section, or the type of a section if no option is specified. ### Parameters #### Path Parameters - **config** (string) - Required - The configuration file name. - **section** (string) - Required - The name or type of the section. - **option** (string) - Optional - The name of the option to retrieve. If omitted, the section type is returned. ``` -------------------------------- ### Login to Auth RPC Library Source: https://github.com/openwrt/luci/blob/master/doc_gen/tutorials/JsonRpcHowTo.md Use this command to obtain an authentication token by logging into the 'auth' RPC library. Replace , 'youruser', and 'somepassword' with your actual details. ```shell curl http:///cgi-bin/luci/rpc/auth --data ' { "id": 1, "method": "login", "params": [ "youruser", "somepassword" ] }' ``` -------------------------------- ### Clone LuCI Stable Branch Source: https://github.com/openwrt/luci/wiki/Source-Code Checkout a specific stable branch of the LuCI repository. Ensure you have Git installed. ```bash git clone https://github.com/openwrt/luci.git git checkout luci-0.12 ``` -------------------------------- ### luci.sys.process.list Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.sys.process.html Fetches information about all currently running processes on the system. ```APIDOC ## luci.sys.process.list ### Description Retrieve information about currently running processes. ### Return value: Table containing process information ``` -------------------------------- ### parser:get Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.jsonc.parser.html Converts the parsed JSON data into a Lua table. This should be called after `parser:parse` has indicated that parsing is complete. ```APIDOC ## parser:get() ### Description Converts the internally parsed JSON data into a Lua table. ### Usage ```lua parser = luci.jsonc.new() parser:parse('{ "example": "test" }') data = parser:get() print(data.example) -- "test" ``` ### Return Value * The parsed JSON object converted into a Lua table, or `nil` if the parser didn't finish or encountered an error. ### See Also * [parser:parse](#parser.parse) ``` -------------------------------- ### Cursor:section Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.model.uci.html Creates a new section in a UCI configuration and initializes it with provided data. ```APIDOC ## Cursor:section ### Description Creates a new section within a UCI configuration and initializes it with provided data. ### Parameters #### Path Parameters - **config** (string) - Required - The configuration file name. - **type** (string) - Required - The type of the section to create. - **name** (string) - Optional - The name of the section. If omitted, an anonymous section is created. - **values** (table) - Optional - A table containing key-value pairs to initialize the section with. ``` -------------------------------- ### get(...) Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.dispatcher.html Fetches or creates a dispatching node without setting the target module or enabling the node. Accepts a virtual path as arguments. ```APIDOC ## get(...) ### Description Fetch or create a dispatching node without setting the target module or enabling the node. ### Parameters * ...: Virtual path ### Return value: Dispatching tree node ``` -------------------------------- ### Create RustDesk Key Directory Source: https://github.com/openwrt/luci/blob/master/applications/luci-app-rustdesk-server/README.md Ensure the directory for storing RustDesk keys exists. This command creates the directory if it does not already exist. ```bash mkdir -p /etc/rustdesk ``` -------------------------------- ### lstat(path, field) Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/nixio.fs.html Gets file status and attributes without resolving symlinks. An optional field parameter can be used to retrieve a specific attribute. ```APIDOC ## lstat(path, field) ### Description Get file status and attributes and do not resolve if target is a symlink. ### Parameters * path: Path * field: Only return a specific field, not the whole table (optional) ### Return value: Table containing attributes (see stat for a detailed description) ### See also: * [stat](#nixio.fs.stat) ``` -------------------------------- ### entry(path, target, title, order) Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.dispatcher.html Creates a new dispatching node and defines common parameters. ```APIDOC ## entry(path, target, title, order) ### Description Create a new dispatching node and define common parameters. ### Parameters * path: Virtual path * target: Target function to call when dispatched. * title: Destination node title * order: Destination node order value (optional) ### Return value: Dispatching tree node ``` -------------------------------- ### Check Running RustDesk Server Processes Source: https://github.com/openwrt/luci/blob/master/applications/luci-app-rustdesk-server/README.md Verify if the hbbs and hbbr processes are currently running on the system. This helps in diagnosing if the service has started successfully. ```bash pidof hbbs hbbr ``` -------------------------------- ### po2lmo Utility Usage Source: https://github.com/openwrt/luci/wiki/i18n Display the usage instructions for the po2lmo utility. This shows the expected command-line arguments for converting PO files to LMO files. ```bash ./po2lmo Usage: ./po2lmo input.po output.lmo ``` -------------------------------- ### Registering Theme with UCI Defaults Source: https://github.com/openwrt/luci/blob/master/doc_gen/tutorials/ThemesHowTo.md Configures LuCI to recognize and use the new theme by setting UCI variables. This script should be placed in `root/etc/uci-defaults/`. ```sh #!/bin/sh uci batch <<-"EOF" set luci.themes.MyTheme=/luci-static/mytheme set luci.main.mediaurlbase=/luci-static/mytheme commit luci EOF exit 0 ``` -------------------------------- ### MAC Constructor Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.ip.html Constructs a new MAC luci.ip.cidr instance. It can parse MAC addresses with CIDR notation or a separate mask. Throws an error for invalid input. ```APIDOC ## MAC Constructor ### Description Constructs a new MAC luci.ip.cidr instance. Throws an error if the given string does not represent a valid ethernet MAC address or if the given optional mask is of a different family. ### Parameters * address: String containing a valid ethernet MAC address, optionally with prefix size (CIDR notation) or mask separated by slash. * netmask: String containing a valid MAC address mask or number containing a prefix size between `0` and `48` bit. Overrides mask embedded in the first argument if specified. (optional) ### Usage: ```lua intel_macs = luci.ip.MAC("C0:B6:F9:00:00:00/24") intel_macs = luci.ip.MAC("C0:B6:F9:00:00:00/FF:FF:FF:0:0:0") intel_macs = luci.ip.MAC("C0:B6:F9:00:00:00", "FF:FF:FF:0:0:0") intel_macs = luci.ip.MAC("C0:B6:F9:00:00:00/24", 48) -- override mask ``` ### Return value: A `luci.ip.cidr` object representing the given MAC address range. ``` -------------------------------- ### cidr:prefix Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.ip.cidr.html Get or set the prefix size of a CIDR instance. If an optional mask parameter is given, the prefix size is altered; otherwise, the current prefix size is returned. ```APIDOC ## cidr:prefix ### Description Get or set prefix size of CIDR instance. If the optional mask parameter is given, the prefix size of this CIDR is altered else the current prefix size is returned. ### Parameters * mask: Either a number containing the number of bits (`0..32` for IPv4, `0..128` for IPv6 or `0..48` for MAC addresses) or a string containing a valid netmask (optional) ### Usage: ```lua local range = luci.ip.new("192.168.1.1/255.255.255.0") print(range:prefix()) -- 24 range:prefix(16) print(range:prefix()) -- 16 range:prefix("255.255.255.255") print(range:prefix()) -- 32 ``` ### Return value: Bit count of the current prefix size ``` -------------------------------- ### LuCI Header Template Initialization Source: https://github.com/openwrt/luci/blob/master/doc_gen/tutorials/ThemesHowTo.md Initializes the LuCI header template by importing necessary modules and setting the HTTP content type. Adapt 'text/html' as needed. ```lua {% import { getuid, getspnam } from 'luci.core'; const boardinfo = ubus.call('system', 'board'); http.prepare_content('text/html; charset=UTF-8'); -%} ``` -------------------------------- ### Retrieving Parsed JSON Data Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.jsonc.parser.html Shows how to parse a JSON string and then retrieve the resulting Lua table using the `get()` method. This is useful after `parser:parse()` has indicated completion. ```lua parser = luci.jsonc.new() parser:parse('{ "example": "test" }') data = parser:get() print(data.example) -- "test" ``` -------------------------------- ### Generate base PO template using multiple modules Source: https://github.com/openwrt/luci/blob/master/doc_gen/tutorials/i18n.md This command scans various LuCI modules and protocols to generate the 'base.pot' template file for the 'luci-base' module. ```shell ./build/i18n-scan.pl \ modules/luci-base modules/luci-compat modules/luci-lua-runtime \ modules/luci-mod-network modules/luci-mod-status modules/luci-mod-system \ protocols themes \ > modules/luci-base/po/templates/base.pot ``` -------------------------------- ### ACL Declarations for RPC and UBUS Access Source: https://github.com/openwrt/luci/blob/master/applications/luci-app-example/README.md Example ACL declarations for granting read access to UBUS methods via RPC. This allows calling specific RPC functions, such as those related to 'luci.example'. ```json { "luci-app-example": { "read": { "ubus": { "luci.example": [] } } } } ``` -------------------------------- ### nixio.exece Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/nixio.html Replaces the current process with a new executable, allowing a custom environment and arguments. The executable name is automatically passed as argv[0]. This function does not return on success. ```APIDOC ## exece(executable, arguments, environment) ### Description Execute a file with a custom environment to replace the current process. ### Parameters * **executable** (string) - Executable * **arguments** (table) - Argument Table * **environment** (table) - Environment Table (optional) ### Usage * The name of the executable is automatically passed as argv[0] * This function does not return on success. ``` -------------------------------- ### OpenWrt Feed Integration: Package Description Source: https://github.com/openwrt/luci/wiki/Modules Defines a LuCI Web UI application package for the OpenWrt feed. Includes dependencies and a short title for the module. ```makefile define Package/luci-app-YOURMODULE $(call Package/luci/webtemplate) DEPENDS+=+some-package +some-other-package TITLE:=SHORT DESCRIPTION OF YOURMODULE endef ``` -------------------------------- ### luci.ip.link Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.ip.html Fetches basic information about a network device. Returns an empty table if the interface is not found. ```APIDOC ## luci.ip.link ### Description Fetch basic device information for a given network device. ### Parameters * `device` (string): The name of the network device to query. ### Return Value Returns a table containing device information if the interface is found, otherwise an empty table. ### Device Information Fields * `up` (boolean): True if the device is in the IFF_RUNNING state. * `type` (number): Numeric value indicating the type of the device (e.g., 1 for ethernet). * `name` (string): The name of the device. * `master` (string, optional): The name of the parent bridge device if the queried device is a bridge port. * `mtu` (number): The current MTU of the device. * `qlen` (number): The TX queue length of the device. * `mac` (luci.ip.cidr): The MAC address of the device. ### Usage Examples ```lua -- Test whether device br-lan exists print(luci.ip.link("br-lan").name ~= nil) -- Query MAC address of eth0 print(luci.ip.link("eth0").mac) ``` ``` -------------------------------- ### Derive Host Address from CIDR Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.ip.cidr.html Use the `host` function to get the host address part of a CIDR instance. This effectively sets the prefix size to the maximum for the address type (32 for IPv4, 128 for IPv6). ```lua local range = luci.ip.new("172.19.37.45/16") print(range) -- "172.19.37.45/16" print(range:host()) -- "172.19.37.45" ``` -------------------------------- ### exec Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.util.html Executes a commandline and captures its standard output. ```APIDOC ## exec ### Description Execute given commandline and gather stdout. ### Parameters - **command** (string) - The command to execute. ### Returns - **string**: The standard output of the command. ``` -------------------------------- ### exec Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.util.html Executes a commandline and captures its standard output. ```APIDOC ## exec ### Description Execute given commandline and gather stdout. ### Parameters * command: String containing command to execute ### Return value: String containing the command's stdout ``` -------------------------------- ### Authentication - Login Method Source: https://github.com/openwrt/luci/wiki/JsonRpcHowTo Demonstrates how to obtain an authentication token by calling the 'login' method of the 'auth' RPC-Library. This is required for accessing most exported libraries. ```APIDOC ## POST /cgi-bin/luci/rpc/auth ### Description Authenticates a user and returns an authentication token. ### Method POST ### Endpoint /cgi-bin/luci/rpc/auth ### Parameters #### Request Body - **id** (number) - Required - JSON-RPC request ID. - **method** (string) - Required - The method to call, should be "login". - **params** (array) - Required - An array containing the username and password. - **username** (string) - Required - The username for authentication. - **password** (string) - Required - The password for authentication. ### Request Example ```json { "id": 1, "method": "login", "params": [ "youruser", "somepassword" ] } ``` ### Response #### Success Response (200) - **id** (number) - The request ID. - **result** (string) - The authentication token if login is successful. - **error** (null) - Should be null on success. #### Response Example ```json { "id": 1, "result": "65e60c5a93b2f2c05e61681bf5e94b49", "error": null } ``` ``` -------------------------------- ### Scan multiple packages for shared translation templates Source: https://github.com/openwrt/luci/wiki/i18n Use `i18n-scan.pl` to scan multiple application directories and aggregate their translatable strings into a shared template `.pot` file. ```bash ./build/i18n-scan.pl applications/[package-1] applications/[package-2] applications/[package-n] > [location of shared template]/[application].pot ``` ```bash ./build/i18n-scan.pl \ modules/luci-base modules/luci-compat modules/luci-lua-runtime \ modules/luci-mod-network modules/luci-mod-status modules/luci-mod-system \ protocols themes \ > modules/luci-base/po/templates/base.pot ``` -------------------------------- ### luci.sys.mounts Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.sys.html Retrieves information about currently mounted file systems. ```APIDOC ## luci.sys.mounts ### Description Retrieve information about currently mounted file systems. ### Return Value Table containing mount information. ``` -------------------------------- ### HTML/Lua for Creating a Custom Interface Source: https://github.com/openwrt/luci/blob/master/modules/luci-compat/luasrc/view/cbi/network_ifacelist.htm Provides an option to create a new custom network interface. This is typically rendered as a selectable item or button, allowing users to define new network configurations. ```html+lua <% if not self.nocreate then %> * ![](<%=resource%>/icons/ethernet_disabled.svg "<%:Custom Interface%>") <%:Custom Interface%>: <% end %> ``` -------------------------------- ### luci.sys.httpget Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.sys.html Fetches the content of a resource from a given URL. ```APIDOC ## luci.sys.httpget ### Description Returns the contents of a documented referred by an URL. ### Parameters * `url`: The URL to retrieve. * `stream`: Return a stream instead of a buffer. * `target`: Directly write to target file name. ### Return Value String containing the contents of the given URL. ``` -------------------------------- ### openlog Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/nixio.html Opens a connection to the system logger. ```APIDOC ## openlog(ident, flag1, ...) ### Description (POSIX) Open a connection to the system logger. ### Parameters * ident: Identifier * flag1: Flag 1 ["cons", "nowait", "pid", "perror", "ndelay", "odelay"] * ...: More flags [-"-"] ``` -------------------------------- ### Check RustDesk Binaries Exist Source: https://github.com/openwrt/luci/blob/master/applications/luci-app-rustdesk-server/README.md Verify that the hbbs and hbbr binaries are present in the /usr/bin directory. This is a crucial step for troubleshooting service startup issues. ```bash ls -la /usr/bin/hbbs /usr/bin/hbbr ``` -------------------------------- ### nixio.exec Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/nixio.html Replaces the current process with a new executable. Accepts a variable number of arguments. ```APIDOC ## nixio.exec ### Description Execute a file to replace the current process. ### Parameters - **executable** (string) - The path to the executable file. - **...** (any) - Variable arguments to be passed to the executable. ``` -------------------------------- ### nixio.connect Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/nixio.html Creates a new socket and connects to a network address. This is a shortcut for calling nixio.socket and then connect() on the socket object. ```APIDOC ## connect(host, port, family, socktype) ### Description Create a new socket and connect to a network address. ### Parameters * **host** (string) - Hostname or IP-Address (optional, default: localhost) * **port** (number|string) - Port or service description * **family** (string) - Address family ["any", "inet", "inet6"] (optional, default: "any") * **socktype** (string) - Socket Type ["stream", "dgram"] (optional, default: "stream") ### Usage: This functions calls getaddrinfo(), socket() and connect(). ### Return value: Socket Object ``` -------------------------------- ### nixio.openlog Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/nixio.html Opens a connection to the system logger. This is a POSIX-specific function. ```APIDOC ## nixio.openlog ### Description (POSIX) Open a connection to the system logger. ### Parameters - **ident** (string) - An identifier for the program. - **flag1** (string) - The first log option (e.g., "LOG_PID"). - **...** (string, optional) - Additional log options. ``` -------------------------------- ### mkdir(path, mode) Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/nixio.fs.html Creates a new directory with a specified mode. ```APIDOC ## mkdir(path, mode) ### Description Create a new directory. ### Parameters * path: The path for the new directory. * mode: The mode for the new directory. ``` -------------------------------- ### nice Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/nixio.html Adjusts the priority of the current process. ```APIDOC ## nice(nice) ### Description (POSIX) Change priority of current process. ### Parameters * nice: Nice Value ### Return value: true ``` -------------------------------- ### luci.dispatcher.template Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.dispatcher.html Create a template render dispatching target. ```APIDOC ## template ### Description Create a template render dispatching target. ### Parameters * name: The name of the template to render. ### Return value: None ``` -------------------------------- ### Cursor:section Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.model.uci.html Creates a new UCI section and initializes it with provided data. Returns the name of the created section. ```APIDOC ## Cursor:section ### Description Create a new section and initialize it with data. ### Parameters * `config`: UCI config * `type`: UCI section type * `name`: UCI section name (optional) * `values`: Table of key - value pairs to initialize the section with ### Return Value - String: Name of created section ``` -------------------------------- ### Cursor:get_first Source: https://github.com/openwrt/luci/blob/master/docs/api/modules/luci.model.uci.html Retrieves a specific option from the first section matching a given type in a UCI configuration. ```APIDOC ## Cursor:get_first ### Description Get the given option from the first section with the given type. ### Parameters * config: UCI config (string) * type: UCI section type (string) * option: UCI option (string, optional) * default: Default value (any, optional) ### Return value UCI value ``` -------------------------------- ### Referencing Static Assets in Templates Source: https://github.com/openwrt/luci/blob/master/doc_gen/tutorials/ThemesHowTo.md Demonstrates how to reference static assets like icons within LuCI templates using the `{{ media }}` variable. ```html ``` -------------------------------- ### Filesystem RPC Functions Source: https://github.com/openwrt/luci/wiki/JsonRpcHowTo The Filesystem library `/rpc/fs` allows interaction with the host machine's filesystem. It exposes most functions from the `luci.fs` library, with special handling for `readfile` and `writefile`. ```APIDOC ## Filesystem RPC API ### Description Provides access to the host machine's filesystem via RPC. ### Functions All functions from the `luci.fs` library are exported, with the following exceptions: - `readfile`: Encodes its return value in Base64. - `writefile`: Accepts only Base64 encoded data as the second argument. These functions are only available if the `luasocket` package is installed. ### Example Usage Refer to the complete `luci.fs` library documentation for specific function signatures and usage. ```