mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-31 04:53:01 +02:00
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 <troglobit@gmail.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user