xref: /openbmc/phosphor-bmc-code-mgmt/bmc/sync-once.sh (revision 7fe19f4d2aa5c31facca05c580ad984885258195)
1#!/bin/bash
2
3# Sync the files/dirs specified in synclist once
4# Usually the sync-manager could sync the file once before it starts, so that
5# it makes sure the synclist is always synced when the sync-manager is running.
6
7SYNCLIST=/etc/synclist
8DEST_DIR=/run/media/rwfs-alt/cow
9
10while read -r l; do
11
12    # if the sync entry is not present in the source, remove it from the destination
13    if [ -n "${l}" ] && [ ! -e "${l}" ] && [ -e "${DEST_DIR}/${l}" ]; then
14        echo "Removing ${DEST_DIR}/${l}"
15        rm -rf "${DEST_DIR:?}/${l:?}"
16        continue
17    fi
18
19    echo rsync -a -R --delete "${l}" "${DEST_DIR}"
20    rsync -a -R --delete "${l}" "${DEST_DIR}"
21done < ${SYNCLIST}
22