summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-core/nv-sync/nv-sync/nv-syncd
diff options
context:
space:
mode:
Diffstat (limited to 'meta-openbmc-mods/meta-common/recipes-core/nv-sync/nv-sync/nv-syncd')
-rw-r--r--meta-openbmc-mods/meta-common/recipes-core/nv-sync/nv-sync/nv-syncd32
1 files changed, 32 insertions, 0 deletions
diff --git a/meta-openbmc-mods/meta-common/recipes-core/nv-sync/nv-sync/nv-syncd b/meta-openbmc-mods/meta-common/recipes-core/nv-sync/nv-sync/nv-syncd
new file mode 100644
index 000000000..e2bb4bb0c
--- /dev/null
+++ b/meta-openbmc-mods/meta-common/recipes-core/nv-sync/nv-sync/nv-syncd
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+NVMP=/tmp/.rwfs
+SOMP=/var/sofs
+
+do_sync() {
+ rsync -a --delete /tmp/.overlay/ $NVMP/.overlay
+ sync $NVMP/.overlay
+}
+
+stop_nv() {
+ history -a
+ do_sync
+ mount -o remount,ro $NVMP
+ mount -o remount,ro $SOMP
+ exit 0
+}
+
+# register cleanup function
+trap stop_nv SIGINT
+trap stop_nv SIGTERM
+trap stop_nv EXIT
+
+# make sure the mount points are RW
+mount -o remount,rw $NVMP
+mount -o remount,rw $SOMP
+
+# Run rsync periodically to sync the overlay to NV storage
+while true; do
+ do_sync
+ sleep 10
+done