From 4ba61a1aaf51cf1c7214ba704af5ecac51bfc1bb Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Wed, 21 Nov 2018 00:28:40 +0100 Subject: [PATCH] OS: allow set NTP (#252) * OS: allow set NTP * Create etc-systemd-timesyncd.conf.mount * Update hassos-config * Update configuration.md * add link * Update Documentation/configuration.md Co-Authored-By: pvizeli --- Documentation/configuration.md | 2 ++ .../etc-systemd-timesyncd.conf.mount | 1 + .../rootfs-overlay/etc/tmpfiles.d/timesyncd.conf | 1 + .../system/etc-systemd-timesyncd.conf.mount | 14 ++++++++++++++ .../rootfs-overlay/usr/sbin/hassos-config | 9 +++++++++ 5 files changed, 27 insertions(+) create mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-systemd-timesyncd.conf.mount create mode 100644 buildroot-external/rootfs-overlay/etc/tmpfiles.d/timesyncd.conf create mode 100644 buildroot-external/rootfs-overlay/usr/lib/systemd/system/etc-systemd-timesyncd.conf.mount diff --git a/Documentation/configuration.md b/Documentation/configuration.md index be2a2b071..69b2cf13c 100644 --- a/Documentation/configuration.md +++ b/Documentation/configuration.md @@ -10,6 +10,7 @@ network/ modules/ udev/ authorized_keys +timesyncd.conf hassos-xy.raucb ``` @@ -17,6 +18,7 @@ hassos-xy.raucb - The `modules` folder is for modules-load configuration files. - The `udev` folder is for udev rules files. - The `authorized_keys` file activates debug SSH access on port `22222`. See [Debugging Hassio][debug-hassio]. +- The `timesyncd.conf` file allow you to set different NTP servers. HassOS won't boot without correct working time servers! - The `hassos-*.raucb` file is a firmware OTA update which will be installed. These can be found on on the [release][hassos-release] page. You can put this USB stick into the device and it will be read on startup. You can also trigger this process later over the diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-systemd-timesyncd.conf.mount b/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-systemd-timesyncd.conf.mount new file mode 120000 index 000000000..29053b7fc --- /dev/null +++ b/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-systemd-timesyncd.conf.mount @@ -0,0 +1 @@ +/usr/lib/systemd/system/etc-systemd-timesyncd.conf.mount \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/tmpfiles.d/timesyncd.conf b/buildroot-external/rootfs-overlay/etc/tmpfiles.d/timesyncd.conf new file mode 100644 index 000000000..b4d8dc217 --- /dev/null +++ b/buildroot-external/rootfs-overlay/etc/tmpfiles.d/timesyncd.conf @@ -0,0 +1 @@ +C /mnt/overlay/etc/systemd/timesyncd.conf - - - - /etc/systemd/timesyncd.conf diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/etc-systemd-timesyncd.conf.mount b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/etc-systemd-timesyncd.conf.mount new file mode 100644 index 000000000..a26658c2a --- /dev/null +++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/etc-systemd-timesyncd.conf.mount @@ -0,0 +1,14 @@ +[Unit] +Description=Timesyncd persistent configuration +Requires=mnt-overlay.mount +After=mnt-overlay.mount systemd-tmpfiles-setup.service +Before=systemd-timesyncd.service + +[Mount] +What=/mnt/overlay/etc/systemd/timesyncd.conf +Where=/etc/systemd/timesyncd.conf +Type=none +Options=bind + +[Install] +WantedBy=hassos-bind.target diff --git a/buildroot-external/rootfs-overlay/usr/sbin/hassos-config b/buildroot-external/rootfs-overlay/usr/sbin/hassos-config index 1c2a9f587..5338eb830 100755 --- a/buildroot-external/rootfs-overlay/usr/sbin/hassos-config +++ b/buildroot-external/rootfs-overlay/usr/sbin/hassos-config @@ -75,6 +75,15 @@ else systemctl stop dropbear > /dev/null 2>&1 fi +## +# timesyncd +if [ -f "${CONFIG_DIR}/timesyncd.conf" ]; then + echo "[Info] Update timesyncd config" + + cat "${CONFIG_DIR}/timesyncd.conf" > /etc/systemd/timesyncd.conf + systemctl restart systemd-timesyncd.service > /dev/null 2>&1 +fi + ## # Firmware update / Only USB UPTIME=$(awk '{printf "%0.f", $1}' /proc/uptime)