TIMESYNCD_CONF=/run/systemd/timesyncd.conf.d/01-dhclient6.conf timesyncd_servers_setup_remove() { if [ -e $TIMESYNCD_CONF ]; then rm -f $TIMESYNCD_CONF systemctl try-restart systemd-timesyncd.service || true fi } timesyncd_servers_setup_add() { if [ ! -d /run/systemd/system ]; then return fi if [ -e $TIMESYNCD_CONF ] && [ "$new_dhcp6_sntp_servers" = "$old_dhcp6_sntp_servers" ]; then return fi if [ -z "$new_dhcp6_sntp_servers" ]; then timesyncd_servers_setup_remove return fi mkdir -p $(dirname $TIMESYNCD_CONF) cat < ${TIMESYNCD_CONF}.new # NTP server entries received from DHCP server [Time] NTP=$new_dhcp6_sntp_servers EOF mv ${TIMESYNCD_CONF}.new ${TIMESYNCD_CONF} systemctl try-restart systemd-timesyncd.service || true } case $reason in BOUND|BOUND6|RENEW|RENEW6|REBIND|REBIND6|REBOOT|REBOOT6) timesyncd_servers_setup_add ;; EXPIRE|EXPIRE6|FAIL|FAIL6|RELEASE|RELEASE6|STOP|STOP6) timesyncd_servers_setup_remove ;; esac