openwrt uci
UCI: Unified Configuration Interface 通用配置接口,主要用于集中控制openwrt的配置文件。
1、uci使用的配置文件一般放置在设备上的/etc/config目录下,包括一些兼容的应用,譬如snmp,保存在/etc/config/的配置文件是已经被重写后的文件。
并且这些配置文件被写在RAM,而不是flash中,因为它没有必要被写在不易失的内存中,并且他们会经常改变。
存在于/etc/config下面的文件,可以使用直接修改或者通过uci命令的方式,还有兼容的luci页面等来进行修改。配置文件被修改后,要想使配置生效,必须重启相应的进程。
2、uci配置文件的语法
uci配置文件包含了多个“config”段。
package 'example' config 'example' 'test'
option 'string' 'some value'
option 'boolean' '1'
list 'collection' 'first item'
list 'collection' 'second item'
- The
config 'example' 'test'statement defines the start of a section with the typeexampleand the nametest. There can also be so called anonymous sections with only a type, but no name identifier. The type is important for the processing programs to decide how to treat the enclosed options.
“example”和“test”定义了一个段,段的类型为example,名字为test。也有匿名段,即只有段类型(example),木有段名称(test).
- The
option 'string' 'some value'andoption 'boolean' '1'lines define simple values within the section. Note that there are no syntactical differences between text and boolean options. Per convention, boolean options may have one of the values '0', 'no', 'off', 'false' or 'disabled' to specify a false value or '1' , 'yes', 'on', 'true' or 'enabled' to specify a true value.
“string”和“some value”组成了一对值(value)。并且对于文本和布尔型没有明确的界限
- In the lines starting with a
listkeyword an option with multiple values is defined. Allliststatements that share the same name,collectionin our example, will be combined into a single list of values with the same order as in the configuration file.
关键字“list”定义了一个数组,共用一个数组名(例如本例中的 collection),
- The indentation of the
optionandliststatements is a convention to improve the readability of the configuration file but it's not syntactically required.
- If an option is absent and not required, the default value is assumed. If it is absent and required, it may trigger an error in the application or other unwanted behaviour.
- A way to disable a config section, that does not have a
enabledoption to be disabled, is renaming the config section identifier (or type, in this caseexample) to a value not recognized by the processes that uses those values. Normally adisabled_identifieras config section type/identifier is sufficient.
一种禁止section段的方法,就是重命名section段名(或者是类型type名),总之就是使使用这个配置文件的进程识别不出来。
It is important to know that UCI identifiers and config file names may contain only the characters a-z, 0-9 and _.
uci配置文件中使用的变量只支持a-z,0-9和下划线_.
3、使用命令行修改配置文件
对于匿名段,需要加@和取第一个[0]的符号才能够正常获取和修改值。
例如:
root@hbg:/# cat /etc/config/snmpd
config agent
option agentaddress UDP:161
利用查看命令你会查看到:
root@hbg:/# uci show snmpd
snmpd.@agent[0]=agent
snmpd.@agent[0].agentaddress=UDP:161
因此你要查看agent下的值时需要使用命令:
root@hbg:/# uci get snmpd.@agent[0].agentaddress
UDP:161
root@TVWS:/#
否则会报错:
root@hbg:/# uci get snmpd.agent.agentaddress
uci: Entry not found
root@TVWS:/
来源于: http://wiki.openwrt.org/doc/uci
openwrt uci的更多相关文章
- OpenWRT UCI命令实现无线中继
本文主要功能主要是利用OpenWRT系统uci命令实现无线中继,主要是利用uci程序修改/etc/congfig/目录下的配置文件.实现步骤如下主要分为以下几步: 1) 安装 relayd (opkg ...
- [openwrt] uci 的shell和lua接口
uci是openwrt上配置操作的接口,不管是自动化的shell脚本,还是使用luci来二次开发配置界面,都会用到这部分知识. uci提供了lua, shell, c接口,这里主要用到了前两种 she ...
- OpenWrt的UCI系统
http://wiki.openwrt.org/doc/uci UCI是Unified Configuration Interface的缩写,翻译成中文就是统一配置接口,用途就是为OpenWrt提供一 ...
- 【openwrt】再设置
https://wiki.openwrt.org/zh-cn/doc/uci/network https://wiki.openwrt.org/zh-cn/doc/uci/wireless https ...
- [Openwrt 项目开发笔记]:Samba服务&vsFTP服务(四)
[Openwrt项目开发笔记]系列文章传送门:http://www.cnblogs.com/double-win/p/3888399.html 正文: 在上一节中,我们讲述了如何在路由器上挂载U盘,以 ...
- configure.ac
# # Copyright (C) - Tobias Brunner # Copyright (C) - Andreas Steffen # Copyright (C) - Martin Willi ...
- openwrt开发笔记三:uci移植及API调用
1.uci编译安装.移植 安装依赖 libubox #安装cmake sudo apt-get install cmake #下载依赖库libubox git clone http://git.nbd ...
- OpenWrt wireless通过配置uci生效
[转载请注明出处:钱正柱 http://blog.csdn.net/qianguozheng/article/details/24412673] 配置无线 vi /etc/config/wireles ...
- OpenWrt中开启usb存储和samba服务
在从官网安装的WNDR3800 15.05.1版本OpenWrt中, 不带usb存储支持以及samba, 需要另外安装 1. 启用usb支持 USB Basic Support https://wik ...
随机推荐
- .net中读取xml文件中节点的所有属性信息
功能描述: 将数据以xml的格式记录成配置文件,需要获取配置文件中的数据时,则获取对应的配置文件,读取配置文件里对应节点的所有属性. 逻辑实现: 1.将数据配置好在xml文件中. 2.获取xml文件中 ...
- Java 语言的 XPath API
如果要告诉别人买一加仑牛奶,您会怎么说?"请去买一加仑牛奶回来" 还是 "从前门出去,向左转,走三个街区向右转,再走半个街区向右转进入商店.走向四号通道,沿通道走五米向左 ...
- 纯注解快速使用spring IOC容器
使用spring的ioc容器实现对bean的管理与基本的依赖注入是再经典的应用了.基础使用不在详述. 这里主要介绍下使用注解实现零配置的spring容器.我相信你也会更喜欢使用这种方式.Spring ...
- 纯CSS实现斜角
今天看了看腾讯的七周年时光轴,发现这个斜角的CSS,研究了半天提出下面代码可以直接实现斜角,不是CSS3哦,那个就太容易了 -webkit-transform:rotate(10deg); 倾斜度后再 ...
- cobaltstrike3.5使用记录
一.服务器搭建与连接(1)团队服务器上: sudo ./teamserver 服务器IP 连接密码 (VPS的话要写外网ip,并且可以进行端口映射,默认使用50050端口) 但是这个一关闭团队服务器也 ...
- WOT2016大数据技术峰会——千人技术盛宴
WOT2016大数据技术峰会是一场聚焦大数据领域最前沿的的技术及经验分享.2016年11月25-26日北京粤财JW万豪酒店如约而至,会议规模达到1000人! 由51CTO主办的千人技术盛宴--WOT2 ...
- hdu_5585_Less Time, More profit(二分+最大权闭合图)
题目链接:hdu_5585_Less Time, More profit 题意: 有n个工厂,每建一个工厂要花费vi,需要时间ti,然后有m个商店,每个商店需要在指定的k个工厂中进货,才能盈利,如果其 ...
- Maxmum subsequence sum problem
We have a lot of ways to solve the maximum subsequence sum problem, but different ways take differen ...
- Java 相关注意事项小结
程序是一系列有序指令的集合: Java主要用于开发两类程序: 1)桌面应用程序2)Internet应用程序1,Java程序:三步走,编写--编译--运行:2,使用记事本开发:1)以.java为后缀名保 ...
- WTL版本ACEdit控件,改写自MFC版,附带源码
自动完成是个很酷也很实用的功能,比如在浏览器地址栏输入几个字母,相关的记录就会在下拉框中陈列出来. 最近在做公司产品UI部分的改善,原版本是MFC做的,我决定用WTL,于是就遇到自动完成控件的问题.遍 ...