mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-01-31 16:35:23 +00:00
Merge pull request #2081 from balena-os/journalctl-persistent-logs
Fix journalctl to work with persistent logs
This commit is contained in:
commit
f155672540
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…
x
Reference in New Issue
Block a user