From 2ba8612f7fc91d2744703ecd4b515e5ca22e0d53 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 3 Apr 2023 20:35:55 +0200 Subject: [PATCH] src/confd: add commit_done_hook() to call initctl reload This is needed to confirm the new system configuration generation and reload all affected services. E.g., when configuring an NTP server and committing the candidate to running, the ietf-system plugin has only enabled the service, as a last step we need to tell Finit to actually start it. This hook needs to run last since the enabled service(s) may depend on other service(s), or networking, to be enabled in the proper order. Signed-off-by: Joachim Wiberg --- src/confd/src/core.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/confd/src/core.c b/src/confd/src/core.c index 48a7e30e..4337db88 100644 --- a/src/confd/src/core.c +++ b/src/confd/src/core.c @@ -13,6 +13,15 @@ static int startup_save_hook(sr_session_ctx_t *session, uint32_t sub_id, const c return SR_ERR_OK; } +static int commit_done_hook(sr_session_ctx_t *session, uint32_t sub_id, const char *module, + const char *xpath, sr_event_t event, unsigned request_id, void *priv) +{ + if (system("initctl -nbq reload")) + return SR_ERR_SYS; + + return SR_ERR_OK; +} + int sr_plugin_init_cb(sr_session_ctx_t *session, void **priv) { sr_session_ctx_t *startup; @@ -48,6 +57,12 @@ int sr_plugin_init_cb(sr_session_ctx_t *session, void **priv) goto err; } + if (rc = sr_module_change_subscribe(session, "ietf-system", "/ietf-system:system//.", + commit_done_hook, NULL, 0, SR_SUBSCR_PASSIVE | SR_SUBSCR_DONE_ONLY, &confd.sub)) { + ERROR("failed setting up startup-config hook: %s", sr_strerror(rc)); + goto err; + } + if (rc = sr_install_module(confd.conn, YANG_PATH_"kernelkit-infix-deviations.yang", NULL, NULL)) goto err;