View file File name : ntp Content :NTP_CONF=/etc/ntp.conf NTP_DHCP_CONF=/run/ntp.conf.dhcp ntp_server_restart() { invoke-rc.d ntp try-restart } ntp_servers_setup_remove() { if [ ! -e $NTP_DHCP_CONF ]; then return fi rm -f $NTP_DHCP_CONF ntp_server_restart } ntp_servers_setup_add() { networkd_ntp=$(sed -n 's/NTP=//p' /run/systemd/netif/leases/* 2>/dev/null) if [ -z "$new_ntp_servers" ] && [ -z "$networkd_ntp" ]; then ntp_servers_setup_remove return fi if [ -e $NTP_DHCP_CONF ] && [ "$new_ntp_servers" = "$old_ntp_servers" ] && [ -z "$networkd_ntp" ] ; then return fi tmp=$(mktemp "$NTP_DHCP_CONF.XXXXXX") || return chmod --reference=$NTP_CONF $tmp chown --reference=$NTP_CONF $tmp ( echo "# This file was copied from $NTP_CONF with the server options changed" echo "# to reflect the information sent by the DHCP server. Any changes made" echo "# here will be lost at the next DHCP event. Edit $NTP_CONF instead." echo echo "# NTP server entries received from DHCP server" for server in $new_ntp_servers $networkd_ntp; do echo "server $server iburst" done echo sed '/^[[:space:]]*\(server\|peer\|pool\)[[:space:]]/d' $NTP_CONF ) >>$tmp mv $tmp $NTP_DHCP_CONF ntp_server_restart } ntp_servers_setup() { case $reason in BOUND|RENEW|REBIND|REBOOT) ntp_servers_setup_add ;; EXPIRE|FAIL|RELEASE|STOP) ntp_servers_setup_remove ;; esac } ntp_servers_setup