Save persistent DSes to /cfg upon each change

This is pretty crude -- whenever an "interesting" file in our overlay
/etc/sysrepo/data gets changed, ensure that we store it in the
non-volatile /cfg partition as well.

Change-Id: Ie6165564a03bf49a51e3475d61d77e3a0374632c
diff --git a/board/czechlight/common/overlay/usr/lib/systemd/system/multi-user.target.wants/sysrepo-persistent-cfg.service b/board/czechlight/common/overlay/usr/lib/systemd/system/multi-user.target.wants/sysrepo-persistent-cfg.service
new file mode 120000
index 0000000..810aa4b
--- /dev/null
+++ b/board/czechlight/common/overlay/usr/lib/systemd/system/multi-user.target.wants/sysrepo-persistent-cfg.service
@@ -0,0 +1 @@
+../sysrepo-persistent-cfg.service
\ No newline at end of file
diff --git a/board/czechlight/common/overlay/usr/lib/systemd/system/sysrepo-persistent-cfg.service b/board/czechlight/common/overlay/usr/lib/systemd/system/sysrepo-persistent-cfg.service
new file mode 100644
index 0000000..fcb1d7e
--- /dev/null
+++ b/board/czechlight/common/overlay/usr/lib/systemd/system/sysrepo-persistent-cfg.service
@@ -0,0 +1,8 @@
+[Unit]
+Description=Persisting persistent sysrepo datastores to /cfg
+After=sysrepod.service
+Requires=cfg.mount
+
+[Service]
+Type=simple
+ExecStart=/bin/sh -c 'while true; do inotifywait -e CLOSE_WRITE /etc/sysrepo/data/*.startup && mkdir -p /cfg/etc/sysrepo/data/ && cp -a /etc/sysrepo/data/*.startup /cfg/etc/sysrepo/data/; done'
diff --git a/configs/czechlight_clearfog_defconfig b/configs/czechlight_clearfog_defconfig
index fce8742..e9182c9 100644
--- a/configs/czechlight_clearfog_defconfig
+++ b/configs/czechlight_clearfog_defconfig
@@ -31,6 +31,7 @@
 BR2_PACKAGE_UBOOT_TOOLS=y
 BR2_PACKAGE_OPENSSH=y
 BR2_PACKAGE_BASH=y
+BR2_PACKAGE_INOTIFY_TOOLS=y
 BR2_PACKAGE_RAUC=y
 BR2_PACKAGE_RAUC_NETWORK=y
 # BR2_PACKAGE_SYSTEMD_HWDB is not set