From 2d3119ef22015a06cb2db6265a0210732f185df9 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Wed, 12 May 2021 17:47:42 +0200 Subject: [PATCH] Delay Supervisor start until time has been sychronized (#1360) * Enable systemd-time-wait-sync.service by default Enable the systemd-time-wait-sync.service by default. This allows to use the time-sync.target which allows to make sure services only get started once the time is synchronized. * Make sure time is synchronized when starting hassos-supervisor.service Use the time-sync.target to make sure that the Supervisor gets stsarted after the time has been synchronized. * Set timeout for systemd-time-wait-sync.service Don't delay startup forever in case time synchronization doesn't work. This allows to boot the system even without Internet connection. --- .../system/systemd-time-wait-sync.service.d/timeout.conf | 2 ++ .../usr/lib/systemd/system-preset/70-haos.preset | 2 ++ .../usr/lib/systemd/system/hassos-supervisor.service | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 buildroot-external/rootfs-overlay/etc/systemd/system/systemd-time-wait-sync.service.d/timeout.conf diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/systemd-time-wait-sync.service.d/timeout.conf b/buildroot-external/rootfs-overlay/etc/systemd/system/systemd-time-wait-sync.service.d/timeout.conf new file mode 100644 index 000000000..e367cf862 --- /dev/null +++ b/buildroot-external/rootfs-overlay/etc/systemd/system/systemd-time-wait-sync.service.d/timeout.conf @@ -0,0 +1,2 @@ +[Service] +TimeoutStartSec=90s diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/system-preset/70-haos.preset b/buildroot-external/rootfs-overlay/usr/lib/systemd/system-preset/70-haos.preset index 5767f596e..7d843537e 100644 --- a/buildroot-external/rootfs-overlay/usr/lib/systemd/system-preset/70-haos.preset +++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/system-preset/70-haos.preset @@ -1 +1,3 @@ disable apparmor.service + +enable systemd-time-wait-sync.service diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-supervisor.service b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-supervisor.service index d282cfb63..98fe3e1be 100644 --- a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-supervisor.service +++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-supervisor.service @@ -1,8 +1,8 @@ [Unit] Description=HassOS supervisor Requires=docker.service rauc.service dbus.service -Wants=network-online.target hassos-apparmor.service -After=docker.service rauc.service dbus.service network-online.target +Wants=network-online.target hassos-apparmor.service time-sync.target +After=docker.service rauc.service dbus.service network-online.target time-sync.target RequiresMountsFor=/mnt/data /mnt/boot /mnt/overlay StartLimitIntervalSec=60 StartLimitBurst=5