diff options
author | John Crispin <blogic@openwrt.org> | 2015-08-21 07:45:44 +0200 |
---|---|---|
committer | John Crispin <blogic@openwrt.org> | 2015-08-25 23:56:32 +0200 |
commit | f00890cd6eb47ad9bb5da0fb6c50aedc8406e7c5 (patch) | |
tree | 20b43ef9d71410b769a42a741691d20f01c6e28b | |
parent | 032346f479a53683139a52baeb30b7399bc6df5e (diff) | |
download | rpcd-f00890cd6eb47ad9bb5da0fb6c50aedc8406e7c5.tar.gz |
add a reload_config method to the uci object
Signed-off-by: John Crispin <blogic@openwrt.org>
-rw-r--r-- | uci.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -23,6 +23,7 @@ #include <libubox/blobmsg_json.h> #include <rpcd/uci.h> +#include <rpcd/exec.h> #include <rpcd/session.h> static struct blob_buf buf; @@ -1490,6 +1491,21 @@ rpc_uci_rollback(struct ubus_context *ctx, struct ubus_object *obj, return 0; } +static int +rpc_uci_reload(struct ubus_context *ctx, struct ubus_object *obj, + struct ubus_request_data *req, const char *method, + struct blob_attr *msg) +{ + char * const cmd[2] = { "/sbin/reload_config", NULL }; + + if (!fork()) { + /* wait for the RPC call to complete */ + sleep(2); + return execv(cmd[0], cmd); + } + + return 0; +} /* * Session destroy callback to purge associated delta directory. @@ -1538,6 +1554,7 @@ int rpc_uci_api_init(struct ubus_context *ctx) UBUS_METHOD("apply", rpc_uci_apply, rpc_uci_apply_policy), UBUS_METHOD("confirm", rpc_uci_confirm, rpc_uci_rollback_policy), UBUS_METHOD("rollback", rpc_uci_rollback, rpc_uci_rollback_policy), + UBUS_METHOD_NOARG("reload_config", rpc_uci_reload), }; static struct ubus_object_type uci_type = |