diff --git a/.gitignore b/.gitignore index edbd78c..6cf30ac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ debian/.debhelper debian/debhelper-build-stamp debian/wit-hypervisor/ +debian/files +debian/wit-hypervisor.postinst.debhelper +debian/wit-hypervisor.prerm.debhelper +debian/wit-hypervisor.substvars diff --git a/debian/changelog b/debian/changelog index d2dafab..1eaaea8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,4 +2,4 @@ wit-hypervisor (1.0) unstable; urgency=low * Initial release. - -- Toby Paler Wed, 25 Jul 2018 22:54:00 +0100 + -- Toby Wed, 25 Jul 2018 22:54:00 +0100 diff --git a/debian/postinst.ex b/debian/postinst.ex index 9caaa7f..6cb4c5a 100644 --- a/debian/postinst.ex +++ b/debian/postinst.ex @@ -21,6 +21,25 @@ set -e case "$1" in configure) + echo "auto lo:0" >/etc/network/interfaces.d/lo + echo "iface lo:0 inet static\n address 10.1.$TIER_ID.$NODE_ID/32" >> /etc/network/interfaces.d/lo + echo "iface lo:0 inet6 static\n address 2604:bbc0::$TIER_ID:$NODE_ID/128" >> /etc/network/interfaces.d/lo + + sed -e "s/VTEPINDEX/$MYID/" -e "s/TIERID/$TIERID/" -e "s/TIERASN/$(printf "%03d" $TIERID)/" -e "s/VTEPASN/$(printf "%03d" $MYID)/" /usr/share/wit-hypervisor/frr.conf.tmpl >/etc/frr/frr.conf + + + echo 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="'$MGMT_MAC'", ATTR{type}=="1", NAME="mgmt1"' >/etc/udev/rules.d/70-persistent-net.rules + i=0 + for nic in $(ip -br link | awk '{ print $1 }'); do + if ethtool $nic | grep -q 10000; then + i=$((i+1)) + echo 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="'$(cat /sys/class/net/$nic/address)'", ATTR{type}=="1", NAME="feth'$i'"' >>/etc/udev/rules.d/70-persistent-net.rules + fi + done + sed -i "/$MGMT_MAC.*feth./d" /etc/udev/rules.d/70-persistent-net.rules + + + systemctl stop systemd-networkd.socket systemctl stop systemd-networkd.service systemctl stop systemd-networkd-wait-online diff --git a/debian/preinst.ex b/debian/preinst.ex index 4605f0e..e96b7bb 100644 --- a/debian/preinst.ex +++ b/debian/preinst.ex @@ -20,6 +20,7 @@ case "$1" in [ -z "$NODE_ID" ] && export NODE_ID=$(ip -4 -br addr | grep 10.0. | awk '{ print $3 }' | awk 'BEGIN{FS="[./]"} { print $4 }') MGMT_ID=$(ip -4 -br addr | grep 10.0. | awk '{ print $3 }' | awk 'BEGIN{FS="[./]"} { print $3 }') + MGMT_MAC=$(ip -br link show dev $(ip -4 -br addr | grep 10.0. | awk '{ print $1 }') | awk '{ print $3 }') [ "$MGMT_ID" -ge 0 -a "$MGMT_ID" -lt 16 ] && export DOMAINNAME=.usw1.wit.com diff --git a/debian/wit-hypervisor.hide b/debian/wit-hypervisor.hide index 863ce93..cc3e875 100644 --- a/debian/wit-hypervisor.hide +++ b/debian/wit-hypervisor.hide @@ -1 +1,4 @@ /etc/systemd/network/* +/etc/frr/daemons +/etc/bash.bashrc +/etc/systemd/timesyncd.conf.wit diff --git a/debian/wit-hypervisor.install b/debian/wit-hypervisor.install index f7a4f45..dc8ba2a 100644 --- a/debian/wit-hypervisor.install +++ b/debian/wit-hypervisor.install @@ -5,10 +5,10 @@ files/rc.local etc files/10-frr.conf etc/sysctl.d files/wit-gc usr/bin files/resolv.conf etc -files/bashrc-witaddon root +files/bashrc-witaddon etc files/qemu-ifdown etc/libvirt/hooks files/qemu-ifup-public etc/libvirt/hooks files/qemu-ifup etc/libvirt/hooks files/firewall etc/init.d -files/frr.conf etc/frr files/interfaces etc/network +files/frr.conf.tmpl usr/share/wit-hypervisor diff --git a/debian/wit-hypervisor.transform b/debian/wit-hypervisor.transform index d2a3132..8494474 100644 --- a/debian/wit-hypervisor.transform +++ b/debian/wit-hypervisor.transform @@ -1,9 +1,3 @@ -/etc/network/interfaces sed -e "s/TIERID/$TIER_ID/g" -/etc/frr/frr.conf sed -e "s/VTEPINDEX/$NODE_ID/" -e "s/TIERID/$TIER_ID/" -e "s/TIERASN/$(printf "%03d" $TIER_ID)/" -e "s/VTEPASN/$(printf "%03d" $NODE_ID)/" -/etc/hosts sed -e "/.*debcore1/d" -e "/.*$MYHOSTNAME/d" -e "$ s/$/\n10.1.$TIER_ID.$NODE_ID\t$MYHOSTNAME/" -/etc/frr/daemons sed -e 's/bgpd=no/bgpd=yes/' -e 's/zebra=no/zebra=yes/' -/etc/ssh/sshd_config sed -e '/PasswordAuthentication/d' -e '$ s/$/\nPasswordAuthentication no/' -/etc/systemd/timesyncd.conf sed -e 's/#NTP=.*/NTP=ipv6.ntp.ubuntu.com/g' -/etc/default/grub sed -e '/GRUB_CMDLINE_LINUX_DEFAULT=/d' -e '/GRUB_CMDLINE_LINUX=/d' -e '/GRUB_SERIAL_COMMAND=/d' -e '/GRUB_TERMINAL=/d' -e '$ s/$/\nGRUB_CMDLINE_LINUX_DEFAULT=""\nGRUB_CMDLINE_LINUX="console=tty0 console=ttyS1,115200n8"\nGRUB_TERMINAL=serial\nGRUB_SERIAL_COMMAND="serial --speed=115200 --unit=1 --word=8 --parity=no --stop=1"/' -/root/.bashrc sed -e '/.*bashrc-witaddon.*/d' -e '$ /$/\nsource ~/bashrc-witaddon/' - +/etc/frr/daemons.wit sed -e 's/bgpd=no/bgpd=yes/' -e 's/zebra=no/zebra=yes/' +/etc/systemd/timesyncd.conf.wit sed -e 's/#NTP=.*/NTP=ipv6.ntp.ubuntu.com/g' +/etc/bash.bashrc.wit sed -e '/.*bashrc-witaddon.*/d' -e '$ s/$/\nsource \/etc\/bashrc-witaddon/' diff --git a/files/frr.conf b/files/frr.conf.tmpl similarity index 100% rename from files/frr.conf rename to files/frr.conf.tmpl diff --git a/files/interfaces b/files/interfaces index 7adb3e0..10cfff2 100644 --- a/files/interfaces +++ b/files/interfaces @@ -1,13 +1,6 @@ auto lo iface lo inet loopback -auto lo:0 -iface lo:0 inet static - address 10.1.TIERID.VTEPINDEX/32 - -iface lo:0 inet6 static - address 2604:bbc0::TIERID:VTEPINDEX/128 - auto mgmt1 iface mgmt1 inet6 auto iface mgmt1 inet dhcp @@ -26,3 +19,4 @@ iface feth2 inet manual mtu 9000 +source-directory /etc/network/interfaces.d