--- dhcp-3.0.6/client/scripts/linux +++ dhcp-3.0.6/client/scripts/linux 2008/04/04 07:37:35 @@ -103,6 +103,54 @@ done } +remove_ntp_runtime_conf() { + if test -f "/var/run/ntp/servers.${interface}" ; then + rm -f "/var/run/ntp/servers.${interface}" + + if test -x /etc/init.d/ntp ; then + /etc/init.d/ntp try-restart + fi + fi +} + +make_ntp_runtime_conf() { + if [ "x$new_ntp_servers" != "x" ]; then + local restart=no + if test -f "/var/run/ntp/servers.${interface}" ; then + . "/var/run/ntp/servers.${interface}" + test "x$RUNTIME_SERVERS" = "x$new_ntp_servers" && return 0 + + restart=yes + rm -f "/var/run/ntp/servers.${interface}" + fi + + cat > "/var/run/ntp/servers.${interface}" << EOF +### BEGIN INFO +# +# Modified_by: dhclient-script +# Process: /sbin/dhclient +# Process_id: $(pidof dhclient) +# Script: /sbin/dhclient-script +# +# Info: This is a temporary generated config by the dhclient-script. +# In the case of a restart these infomrmations are used to +# add the ntp servers at runtime. +### END INFO + +RUNTIME_SERVERS="$new_ntp_servers" + +EOF + + if test -x /etc/init.d/ntp ; then + if test "$restart" = "no" ; then + /etc/init.d/ntp addserver $new_ntp_servers + else + /etc/init.d/ntp try-restart + fi + fi + fi +} + function write_informational_resolv_conf_header() { cat > /etc/resolv.conf << EOF ### BEGIN INFO @@ -250,6 +298,7 @@ fi if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 1 ) != 1 )); then make_resolv_conf + make_ntp_runtime_conf eval `grep --no-filename "^DHCLIENT_SET_HOSTNAME=" /etc/sysconfig/network/dhcp` if [ "$DHCLIENT_SET_HOSTNAME" = yes ] ; then @@ -311,6 +360,7 @@ route add default gw $router done make_resolv_conf + make_ntp_runtime_conf exit_with_hooks 0 fi ifconfig $interface inet 0 down @@ -321,5 +371,7 @@ if test -f /etc/resolv.conf.saved.by.dhclient ; then mv /etc/resolv.conf.saved.by.dhclient /etc/resolv.conf fi +# remove runtime ntp conf +remove_ntp_runtime_conf exit_with_hooks 0