标签:
UCI文件语法UCI配置文件由一个或多个config语句组成,每一个config语句伴随着一个或多个option语句。这样的由一个config语句以及伴随的几个option语句组成的段落就叫做一个section。
UCI文件语法举例:
config 'section-type' 'section' option 'key' 'value' list 'list_key' 'list_value' config 'example' 'test' option 'string' 'some value' option 'boolean' '1' list 'collection' 'first item' list 'collection' 'second item'config 节点 以关键字 config 开始的一行用来代表当前节点
section-type 节点类型 section 节点名称config 节点语法格式
config 'section-type' 'section'config 节点原则
UCI 允许只有节点类型的匿名节点存在 节点类型和名字建议使用单引号包含以免引起歧义 节点中可以包含多个 option 选项或 list 列表选项。 节点遇到文件结束或遇到下一个节点代表完成。
key 键 value 值option 选项语法格式
option 'key' 'value'option 选项原则
选项的键与值建议使用单引号包含 避免相同的选项键存在于同一个节点,否则只有一个生效
list_key 列表键 list_value 列表值list 列表选项语法格式
list 'list_key' 'list_value'list 列表选项原则
选项的键与值建议使用单引号包含 列表键的名字如果相同,则相同键的值将会被当作数组传递给相应软件
uci [<options>] <command> [<arguments>]参数说明:
Commands: batch export [<config>] import [<config>] changes [<config>] commit [<config>] add <config> <section-type> add_list <config>.<section>.<option>=<string> del_list <config>.<section>.<option>=<string> show [<config>[.<section>[.<option>]]] get <config>.<section>[.<option>] set <config>.<section>[.<option>]=<value> delete <config>[.<section>[[.<option>][=<id>]]] rename <config>.<section>[.<option>]=<name> revert <config>[.<section>[.<option>]] reorder <config>.<section>=<position> Options: -c <path> set the search path for config files (default: /etc/config) -d <str> set the delimiter for list values in uci show -f <file> use <file> as input instead of stdin -m when importing, merge data into an existing package -n name unnamed sections on export (default) -N don't name unnamed sections -p <path> add a search path for config change files -P <path> add a search path for config change files and use as default -q quiet mode (don't print error messages) -s force strict mode (stop on parser errors, default) -S disable strict mode -X do not use extended syntax on 'show'
示例:
设置lan的ip
uci set network.lan.ipaddr=[lan ip]设置pppoe用户
uci set network.wan.proto=pppoe //设置wan口类型为pppoe uci set network.wan.username=[上网帐户] uci set network.wan.password=[上网密码] //这两行设置pppoe用户名和密码设置挂载上级路由
uci set network.wan.proto=none //关掉wan uci set network.lan.gateway=[上级路由ip] //网关指向上级路由 uci set network.lan.dns=[上级路由ip] //dns指向上级路由 uci set dhcp.lan.ignore=1 //关掉lan的dhcp设置无线
uci set wireless.@wifi-device[0].disabled=0 //打开无线 uci set wireless.@wifi-device[0].txpower=17 //设置功率为17dbm 太高会烧无线模块 uci set wireless.@wifi-device[0].channel=6 //设置无线信道为6 uci set wireless.@wifi-iface[0].mode=ap //设置无线模式为ap uci set wireless.@wifi-iface[0].ssid=[自己设置SSID] //设置无线SSID uci set wireless.@wifi-iface[0].network=lan //无线链接到lan上 uci set wireless.@wifi-iface[0].encryption=psk2 //设置加密为WPA2-PSK uci set wireless.@wifi-iface[0].key=[密码] //设置无线密码应用配置
uci commit //应用 /etc/init.d/network restart //重启网络服务
标签:
原文地址:http://blog.csdn.net/u011641885/article/details/46549181