Skip to content

Deleting array-like openwrt uci config sections #738

@Shados

Description

@Shados

# HACK: there seem no better way to clear out a list

If you rely solely on uci batch commands, it's not possible to do. If you make use of some form of on-device scripting, it's trivial, and this is what both OpenWRT's documentation and scripts do currently. For example, deleting all existing network devices with ash:

while uci -q del network.@device[-1] 2>/dev/null; do :; done

There shouldn't really be much of an issue interspersing uci batch commands and segments of shell script; so long as you don't uci commit the changes until everything is done, any failure in the script won't be persisted and could be trivially reverted.

As a possibly more interesting alternative, ucode is now on every OpenWRT image from 22.03 and on, so you could directly ship the uci.json onto the router, along with a ucode script to parse & act on it directly on the target.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions