Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
docs:guide-developer:ubus:uci [2024/11/08 03:41] – Update to OpenWrt 23.05.5 ivan98docs:guide-developer:ubus:uci [2024/11/08 06:33] (current) – Minor updates ivan98
Line 29: Line 29:
 | ''uci'' | ''configs'' | ''{ }'' | <WRAP>List all available configs | ''uci'' | ''configs'' | ''{ }'' | <WRAP>List all available configs
  
-Return messages+Example
-  ''{ "configs": [ "config1", "config2", ... ] }''+<code> 
 +# ubus call uci configs '{"ubus_rpc_session":"2db687f321a60414e77677bbb5dd6d6f"}' 
 +{ 
 + "configs": [ 
 + "dhcp", 
 + "dropbear", 
 + "firewall", 
 + "luci", 
 + "network", 
 + "radius", 
 + "rpcd", 
 + "system", 
 + "ubootenv", 
 + "ucitrack", 
 + "uhttpd", 
 + "wireless" 
 + ] 
 +} 
 +</code>
 </WRAP> | </WRAP> |
 | ''uci'' | ''get'' | ''{ "config": "//config//", | ''uci'' | ''get'' | ''{ "config": "//config//",
Line 67: Line 85:
     - ''{ "//oname//": "value1" }''     - ''{ "//oname//": "value1" }''
     - ''{ "//oname//": [ "value1.1", ... ] }''     - ''{ "//oname//": [ "value1.1", ... ] }''
 +
 +Example:
 +<code>
 +# ubus call uci get '{"ubus_rpc_session":"2db687f321a60414e77677bbb5dd6d6f", "config":"wireless", "section":"wifinet2"}'
 +{
 + "values": {
 + ".anonymous": false,
 + ".type": "wifi-iface",
 + ".name": "wifinet2",
 + "device": "radio0",
 + "mode": "ap",
 + "ssid": "ilwf-guest",
 + "encryption": "sae-mixed",
 + "key": "XXXX",
 + "network": "lan",
 + "disabled": "0"
 + }
 +</code>
 </WRAP> | </WRAP> |
 | ''uci'' | ''state'' | ''{ "config": "//config//", | ''uci'' | ''state'' | ''{ "config": "//config//",
   "section": "//sname//",   "section": "//sname//",
-  "type":    "//type//",+  "type":    "//tname//",
   "option":  "//oname//" }'' | |s   "option":  "//oname//" }'' | |s
 | ''uci'' | ''set'' | ''{ "config": "//config//", | ''uci'' | ''set'' | ''{ "config": "//config//",
   "section": "//sname//",   "section": "//sname//",
-  "option":  "//oname//", +  "type":  "//tname//", 
-  "value":   "//value//" }'' | <WRAP>Set the given value(s), the option argument is optional. +  "values":   "//array_of_values//" }'' | <WRAP>Set the given value(s), the option argument is optional. 
-  - When called with ''//config//'' and ''//sname//'' and ''//value//'' set: add a new section ''//sname//'' in ''//config//'' and set it to the type given in ''//value//'' +  - When called with ''//config//'' and ''//sname//'' and ''//array_of_values//'' set: add a new section ''//sname//'' in ''//config//'' and set it to the type given in ''//tname//'' 
-  - When called with ''//config//'' and ''//sname//'', ''//oname//'' and ''//value//'' set+  - When called with ''//config//'' and ''//sname//'', ''//oname//'' and ''//array_of_values//'' set ''array_of_values'' as values in ''//sname//''
-    - If ''//value//'' is of type array: set strings in the ''value'' array as list option ''//oname//'' +
-    - If ''//value//'' is of type string: set ''//value//'' as normal option ''//oname//''+
 The call does not produce any data, instead it returns with the following status codes: The call does not produce any data, instead it returns with the following status codes:
   - If there already is a section called ''//sname//'': ''UBUS_STATUS_INVALID_ARGUMENT'' else: ''UBUS_STATUS_OK''   - If there already is a section called ''//sname//'': ''UBUS_STATUS_INVALID_ARGUMENT'' else: ''UBUS_STATUS_OK''
   - If there is no section ''//sname//'' or if ''//value//'' is neither a string nor an array: ''UBUS_STATUS_INVALID_ARGUMENT'' else: ''UBUS_STATUS_OK''   - If there is no section ''//sname//'' or if ''//value//'' is neither a string nor an array: ''UBUS_STATUS_INVALID_ARGUMENT'' else: ''UBUS_STATUS_OK''
 +
 +Example:
 +<code>
 +# ubus call uci set '{"ubus_rpc_session":"2db687f321a60414e77677bbb5dd6d6f", "config":"wireless", "section":"wifinet2", "values":{"disabled":"1"}}'
 +# ubus call uci get '{"ubus_rpc_session":"2db687f321a60414e77677bbb5dd6d6f", "config":"wireless", "section":"wifinet2"}'
 +{
 + "values": {
 + ".anonymous": false,
 + ".type": "wifi-iface",
 + ".name": "wifinet2",
 + "device": "radio0",
 + "mode": "ap",
 + "ssid": "ilwf-guest",
 + "encryption": "sae-mixed",
 + "key": "XXXXXXXX",
 + "network": "lan",
 + "disabled": "1"
 + }
 +}
 +</code>
 </WRAP> | </WRAP> |
 | ''uci'' | ''add'' | ''{ "config": "//config//", | ''uci'' | ''add'' | ''{ "config": "//config//",
  • Last modified: 2024/11/08 03:41
  • by ivan98