mirror of
https://github.com/home-assistant/operating-system.git
synced 2025-07-25 22:16:30 +00:00
* Add support for NTP configuration via DHCP. * Default fallback NTP pool is the Cloudflare's one
This commit is contained in:
parent
616c406e8e
commit
f62fee2ff7
@ -1,3 +1,2 @@
|
||||
[Time]
|
||||
NTP=time.cloudflare.com
|
||||
FallbackNTP=0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org 3.pool.ntp.org
|
||||
FallbackNTP=time.cloudflare.com
|
||||
|
@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
|
||||
TIMESYNCD_CONF=/run/systemd/timesyncd.conf.d/10-ntp.conf
|
||||
|
||||
timesyncd_dhcp_ntp_remove() {
|
||||
if [ -e $TIMESYNCD_CONF ]; then
|
||||
rm -f $TIMESYNCD_CONF
|
||||
systemctl restart systemd-timesyncd.service
|
||||
fi
|
||||
}
|
||||
|
||||
timesyncd_dhcp_ntp_add() {
|
||||
mkdir -p $(dirname $TIMESYNCD_CONF)
|
||||
|
||||
echo '[Time]' > ${TIMESYNCD_CONF}
|
||||
echo "NTP=${DHCP4_NTP_SERVERS}" >> ${TIMESYNCD_CONF}
|
||||
|
||||
systemctl restart systemd-timesyncd.service
|
||||
}
|
||||
|
||||
INTERFACE=${1}
|
||||
ACTION=${2}
|
||||
|
||||
case ${ACTION} in
|
||||
up|down|dhcp4-change)
|
||||
if [ ! -z "${DHCP4_NTP_SERVERS}" ]
|
||||
then
|
||||
timesyncd_dhcp_ntp_add
|
||||
RETURN_CODE=$?
|
||||
else
|
||||
timesyncd_dhcp_ntp_remove
|
||||
RETURN_CODE=$?
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
$RETURN_CODE=0
|
||||
;;
|
||||
esac
|
||||
|
||||
return $RETURN_CODE
|
Loading…
x
Reference in New Issue
Block a user