From 4392e97cf2fc644e486ae0a5734d8e9959809420 Mon Sep 17 00:00:00 2001 From: John <18377483+j0hnby@users.noreply.github.com> Date: Tue, 3 May 2022 17:11:17 +0100 Subject: [PATCH] J0hnby dhcp server ntp (#2376) * Add in configuration for NTP * Add in configuration for NTP * Update CHANGELOG.md * Add in configuration for NTP * Add in configuration for NTP * Update dhcp_server/CHANGELOG.md Follow suggestion to have 1.3.0 version convention Co-authored-by: Pascal Vizeli * Update dhcp_server/config.yaml Follow suggestion to have 1.3.0 version convention Co-authored-by: Pascal Vizeli * Update config.yaml * Addition to quotes for settings Lint highlighted a possible issue with unquoted - added in quotes to ensure it doesn't split Co-authored-by: Pascal Vizeli --- dhcp_server/CHANGELOG.md | 4 ++++ dhcp_server/DOCS.md | 8 ++++++++ dhcp_server/config.yaml | 6 +++++- dhcp_server/data/run.sh | 9 +++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/dhcp_server/CHANGELOG.md b/dhcp_server/CHANGELOG.md index c9341a7..ec3702d 100644 --- a/dhcp_server/CHANGELOG.md +++ b/dhcp_server/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.3.0 + +- Add NTP server configuration option. + ## 1.2 - Fixes crash when using FQDN as domain diff --git a/dhcp_server/DOCS.md b/dhcp_server/DOCS.md index 688bc18..eae9735 100644 --- a/dhcp_server/DOCS.md +++ b/dhcp_server/DOCS.md @@ -7,6 +7,7 @@ Follow these steps to get the add-on installed on your system: 1. Navigate in your Home Assistant frontend to **Supervisor** -> **Add-on Store**. 2. Find the "DHCP server" add-on and click it. 3. Click on the "INSTALL" button. +4. Modify configuration as needed ## How to use @@ -26,6 +27,8 @@ domain: mynetwork.local dns: - 8.8.8.8 - 8.8.4.4 +ntp: + - 192.168.1.0 default_lease: 86400 max_lease: 172800 networks: @@ -52,6 +55,11 @@ The DNS servers your DHCP server gives to your clients. This option can contain a list of servers. By default, it is configured to have Google's public DNS servers: `"8.8.8.8", "8.8.4.4". +### Option `ntp` (required) + +The NTP servers your DHCP server gives to your clients. This option can +contain a list of server. By default, none are configured ([]) + ### Option: `default_lease` (required) The default time in seconds that the IP is leased to your client. diff --git a/dhcp_server/config.yaml b/dhcp_server/config.yaml index 077198d..7da7e10 100644 --- a/dhcp_server/config.yaml +++ b/dhcp_server/config.yaml @@ -1,9 +1,10 @@ --- -version: "1.2" +version: 1.3.0 slug: dhcp_server name: DHCP server description: A simple DHCP server url: https://home-assistant.io/addons/dhcp_server/ +codenotary: notary@home-assistant.io advanced: true arch: - armhf @@ -18,6 +19,7 @@ options: dns: - 8.8.8.8 - 8.8.4.4 + ntp: [] domain: null hosts: [] max_lease: 172800 @@ -33,6 +35,8 @@ schema: default_lease: int dns: - str + ntp: + - str domain: str hosts: - ip: str diff --git a/dhcp_server/data/run.sh b/dhcp_server/data/run.sh index 3070d8d..1e5bb7d 100755 --- a/dhcp_server/data/run.sh +++ b/dhcp_server/data/run.sh @@ -20,6 +20,15 @@ MAX_LEASE=$(bashio::config 'max_lease') echo "authoritative;" } > "${CONFIG}" +# Create NTP Server List +if [ "$(bashio::config 'ntp')" ] +then + NTP=$(bashio::config 'ntp|join(", ")') + { + echo "option ntp-servers ${NTP};"; + } >> "${CONFIG}" +fi + # Create networks for network in $(bashio::config 'networks|keys'); do BROADCAST=$(bashio::config "networks[${network}].broadcast")