Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

topotato: add freebsd environment #143

Open
wants to merge 4 commits into
base: topotato-base
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@

Vagrant.configure("2") do |config|

config.vm.box = "ubuntu/jammy64"
config.vm.define :freebsd do |freebsd|
freebsd.vm.box = "freebsd/FreeBSD-14.0-RELEASE"
freebsd.vm.provision "shell", path: "./vm/freebsd/install.sh"
# freebsd.vm.provision "shell", path: "./vm/freebsd/topotato-install.sh"
end

config.vm.define :ubuntu do |ubuntu|
ubuntu.vm.box = "ubuntu/jammy64"
ubuntu.vm.provision "shell", path: "./vm/ubuntu/install.sh"
ubuntu.vm.provision "shell", path: "./vm/ubuntu/topotato-install.sh"
end

config.vm.hostname = "topotato-dev"

Expand All @@ -29,7 +39,4 @@ Vagrant.configure("2") do |config|
config.vbguest.no_remote = true
end

config.vm.provision "shell", path: "./vm/ubuntu/install.sh"
config.vm.provision "shell", path: "./vm/ubuntu/topotato-install.sh"

end
29 changes: 29 additions & 0 deletions run_jail.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh

cd "`dirname $0`"

if [ \! -d "/usr/local/etc/frr" ]; then
echo /usr/local/etc/frr does not exist or is not a directory. Please create it. >&2
exit 1
fi

if [ "$1" = "ns_inner" ]; then

shift
for I in `ls -1 etc`; do
if [ "$I" = "frr" ]; then
continue
fi
mount_nullfs "etc/$I" "/etc/$I"
done
mount -t tmpfs tmpfs /var/tmp
mount -t tmpfs tmpfs /var/run

# ip link set lo0 up

exec ${PYTHON:-python} -mpytest "$@"
else
sudo jail -cmr -f ./vm/jail.conf
sudo jexec topotato $PWD/$0 ns_inner $@
sudo jail -r topotato
fi
41 changes: 41 additions & 0 deletions vm/freebsd/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/local/bin/bash

pkg install -y git autoconf automake libtool gmake json-c pkgconf \
bison py39-pytest c-ares py39-sphinx texinfo libunwind libyang2 protobuf-c

pw groupadd frr -g 101
pw groupadd frrvty -g 102
pw adduser frr -g 101 -u 101 -G 102 -c "FRR suite" \
-d /usr/local/etc/frr -s /usr/sbin/nologin


cd /home/vagrant
git clone https://github.com/frrouting/frr.git --single-branch frr
cd frr
./bootstrap.sh
export MAKE=gmake LDFLAGS=-L/usr/local/lib CPPFLAGS=-I/usr/local/include
./configure \
--sysconfdir=/usr/local/etc/frr \
--enable-pkgsrcrcdir=/usr/pkg/share/examples/rc.d \
--localstatedir=/var/run/frr \
--prefix=/usr/local \
--enable-multipath=64 \
--enable-user=frr \
--enable-group=frr \
--enable-vty-group=frrvty \
--enable-configfile-mask=0640 \
--enable-logfile-mask=0640 \
--enable-fpm \
--with-pkg-git-version \
--with-pkg-extra-version=-MyOwnFRRVersion
gmake
gmake check
gmake install

mkdir /usr/local/etc/frr
touch /usr/local/etc/frr/frr.conf

sysctl -w net.inet.ip.forwarding=1
sysctl -w net.inet6.ip6.forwarding=1

service sysctl restart
4 changes: 4 additions & 0 deletions vm/freebsd/topotato-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

cd /home/vagrant/dev/topotato
# TODO: Add packages for topotato
6 changes: 6 additions & 0 deletions vm/jail.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
topotato {
allow.mount;
allow.mount.nullfs;
allow.mount.tmpfs;
persist;
}