diff options
Diffstat (limited to 'meta-openbmc-mods/meta-common/recipes-core/nv-sync')
3 files changed, 39 insertions, 4 deletions
diff --git a/meta-openbmc-mods/meta-common/recipes-core/nv-sync/nv-sync/nv-sync.service b/meta-openbmc-mods/meta-common/recipes-core/nv-sync/nv-sync/nv-sync.service index bad3329d3..4595541c6 100644 --- a/meta-openbmc-mods/meta-common/recipes-core/nv-sync/nv-sync/nv-sync.service +++ b/meta-openbmc-mods/meta-common/recipes-core/nv-sync/nv-sync/nv-sync.service @@ -2,10 +2,8 @@ Description=Overlay sync to NV storage [Service] -# Run rsync periodically to sync the overlay to NV storage -ExecStart=bash -c 'while true; do rsync -a --delete /tmp/.overlay/ /tmp/.rwfs/.overlay; sync /tmp/.rwfs/.overlay; sleep 10; done' -# On shutdown, archive the bash history so we don't lose it and run one last sync -ExecStop=bash -c 'history -a; rsync -a --delete /tmp/.overlay/ /tmp/.rwfs/.overlay; sync /tmp/.rwfs/.overlay; sleep 5' +# Run a job to periodically sync the overlay to NV storage +ExecStart=/usr/bin/nv-syncd # Due to sync delay stopping this service will take more than default 10 seconds TimeoutStopSec=20 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 diff --git a/meta-openbmc-mods/meta-common/recipes-core/nv-sync/nv-sync_git.bb b/meta-openbmc-mods/meta-common/recipes-core/nv-sync/nv-sync_git.bb index 0ee70e880..420fc258b 100644 --- a/meta-openbmc-mods/meta-common/recipes-core/nv-sync/nv-sync_git.bb +++ b/meta-openbmc-mods/meta-common/recipes-core/nv-sync/nv-sync_git.bb @@ -3,6 +3,7 @@ DESCRIPTION = "Script to periodically sync the overlay to NV storage" S = "${WORKDIR}" SRC_URI = "file://nv-sync.service \ + file://nv-syncd \ " LICENSE = "Apache-2.0" @@ -10,11 +11,15 @@ LIC_FILES_CHKSUM = "file://${INTELBASE}/COPYING.apache-2.0;md5=34400b68072d710fe inherit systemd +RDEPENDS_${PN} += "bash" + FILES_${PN} += "${systemd_system_unitdir}/nv-sync.service" do_install() { install -d ${D}${systemd_system_unitdir} install -m 0644 ${WORKDIR}/nv-sync.service ${D}${systemd_system_unitdir} + install -d ${D}${bindir} + install -m 0755 ${WORKDIR}/nv-syncd ${D}${bindir}/nv-syncd } SYSTEMD_SERVICE_${PN} += " nv-sync.service" |