Skip to content

Commit

Permalink
Merge pull request #74 from hnez/flexible-rauc-migrate
Browse files Browse the repository at this point in the history
meta-lxatac-software: bundles: hook.sh: migrate user-specified files
  • Loading branch information
jluebbe authored Dec 12, 2023
2 parents 461ee86 + f2d7a30 commit ba3e18a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ bundle on your TAC:

If that does not work you may want to [re-install via USB](#installing-images-via-usb).

If you've made changes to your TACs configuration that you want to preserve,
which are not covered by the default update migration logic,
you can add a list of additional files to migrate to the
`/etc/rauc/migrate.d`:

root@lxatac-00010:~ cat /etc/rauc/migrate.d/git_config.conf
/etc/gitconfig
/home/root/.gitconfig

If that is not enough customization for you then read on to learn
how to build fully-custom images for your LXA TAC.

Building the image as-is
------------------------

Expand Down
23 changes: 23 additions & 0 deletions meta-lxatac-software/recipes-core/bundles/files/hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

set -exu -o pipefail

EXTRA_MIGRATE_LISTS_DIR="/etc/rauc/migrate.d"
CERT_AVAILABLE_DIR="${RAUC_SLOT_MOUNT_POINT}/etc/rauc/certificates-available"
CERT_ENABLED_DIR="${RAUC_SLOT_MOUNT_POINT}/etc/rauc/certificates-enabled"

Expand Down Expand Up @@ -44,6 +45,22 @@ function migrate () {
cp -a "$1" "${RAUC_SLOT_MOUNT_POINT}/$1"
}

function process_migrate_lists () {
if [ ! -d "${EXTRA_MIGRATE_LISTS_DIR}" ]; then
return
fi

for migrate_list in "${EXTRA_MIGRATE_LISTS_DIR}"/*.conf; do
# Migrate files in the list line by line
while read -r line; do
migrate "${line}"
done < "${migrate_list}"

# Also migrate the list itself
migrate "${migrate_list}"
done
}

case "$1" in
slot-post-install)
enable_certificates
Expand All @@ -63,6 +80,12 @@ case "$1" in
migrate /home/root/.bash_history
migrate /home/root/.ssh/authorized_keys
migrate /var/cache/lxa-iobus/lss-cache

# Also allow the running system to specify additional files to
# migrate to the new slot via files in /etc/rauc/migrate.d.
# The files should contain one file per line that should be
# migrated to the new slot.
process_migrate_lists
;;
*)
exit 1
Expand Down

0 comments on commit ba3e18a

Please sign in to comment.