mirror of
https://github.com/home-assistant/operating-system.git
synced 2025-07-24 13:36:31 +00:00
Make logs persistent over reboot and cleanup (#61)
* Create hassos-persists-journald * Create hassos-persists-journald.service * Set ln & permission * Enable persists journald * Update hassos-persists-journald
This commit is contained in:
parent
7d4b424d2f
commit
11b1946cd7
@ -0,0 +1 @@
|
||||
/usr/lib/systemd/system/hassos-persists-journald.service
|
@ -0,0 +1,14 @@
|
||||
[Unit]
|
||||
Description=HassOS persists journald
|
||||
Requires=var-log-journal.mount
|
||||
After=sysinit.target systemd-journald.service
|
||||
RefuseManualStart=true
|
||||
RefuseManualStop=true
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/sbin/hassos-persists-journald
|
||||
RemainAfterExit=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
29
buildroot-external/rootfs-overlay/usr/sbin/hassos-persists-journald
Executable file
29
buildroot-external/rootfs-overlay/usr/sbin/hassos-persists-journald
Executable file
@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
MACHINE_ID=$(cat /etc/machine-id)
|
||||
CURRENT_LOGS=/var/log/journal/${MACHINE_ID}
|
||||
|
||||
# Cleanup
|
||||
if [ ! -d ${CURRENT_LOGS} ];
|
||||
rm -rf /var/log/journal/*
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Loop all logs folder and move
|
||||
for log_folder in /var/log/journal/*; do
|
||||
# Not a log folder
|
||||
if [ ! -d ${log_folder} ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# Current log folder
|
||||
if (echo ${log_folder} | grep ${MACHINE_ID}); then
|
||||
continue
|
||||
fi
|
||||
|
||||
mv ${log_folder}/* ${CURRENT_LOGS}/
|
||||
rm -rf ${log_folder}
|
||||
done
|
||||
|
||||
journalctl --vacuum-size=20M
|
Loading…
x
Reference in New Issue
Block a user