Make machine-id persist (#649)
* Make machine-id persist * update * Adjustments * cleanup * fix cleanups * small cleanup
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
[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/libexec/hassos-persists-journald
|
||||
RemainAfterExit=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=HassOS persists data on bootstate
|
||||
After=sysinit.target
|
||||
RefuseManualStart=true
|
||||
RefuseManualStop=true
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/libexec/hassos-persists
|
||||
RemainAfterExit=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,11 +1,11 @@
|
||||
[Unit]
|
||||
Description=Systemd persistent logging
|
||||
Requires=mnt-overlay.mount
|
||||
After=mnt-overlay.mount
|
||||
Requires=mnt-data.mount
|
||||
After=mnt-data.mount
|
||||
Before=systemd-journal-flush.service
|
||||
|
||||
[Mount]
|
||||
What=/mnt/overlay/var/log/journal
|
||||
What=/mnt/data/logs
|
||||
Where=/var/log/journal
|
||||
Type=None
|
||||
Options=bind
|
||||
|
||||
30
buildroot-external/rootfs-overlay/usr/libexec/hassos-persists
Executable file
30
buildroot-external/rootfs-overlay/usr/libexec/hassos-persists
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
MACHINE_ID=$(cat /etc/machine-id)
|
||||
|
||||
###
|
||||
# u-boot
|
||||
if [ -e /usr/sbin/fw_setenv ]; then
|
||||
|
||||
# machine-id
|
||||
if [ "$(fw_printenv -n MACHINE_ID)" != "${MACHINE_ID}" ]; then
|
||||
echo "[info] set machine-id to ${MACHINE_ID}"
|
||||
fw_setenv MACHINE_ID "${MACHINE_ID}"
|
||||
else
|
||||
echo "[info] machine-id is okay"
|
||||
fi
|
||||
|
||||
###
|
||||
# Barebox
|
||||
else
|
||||
|
||||
# machine-id
|
||||
if [ "$(barebox-state -g state.machine_id -i /etc/barebox-state.dtb)" != "${MACHINE_ID}" ]; then
|
||||
echo "[info] set machine-id to ${MACHINE_ID}"
|
||||
barebox-state -s "state.machine_id=${MACHINE_ID}" -i /etc/barebox-state.dtb
|
||||
else
|
||||
echo "[info] machine-id is okay"
|
||||
fi
|
||||
|
||||
fi
|
||||
@@ -1,19 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
MACHINE_ID=$(cat /etc/machine-id)
|
||||
|
||||
# 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
|
||||
|
||||
rm -rf "${log_folder}"
|
||||
done
|
||||
Reference in New Issue
Block a user