[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: ntpd restart on IP address change the Debian way



Bob wrote:
> Sorry to resurrect such an old thread but this is really irritating me,
> after reading through the Bug Reports it seems this has been fixed in
> version 4.2.4 which is fine for Lenny but I don't want to run Lenny on
> my firewall, it's very simple dedicated etch box with nothing other than
> main and updates in its /etc/apt/sources.list so I don't want to start
> messing around with apt pinning.
> 
> Is there a simple way to get the dhcp client to restart ntpd on IP
> address change?
> 
> Thank you.
> 
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=455717
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=439734
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=231354


I'm on my ubuntu workstation right now, they seem to have incorporated that
thing already (which would work with any demon, i found at my workstation
at home that squid restarts whenever I fire up the VPN to the office):

/etc/dhcp3/dhclient-enter-hooks.d/ntpdate

/etc/dhcp3/dhclient-enter-hooks.d $ cat ntpdate
NTPDATE_CONF=/etc/default/ntpdate
NTPDATE_DHCP_CONF=/etc/default/ntpdate.dhcp

--snip--
ntp_servers_setup_remove() {
        rm -f $NTPDATE_DHCP_CONF
}


ntp_servers_setup_add() {
        if [ -e $NTPDATE_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 "$NTPDATE_DHCP_CONF.XXXXXX") || return
        chmod --reference=$NTPDATE_CONF $tmp
        chown --reference=$NTPDATE_CONF $tmp

        (
          echo "# NTP server entries received from DHCP server"
          echo "NTPSERVERS='$new_ntp_servers'"
        ) >>$tmp

        mv $tmp $NTPDATE_DHCP_CONF
}


ntp_servers_setup() {
        case $reason in
                BOUND|RENEW|REBIND|REBOOT)
                        ntp_servers_setup_add
                        ;;
                EXPIRE|FAIL)
                        ntp_servers_setup_remove
                        ;;
        esac
}


ntp_servers_setup
--snap--

-- 
http://noneisyours.marcher.name
http://feeds.feedburner.com/NoneIsYours

You are not free to read this message,
by doing so, you have violated my licence
and are required to urinate publicly. Thank you.


Reply to: