diff --git a/package/sysrepo-plugin-system/sysrepo-plugin-system.mk b/package/sysrepo-plugin-system/sysrepo-plugin-system.mk index 5bd299549..044413b14 100644 --- a/package/sysrepo-plugin-system/sysrepo-plugin-system.mk +++ b/package/sysrepo-plugin-system/sysrepo-plugin-system.mk @@ -22,6 +22,8 @@ define SYSREPO_PLUGIN_SYSTEM_INSTALL_YANG_MODELS $(TARGET_DIR)/usr/share/yang/modules/sysrepo-plugin-system/iana-crypt-hash@2014-08-06.yang $(INSTALL) -D -m 0644 $(@D)/yang/ietf-system@2014-08-06.yang \ $(TARGET_DIR)/usr/share/yang/modules/sysrepo-plugin-system/ietf-system@2014-08-06.yang + $(INSTALL) -D -m 0644 $(@D)/yang/infix-system@2014-08-06.yang \ + $(TARGET_DIR)/usr/share/yang/modules/sysrepo-plugin-system/infix-system@2014-08-06.yang endef SYSREPO_PLUGIN_SYSTEM_POST_INSTALL_TARGET_HOOKS += SYSREPO_PLUGIN_SYSTEM_INSTALL_YANG_MODELS diff --git a/src/confd/src/ietf-system.c b/src/confd/src/ietf-system.c index 520601413..995bdb3fd 100644 --- a/src/confd/src/ietf-system.c +++ b/src/confd/src/ietf-system.c @@ -659,6 +659,33 @@ static int change_dns(sr_session_ctx_t *session, uint32_t sub_id, const char *mo return rc; } +static int change_motd(sr_session_ctx_t *session, uint32_t sub_id, const char *module, + const char *xpath, sr_event_t event, unsigned request_id, void *priv) +{ + char *nm; + FILE *fp; + + /* Ignore all events except SR_EV_DONE */ + if (event != SR_EV_DONE) + return SR_ERR_OK; + + fp = fopen("/etc/motd", "w"); + if (!fp) + return SR_ERR_SYS; + + nm = sr_get_str(session, xpath); + if (nm) { + fprintf(fp, "%s\n", nm); + } else { + /* XXX: derive from global "options.h" or /usr/share/factory/ */ + fprintf(fp, "\033[1;90mNote:\033[0m "); + fprintf(fp, "\033[0;90m use help, show, and setup commands to set up and diagnose the system\033[0m\n"); + } + fclose(fp); + + return SR_ERR_OK; +} + static int change_hostname(sr_session_ctx_t *session, uint32_t sub_id, const char *module, const char *xpath, sr_event_t event, unsigned request_id, void *priv) { @@ -752,6 +779,9 @@ int ietf_system_init(struct confd *confd) if (rc = sr_install_module(confd->conn, YANG_PATH_"ietf-system@2014-08-06.yang", NULL, features)) goto err; + /* Augment to ietf-systems */ + if (rc = sr_install_module(confd->conn, YANG_PATH_"infix-system@2014-08-06.yang", NULL, NULL)) + goto err; rc = sr_oper_get_subscribe(confd->session, "ietf-system", CLOCK_PATH_, clock_cb, NULL, SR_SUBSCR_DEFAULT, &confd->sub); @@ -764,6 +794,7 @@ int ietf_system_init(struct confd *confd) goto err; REGISTER_CHANGE(confd->session, "ietf-system", "/ietf-system:system/hostname", 0, change_hostname, confd, &confd->sub); + REGISTER_CHANGE(confd->session, "ietf-system", "/ietf-system:system/infix-system:motd", 0, change_motd, confd, &confd->sub); REGISTER_CHANGE(confd->session, "ietf-system", "/ietf-system:system/clock", 0, change_clock, confd, &confd->sub); REGISTER_CHANGE(confd->session, "ietf-system", "/ietf-system:system/ntp", 0, change_ntp, confd, &confd->sub); REGISTER_CHANGE(confd->session, "ietf-system", "/ietf-system:system/dns-resolver", 0, change_dns, confd, &confd->sub); diff --git a/src/confd/yang/infix-system@2014-08-06.yang b/src/confd/yang/infix-system@2014-08-06.yang new file mode 100644 index 000000000..3034613bc --- /dev/null +++ b/src/confd/yang/infix-system@2014-08-06.yang @@ -0,0 +1,20 @@ +module infix-system { + prefix "infix-sys"; + yang-version 1.1; + namespace "urn:infix:params:xml:ns:yang:infix-system"; + + import ietf-system { + prefix "sys"; + } + + revision 2014-08-06 { + description "Initial revision."; + } + + augment "/sys:system" { + leaf motd { + type string; + description "Set the MotD (Message of the Day), which is shown after login"; + } + } +}