balena-supervisor/build-utils/setup-journal.sh
Felipe Lalanne 91b119cbae Stop using host journalctl
The supervisor had to chroot into the host root in order to read the
journal logs. This won't be possible anymore once the supervisor becomes
an app. This commit copies the journalctl binary and necessary libraries
from a debian image into the supervisor image in order to be able to use
the tool on runtime.

Change-type: patch
2022-12-05 17:09:20 -03:00

13 lines
305 B
Bash
Executable File

#!/bin/sh
set -e
mkdir -p /sysroot/bin
cp /bin/journalctl /sysroot/bin/
# Get all library dependencies from the binary
for lib in $(ldd /bin/journalctl | grep -oE '(\/.+?) '); do
mkdir -p "/sysroot/$(dirname "$lib")"
# Copy the dependency dereferencing any symlinks
cp -L "$lib" "/sysroot/$lib"
done