It does not take too much to create a machine…

WIP: the tmux does not work.
master
LEdoian 2 weeks ago
parent dbc610e54e
commit 36f05c26e4

@ -1,6 +1,9 @@
#!/bin/false #!/bin/false
mach=$(basename $(dirname "$0")) mach="${0#*machines/}"
mach="${mach%%/*}"
net="${0#*networks/}"
net="${net%%/*}"
netns=netns netns=netns
nethorror_root="`pwd`" # and hope? nethorror_root="`pwd`" # and hope?
@ -49,7 +52,7 @@ bridge_name() {
} }
make_bridge() { make_bridge() {
br="$(bridge_name "$mach")" br="$(bridge_name "$net")"
ip link add name "$br" type bridge ip link add name "$br" type bridge
ip link set dev "$br" up ip link set dev "$br" up
} }

@ -29,5 +29,5 @@ nsenter --net="$vm_netns" ip route add 2a01:4f8:c0c:36b8:ff01:8000:0:0001/128 de
nsenter --net="$vm_netns" ip route add default via 2a01:4f8:c0c:36b8:ff01:8000:0:0001 dev wg-vms nsenter --net="$vm_netns" ip route add default via 2a01:4f8:c0c:36b8:ff01:8000:0:0001 dev wg-vms
nsenter --net="$vm_netns" sysctl net.ipv6.conf.all.forwarding=1 nsenter --net="$vm_netns" sysctl net.ipv6.conf.all.forwarding=1
nsenter --net="$vm_netns" ./machines/$mach/vm1/start.sh
#nsenter --net="$vm_netns" ip route add 2a01:4f8:c0c:36b8:ff01:8000:0:0001/128 dev wg-vms onlink #nsenter --net="$vm_netns" ip route add 2a01:4f8:c0c:36b8:ff01:8000:0:0001/128 dev wg-vms onlink

@ -0,0 +1,20 @@
#!/bin/sh
# LEdoian's absurdly simple initrd generator (ad-hoc arc)
set -eu
outdir="$1"
mkdir "$outdir/initrd"
cp init "$outdir/initrd/"
busybox="$(which busybox)"
cp "$busybox" "$outdir/initrd/busybox"
# TODO: get kernel version from /boot/vmlinuz-linux (which we use)
kver="$(uname -r)"
zstdcat /usr/lib/modules/$kver/kernel/drivers/net/ethernet/intel/e1000/e1000.ko.zst > "$outdir/initrd/e1000.ko"
pushd "$outdir/initrd"
find . | cpio -o -H newc > ../initrd.img
popd

@ -0,0 +1,12 @@
#!/busybox ash
/busybox echo START
#/busybox mdev -s
# we know the modules, lol :-)
/busybox insmod /e1000.ko
/busybox ip link set lo up
/busybox ip addr add 2a01:4f8:c0c:36b8:ff01:8000:0:3/128 dev eth0
/busybox ip link set eth0 up
/busybox ip route add default via 2a01:4f8:c0c:36b8:ff01:8000:0:1 dev eth0 onlink
/busybox ash

@ -0,0 +1,9 @@
#!/bin/sh
set -eu
arch=x86_64
kernel=/boot/vmlinuz-linux
initrd_dir="$1"
shift 1
exec qemu-system-"$arch" -m 1G -kernel "$kernel" -initrd "$initrd_dir/initrd.img" -nographic -append console=ttyS0,115200n1 "$@"

@ -0,0 +1,6 @@
#!/bin/sh
. ./lib.shs
mkdir state/$mach/initdir
tmux new-window -d vm1 sh -c machines/$mach/vm1/create.sh state/$mach/initdir \&\& machines/$mach/vm1/run.sh state/$mach/initdir
Loading…
Cancel
Save