mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-01-18 02:40:03 +00:00
Fix journalctl to work with persistent logs
v14.4.5 introduced a new way to retrieve the host logs by symlinking the log directories into the host /run/log/journal and using a local copy of the journalctl binary instead of chrooting into the host. This failed to account for the location of persistent logs when that option is turned on (/var/log/journal instead of /run/log/journal). This fixes the checks consider this case and also makes sure to remove the original symlink to avoid having nested links `/run/log/journal/journal/journal`, which was a bug in the previous implementation. Change-type: patch
This commit is contained in:
parent
ac3812aa9f
commit
55594274f7
17
entry.sh
17
entry.sh
@ -30,10 +30,23 @@ fi
|
||||
# NOTE: this won't be necessary once the supervisor can update
|
||||
# itself, as using the label io.balena.features.journal-logs will
|
||||
# achieve the same objective
|
||||
if [ -d /mnt/root/run/log/journal ]; then
|
||||
if { [ ! -d /run/log/journal ] || [ -L /run/log/journal ]; } && [ -s /mnt/root/etc/machine-id ]; then
|
||||
# Only enter here if the directory does not exist or the location exists and is a symlink
|
||||
# (note that test -d /symlink-to-dir will return true)
|
||||
|
||||
# Create the directory
|
||||
mkdir -p /run/log
|
||||
ln -sf /mnt/root/run/log/journal /run/log/journal
|
||||
|
||||
# Override the local machine-id
|
||||
ln -sf /mnt/root/etc/machine-id /etc/machine-id
|
||||
|
||||
# Remove the original link if it exists to avoid creating deep links
|
||||
[ -L /run/log/journal ] && rm /run/log/journal
|
||||
|
||||
# If using persistent logging, the host will the journal under `/var/log/journal`
|
||||
# otherwise it will have it under /run/log/journal
|
||||
[ -d "/mnt/root/run/log/journal/$(cat /etc/machine-id)" ] && ln -sf /mnt/root/run/log/journal /run/log/journal
|
||||
[ -d "/mnt/root/var/log/journal/$(cat /etc/machine-id)" ] && ln -sf /mnt/root/var/log/journal /run/log/journal
|
||||
fi
|
||||
|
||||
# Mount the host kernel module path onto the expected location
|
||||
|
Loading…
Reference in New Issue
Block a user