Adding a file browser, file text editor and tty command shell for LuCI OpenWrt

What benefit do you gain having a file browser on a router?

All config a user would ever need can be done in Luci, including software installation and a normal user does not need to edit configuration files?

1 Like

That's based on the idea that a) every app that a user wants is available to configure in luci, or that b) if you want something that can't be configured in luci theb you are an abnormal user.

Those are arrogant assumption.

This is a great idea. I would also add to this list a regedit-like editor for uci. Even in areas that there is a luci front end for, there are often configuration options the front end doesn't expose. The luci interface almost always lags behind the back end development in virtually every area. I'm not criticizing that, it's just a fact. And a general purpose uci editor would allow access to all that without requiring shell expertise.

If the use case is editing config files ssh + pico or nano covers that need with no additional interfaces and is generally secure.

Also, all users should be using uci commands, not editing the files directly - uci has some level of protection from serious mistakes screwing up their config.

Of course anyone is welcome to submit packages they have written to the package repository, I just can’t see a use for this type of browser on a network device

web based tty makes using uci easier

Sometimes the user only knows about editing the file, even if that's not the most optimal way, that might be the best way to make it work right this second.

Direct web access to files and tty command right in the web interface that's one less road block gone to making things work right now and that's undoubtedly the way to go.

If I get dev time on openwrt, that's one of the thing that would make every openwrt user's life easier

What are your thoughts about how such general purpose uci editor would work?

If there is machine-readable metadata about how the uci configurations are allowed to be set, it should allredy be possible to comprehensively validate configuration files and create generic GUIs using the metadata as well as implementing text editor "intellisense"-like functionality and produce documentation. Does the OpenWrt base and individual packages provide such metadata or is the current uci totally ignorant about allowed settings and how settings should be connected to form a technically working configuration?

I think firefox's about:config could serve as a good blueprint for a raw config page

Biggest difference I see with uci is that uci can have multiple values for one config (array)

And a common problem with both firefox and uci is that it is not suggesting the user all the configs that could exist but only the ones that already exist. But solving that shouldn't get in the way of just giving the user a quick access to settings.

So, in order of complexity
a dump of uci show
sort/filter by config section (the text before the first ".", like attendedsysupgrade, ddns, dhcp, firewall, fstab, luci etc..)
show the user which configs are set to non-defaults
ability for the user to change any value
validate user input is the right data format
show/suggest user with unset but possible configs

No, there is not.


Go for it, sounds like it will be a huge package, but if you think you can make it work go ahead

This thread is initially about adding file browser, text editor and a console to openwrt's web interface.

Adding a uci configurator would be a nice to have, but already covered by having a functionnal console in the web interface.

And making this discussion about the metadata of the validator of the uci configurator of the web interface, sounds to me like a derailment.

But sure, I can answer that

So the metadata, it's in the wiki already, and it's really nicely formatted.
A simple trip to chatgpt and it can be turned into machine readable code.

Here for example the fstab config

Here is what it looks like out of uci


So anyway, the wiki data is already so clean we can somewhat easily turn it into machine readable metadata using a large language model like chatgpt

I did a few of the config.sections in this file

Tried to get chatgpt to spit out a script to read it but I just did my first lua hello world a few minutes ago and this doesn't work out of the box

local uci_metadata_file = "uci.metadata"

local function get_metadata(section, option, property)
    local metadata = {}
    for line in io.lines(uci_metadata_file) do
        local s = line:match("^%s*%[(.-)%]") -- section
        if s and s == section then
            local opt, optdata = line:match("^%s*(%S+)%s*=%s*(%b{})")
            if opt and opt == option then
                optdata = optdata:gsub("[{}%s\"]", ""):gsub(",", "\n")
                for k, v in optdata:gmatch("([%w_]+)%s*=%s*([^%s]+)") do
                    metadata[k] = v
    return metadata[property]

-- example usage
local section = arg[1]
local option = arg[2]
local property = arg[3]
local value = get_metadata(section, option, property)

but it's probably close to working

root@router:~# lua read.uci.metadata.lua dropbear.dropbear verbose description
Set to 1 to enable verbose output by the start script.

This metadata database would weight in at something like 250kb uncompressed

While opkg update downloads

     3 -rw-r--r--    1 root     root        3.4K Mar 24 19:55 Packages.gz
    88 -rw-r--r--    1 root     root       87.7K Jan  4 23:19 Packages.gz.1
    88 -rw-r--r--    1 root     root       87.7K Jan  4 23:19 Packages.gz.2
    61 -rw-r--r--    1 root     root       61.1K Mar 21 20:38 Packages.gz.3
   176 -rw-r--r--    1 root     root      176.0K Mar 21 20:38 Packages.gz.4
   453 -rw-r--r--    1 root     root      453.4K Mar 21 20:39 Packages.gz.5
    12 -rw-r--r--    1 root     root       12.0K Mar 21 20:40 Packages.gz.6
    57 -rw-r--r--    1 root     root       57.2K Mar 21 20:40 Packages.gz.7

So that's not something too crazy to download each time a user would use the uci configurator, which presumably would be far less often than how often a user runs opkg update.

And if there's enough free space on the device, you just leave it there

Have you had a chance to develop a package for this?

I created a PR with a minimal File Browser for Luci

Please leave your comments and thoughts.

Some other discussions for file browser:


Great news,

File manager is almost part of default openwrt

That's one almost down, two to go !


Please note that the PR is minimal and it's not that useful as you may think. There are no edit, no console etc. Just list files, delete, upload and download.

Everything else needs for a significant changes and this will be made on stage 2 later.

I find mc to be a good do it all.

We don't have any of those features right now. More than happy about it.

Mind, for the feature roadmap, I would love if it supported uploading and downloading more than one file at once (rather than, I assume, selecting upload and browsing for each file). Download is probably good enough, though, if I can just click a download button per file.

Both of those are probably doable with a for-loop in the JS that reads from a select-list of files (checked files in the viewer to download, multi-select in the upload box for uploading). I've done similar before but I don't have experience with the rest of the code that LuCI uses.

1 Like

The basic file manager luci-app-filebrowser was merged to Luci. It needs to be installed separately but I hope once it will become more mature and tested it will be added to Luci out of the box.
The File Browser is very generic and available only to admin users. E.g. it can't be used as a replacement for "shares" to manage documents and media. But, for example, you can upload a config file to /etc/config from a browser. So packages that doesn't have a Luci app yet can be configured without need to connect with SSH.

Later (in year or two) I'll try to improve it but actually if anyone can contribute you are welcome and I'll try to help you or at least review changes.


Awesome ! Can't wait to try it out, I think that's going to finally nudge me to upgrade to 23.05 !


Just updated to latest 23.05

Could you explain how to try luci-app-filebrowser on stable ?

Just ran opkg update but still it does not show up

Only snapshots.

There was changed two files in Luci core so it can't be backported to the already released versions.
But you can manually download the archive and replace files yourself