From a497c70abe6548103781ac39e36203efa48ae14c Mon Sep 17 00:00:00 2001 From: toby Date: Sat, 23 Feb 2019 04:09:55 +0000 Subject: [PATCH] adding mgmt dhcp6 - so we get ntp and dns over ipv6 - and timesyncd dhcp6 exit script --- debian/wit-network-config.install | 5 ++-- debian/wit-network-config.postinst | 3 ++- files/timesyncd6 | 42 ++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 files/timesyncd6 diff --git a/debian/wit-network-config.install b/debian/wit-network-config.install index bcce82c..f1dd242 100644 --- a/debian/wit-network-config.install +++ b/debian/wit-network-config.install @@ -12,9 +12,10 @@ files/qemu-ifup etc/libvirt/hooks files/firewall etc/init.d files/ips.issue etc/issue.d files/wit-logging.conf etc/strongswan.d -files/lldpd.wit /etc/default +files/lldpd.wit etc/default +files/timesyncd6 etc/dhcp/dhclient-exit-hooks.d templates/wit-swanctl.conf etc/swanctl/conf.d templates/frr.conf.wit etc/frr templates/70-persistent-net.rules etc/udev/rules.d -templates/interfaces /etc/network +templates/interfaces etc/network templates/ipsec.conf.wit etc diff --git a/debian/wit-network-config.postinst b/debian/wit-network-config.postinst index 285da2c..18aa1a7 100755 --- a/debian/wit-network-config.postinst +++ b/debian/wit-network-config.postinst @@ -213,11 +213,12 @@ case "$1" in cat <<-EOF >>$IFCONFIG auto $ifname iface $ifname inet6 auto - iface $ifname inet dhcp pre-up /bin/ip link add mgmt type vrf table mgmt pre-up /bin/ip link set up dev mgmt pre-up /bin/ip link set master mgmt dev $ifname post-down /bin/ip link del dev mgmt + iface $ifname inet6 dhcp + iface $ifname inet dhcp EOF diff --git a/files/timesyncd6 b/files/timesyncd6 new file mode 100644 index 0000000..22482ed --- /dev/null +++ b/files/timesyncd6 @@ -0,0 +1,42 @@ +TIMESYNCD_CONF=/run/systemd/timesyncd.conf.d/01-dhclient6.conf + +timesyncd_servers_setup_remove() { + if [ -e $TIMESYNCD_CONF ]; then + rm -f $TIMESYNCD_CONF + systemctl try-restart systemd-timesyncd.service || true + fi +} + +timesyncd_servers_setup_add() { + if [ ! -d /run/systemd/system ]; then + return + fi + + if [ -e $TIMESYNCD_CONF ] && [ "$new_dhcp6_sntp_servers" = "$old_dhcp6_sntp_servers" ]; then + return + fi + + if [ -z "$new_dhcp6_sntp_servers" ]; then + timesyncd_servers_setup_remove + return + fi + + mkdir -p $(dirname $TIMESYNCD_CONF) + cat < ${TIMESYNCD_CONF}.new +# NTP server entries received from DHCP server +[Time] +NTP=$new_dhcp6_sntp_servers +EOF + mv ${TIMESYNCD_CONF}.new ${TIMESYNCD_CONF} + systemctl try-restart systemd-timesyncd.service || true +} + + +case $reason in + BOUND|BOUND6|RENEW|RENEW6|REBIND|REBIND6|REBOOT|REBOOT6) + timesyncd_servers_setup_add + ;; + EXPIRE|EXPIRE6|FAIL|FAIL6|RELEASE|RELEASE6|STOP|STOP6) + timesyncd_servers_setup_remove + ;; +esac