#!/bin/bash

set -x

# Install openvswitch, python and devel as mininet deps
sudo dnf install python python-devel openvswitch
# Update pip
sudo pip install --upgrade pip
# Install pytest
sudo pip install pytest

# Enable openvswitch
sudo systemctl enable openvswitch
sudo systemctl start openvswitch

# Install mininet (stable 2.2.2)
(mkdir tmp; cd tmp/; \
	git clone --branch 2.2.2 https://github.com/mininet/mininet.git; \
	cd mininet/util; ./install.sh -n)

# Install FRR
sudo groupadd -r -g 92 frr
sudo groupadd -r -g 85 frrvty
sudo adduser -r -g frr -d /var/run/frr -c "FRRouting suite" -s /bin/false frr
sudo usermod -G frrvty frr
sudo dnf install \
	autoconf automake libtool json-c-devel readline-devel \
	c-ares-devel bison flex

git clone https://github.com/FRRouting/frr.git
cd frr; \
	./bootstrap.sh; \
	./configure \
		--prefix=/usr \
		--localstatedir=/var/run/frr \
		--sbindir=/usr/lib/frr \
		--sysconfdir=/etc/frr \
		--enable-vtysh \
		--enable-pimd \
		--enable-multipath=64 \
		--enable-user=frr \
		--enable-group=frr \
		--enable-vty-group=frrvty \
		--disable-doc \
		--with-pkg-extra-version=-my-manual-build; \
	make -j2 && sudo make install

