diff options
author | petere <petere@0070b5ef-2f16-0410-befa-9a02bd1d6ddb> | 2006-10-07 13:26:22 +0000 |
---|---|---|
committer | petere <petere@0070b5ef-2f16-0410-befa-9a02bd1d6ddb> | 2006-10-07 13:26:22 +0000 |
commit | 8a5c3fbcfea2d35a0b4ad2a7ba58b690196d5e3c (patch) | |
tree | a5374b3fcb18997ed33474d2db082678748474c5 /debian/ntp.dhcp | |
parent | db937f2824b7f64d8f92822abb5bc37bbc2a66fb (diff) | |
download | ntp-8a5c3fbcfea2d35a0b4ad2a7ba58b690196d5e3c.tar.gz |
* Use server names sent by DHCP server if available (closes: #268328)
git-svn-id: svn://svn.debian.org/pkg-ntp/ntp/trunk@111 0070b5ef-2f16-0410-befa-9a02bd1d6ddb
Diffstat (limited to 'debian/ntp.dhcp')
-rw-r--r-- | debian/ntp.dhcp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/debian/ntp.dhcp b/debian/ntp.dhcp new file mode 100644 index 0000000..bf25d82 --- /dev/null +++ b/debian/ntp.dhcp @@ -0,0 +1,64 @@ +NTP_CONF=/etc/ntp.conf +NTP_DHCP_CONF=/etc/ntp.conf.dhcp + + +ntp_server_restart() { + invoke-rc.d ntp 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() { + if [ -e $NTP_DHCP_CONF ] && [ "$new_ntp_servers" = "$old_ntp_servers" ]; then + return + fi + + if [ -z "$new_ntp_servers" ]; then + ntp_servers_setup_remove + 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; do + echo "server $server iburst" + done + echo + sed -r -e '/^ *(server|peer).*$/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) + ntp_servers_setup_remove + ;; + esac +} + + +ntp_servers_setup |