Hi there, is there any tool or any hack to export a part or the full config of a OpenWRT/LEDE BOX to a flat .CSV file ?
It will be great and usefull to have the hostnames, dhcps, networks, firewalls, being usable externally and also synchronized to a enduser usable access.
Hope this is not a bad request, and sure if this tool do not exist it will be a great stuff to have.
Thanks hnyman, great to know the export full or part command line.
But no way to get it as a .CSV, or .PDF format, like for adding into a documentation or to create images ?
It is plain text output
just output to a file uci export > /tmp/uci_export.txt
then use a text to pdf conveter after you copy it to your pc ( or just cut and paste)
You could also just use your favourite word-processor and save as pdf
Thanks mbo2o, again I have to explain that I may have being incomplete in my first question.
I have seing the export in text file, but I want to reformat into a external way.
Like a csv, format where columns and rows are all in one topic way.
The UCI format is a one line way format.
Topic, parameter(s)...
Topic.subtopic, parameter(s)
I search a manner to get all in this format; columns titles, then lines of parameters...
Topic, subtopic, subtopic2...
parameter(s) of topic, parameter(s) of subtopic, ...
Then anyone can get the UCI from config files to a calc (csv) way, and then reformat it in image(s), and publish it (pdf)...
I am in search of a tool that can make a visualisation of the parameters, for documentations, tutorials, or magazine articles, of the UCI configs.
Hope I explain better my need, but thanks to get in the topic, anyway...
Can you make a quick mock example of the CSV output you would like to see? I am sure the uci values can be easily formatted in your desired target format with a little bit of Lua or shell scripting.
This is a small piece from the flat format (UCI)
dhcp.@host[0]=host
dhcp.@host[0].name='BREL'
dhcp.@host[0].dns='1'
dhcp.@host[0].mac='00:04:20:17:D9:FA'
dhcp.@host[0].ip='10.3.2.101'
dhcp.@host[1]=host
dhcp.@host[1].name='BRASSENS'
dhcp.@host[1].dns='1'
dhcp.@host[1].mac='00:04:20:1B:B0:A9'
dhcp.@host[1].ip='10.3.2.104'
UCI is a tree format with hashes and arrays, and it doesn't lend itself well to CSV. For instance, how does these keys fit into your example?
dhcp.lan=dhcp
dhcp.lan.interface='lan'
dhcp.wan.ignore='1'
I think you would need hundreds of columns, and most rows would only contain one or a few values, or the data in the rows would not be connected. It would not be a good way to explain them.
like this;
dhcp.lan;dhcp.lan.interface;dhcp.wan.ignore
dhcp;'lan';'1'
dhcp.lan
dhcp.lan.interface
dhcp.wan.ignore
dhcp
'lan'
'1'
Not if all the same types is grouped by number, like, for dhcp, where a value [##] is grouped into the same colums, then the rows takes the each values of the options
There is a particularly large number of array based values in dhcp, so it gives a false impression of how useful your system is. Arrays aren't used at all in for instance Adblock, so you will just get a header line and a single data line with 164 columns. Making a special case for arrays is also a bit of a hack, and the code for encoding and decoding it wouldn't be very nice. I actually thought about writing it just to prove my point, but it's too messy and not very useful. Sorry.
While CSV is a common interchange format for spreadsheets, I don't know that it can represent hierarchical data in a reasonable way. As @per has noted, there are very few flat "arrays" in a typical configuration. Pretty much everything is going to require its own "special" table, making readability and parsability poor, in my opinion.
If you're looking for a good way to communicate the configuration, the configuration files themselves are well suited for that, especially as that is what drives the run-time configuration.
If you're looking for an interchange format to convert between various renderings, something that represents hierarchical data would be much more appropriate than CSV. JSON is one example of such a format, as would be XML.
You'are both right, but what I need in the first is only the DHCP and hosts lists, like in the luci web app, but in a printable way...
Because the luci web app do not show the all information in a browser, and because they are not copy/pastable...
You may export to json and then convert with jshn/jsonfilter tools. Export to JSON can be made via ubus call to uci service e.g. to get all zones from /etc/config/firewall: