unetd: cli: add unet_create/update/delete hook calls

Useful for upcoming cli modules that store created interfaces separately

Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
Felix Fietkau 2025-02-26 10:41:48 +01:00
parent 7c04fa0328
commit 2055b73ba4

View File

@ -153,6 +153,7 @@ function network_sign_data(ctx, name, network, pw_file, upload)
function network_create_uci(model, name, iface)
{
model.run_hook("unet_create", name, iface);
let cur = uci.cursor(null, null, "");
cur.set("network", name, "interface");
for (let key, val in iface)
@ -361,6 +362,7 @@ function network_create(ctx, argv, named) {
function network_delete(ctx, argv) {
let name = argv[0];
let cur = uci.cursor(null, null, "");
model.run_hook("unet_delete", name);
if (!cur.delete("network", name))
return ctx.command_failed("Command failed");
@ -378,6 +380,7 @@ function network_iface_save(ctx)
if (!netdata.iface_changed)
return;
model.run_hook("unet_update", network, netdata.iface);
let cur = uci.cursor(null, null, "");
let iface_orig = cur.get_all("network", network);
for (let name, val in netdata.iface) {