diff options
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-syncd | 38 |
1 files changed, 38 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..538c96875 --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-core/nv-sync/nv-sync/nv-syncd @@ -0,0 +1,38 @@ +#!/bin/bash + +NVMP=/tmp/.rwfs +SOMP=/var/sofs + +clean_var_volatile_tmp() { + rm -rf $NVMP/.overlay/var/volatile/tmp/* || : +} + +do_sync() { + rsync -a --delete --exclude='**/var/volatile/tmp/**' /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 + +clean_var_volatile_tmp + +# Run rsync periodically to sync the overlay to NV storage +while true; do + do_sync + sleep 10 +done |