[Pkg-utopia-maintainers] Bug#537358: network-manager: ignores /etc/dhcp3/dhclient-*-hooks.d
Alan MacLeod
alan at eng.com
Sun Jan 22 21:41:17 UTC 2012
Hi,
I had also hoped that this issue would be fixed as it seems to be in all
Debian derivatives. I reported this issue as a bug upstream and was
informed that the problem does not existing in RedHat and the solution
is required at the distro level. Dan Williams (at RedHat) - kindly
pointed me in the right direction.
My issues are limited to NTP, so I have hacked a script to fix that by
leveraging the existing ntp script in dhclient-exit-hooks.d. I am no
script writer, but it works fine in my environment. The only real
shortcoming is that it doesn't compare the existing ntp servers with the
ones from DHCP, so arguably it could pointlessly needlessly
create /var/lib/ntp/ntp.conf.dhcp. Hopefully someone more skilled can
fix that, and it can added to the package moving forward.
If you cut and paste the script below, I have tried to catch the wrapped
text, but this needs to be verifed. That aside, I named the script
11ntp... I hope this is useful to others.
Thanks
Alan
#!/bin/sh -e
# Script to take DHCP configured NTP servers
# This heavily leverages the ntp script from dhclient-exit-hooks.d
if [ -z "$1" ]; then
echo "$0: called with no interface" 1>&2
exit 1;
fi
NTP_CONF=/etc/ntp.conf
NTP_DHCP_CONF=/var/lib/ntp/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
}
# Run the right scripts
case "$2" in
up|vpn-up)
if [ -e $NTP_DHCP_CONF ] && [ -z "$DHCP4_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 $DHCP4_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
;;
down|vpn-down)
if [ ! -e $NTP_DHCP_CONF ]; then
return
fi
rm -f $NTP_DHCP_CONF
ntp_server_restart
;;
hostname|dhcp4-change|dhcp6-change)
# Do nothing
;;
*)
echo "$0: called with unknown action \`$2'" 1>&2
exit 1
;;
esac
More information about the Pkg-utopia-maintainers
mailing list