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 type example and the name test. 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'  and  option '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 list keyword an option with multiple values is defined. All list statements that share the same name, collection in 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 option and list statements 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 enabled option to be disabled, is renaming the config section identifier (or type, in this case example) to a value not recognized by the processes that uses those values. Normally a disabled_identifier as 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-z0-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

转载于:https://www.cnblogs.com/rohens-hbg/p/5039324.html

openwrt uci相关推荐

  1. OpenWrt的UCI系统

    http://wiki.openwrt.org/doc/uci UCI是Unified Configuration Interface的缩写,翻译成中文就是统一配置接口,用途就是为OpenWrt提供一 ...

  2. openwrt - 入门( uHTTPd, opkg, uci, luci, mtd等)

    介紹 主頁: https://openwrt.org/ 目錄: 安裝 Download First Login UCI (Unified Configuration Interface) SSH(Dr ...

  3. 【智能路由器】openwrt工具uci使用指南

    [智能路由器]系列文章连接 http://blog.csdn.net/u012819339/article/category/5803489 uci(Unified Configuration Int ...

  4. [Openwrt 项目开发笔记]:Samba服务vsFTP服务(四)

    [Openwrt项目开发笔记]系列文章传送门:http://www.cnblogs.com/double-win/p/3888399.html 正文: 在上一节中,我们讲述了如何在路由器上挂载U盘,以 ...

  5. 一、我来说LuCI: LuCI官方----2.UCI

    中文总结: 1. UCI是基于NVRAM的系统配置工具: 2. UCI的语法格式, /etc/config: package 'example' config 'example' 'test'     ...

  6. 二、Luci中的UCI API的使用

    1.UCI 在openwrt中的各个应用程序和服务,都拥有自己的配置文件,但是每个应用程序的配置文件所在目录,都不是一定是一致的.所以为了能够更加方便的修改配置和解决配置不兼容过的问题. openwr ...

  7. OpenWrt入坑之路

    u盘启动盘制作 从官网下载combined-squashfs.img.gz镜像,为何不使用ext4镜像,因为squashfs镜像可以恢复,ext4改就改了,没有Overlay机制. 启动盘制作工具,使 ...

  8. PVE(Proxmox Virtual Environment)OpenWRT安装使用教程

    PVE安装教程 PVE(Proxmox Virtual Environment)安装配置 Proxmox Virtual Environment简介 Proxmox Virtual Environme ...

  9. openwrt--uci指令的使用

    UCI简介 UCI是集中式配置信息管理接口(Unified Configuration Interface)的缩写,他是OpenWrt引进的一套配置参数管理系统.UCI管理了OpenWrt下最主要的系 ...

最新文章

  1. 中国互联网+光通信器件行业商业模式创新与投资机会深度研究报告
  2. 使用apache的activemq集合JMS处理异步消息
  3. 玉米田Corn Fields
  4. Android Application中的Context和Activity中的Context的异同
  5. GraphQL学习过程应该是这样的
  6. mysql 查询优化器跟踪_3. select语句执行过程-优化器
  7. linux 管道使用方法,Linux 管道命令
  8. php绑定变量,php动态绑定变量的用法
  9. 【论文解读】百度提出新冠高风险小区预警算法,AAAI21收录!
  10. 思科网络基础课件_上海思科CCNA培训、思科网络工程师培训
  11. mysql记录当前表数据的数据条数据类型_mysql的表的操作 数据类型
  12. windows中端口号被占用的解决方法
  13. 【图论训练】最小拓扑序
  14. 信息系统项目管理师 pdf_关于系统集成项目管理工程师和信息系统项目管理师的区别...
  15. Autodesk Maya 2009标准培训教材
  16. selenium--下载与安装
  17. 计算机科学导论第一章练习解答
  18. HDU4585 Shaolin(treap)
  19. 从父组件中获取子组件的值
  20. 基于云服务创建弹性托管集群服务

热门文章

  1. Gitlab备份、升级、恢复
  2. ionic 幻灯指令 ion-slide-box
  3. 转载:Python正则表达式
  4. 通过VBA实现重复的PPT编辑操作
  5. XBMC Skinning Manual
  6. if语句使用说明(Java)
  7. c语言结构体实验报告加注释,C语言结构体实验报告.doc
  8. Android代码优化
  9. exploring spring
  10. Session的创建与销毁时机