2021-02-11 10:26:44 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
trusty()
|
|
|
|
{
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
xenial()
|
|
|
|
{
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
bionic()
|
|
|
|
{
|
|
|
|
cd /usr/src/buildbot-scripts/docker/bionic || return
|
|
|
|
docker build -t pybm-build-bionic .
|
|
|
|
}
|
|
|
|
|
|
|
|
focal()
|
|
|
|
{
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
cores=$(grep -E '^cpu cores' /proc/cpuinfo |head -1|cut -d: -f2|tr -d '[:space:]')
|
|
|
|
mem=$(sed -E 's/^MemTotal: +([0-9]+) kB/\1/p;d' < /proc/meminfo)
|
|
|
|
mempercore=$(((mem/1024-4096)/cores))
|
|
|
|
|
|
|
|
# install kata containers
|
2021-02-11 10:48:43 +01:00
|
|
|
cid=$(docker run -d --runtime=runc -v /opt/kata:/opt/kata -v /var/run/dbus:/var/run/dbus -v /run/systemd:/run/systemd -v /etc/docker:/etc/docker -it katadocker/kata-deploy kata-deploy-docker install)
|
2021-02-11 10:45:03 +01:00
|
|
|
# wait for finish
|
|
|
|
while [ "$(docker container inspect -f '{{.State.Running}}' "$cid")" == "true" ]; do
|
|
|
|
sleep 1
|
|
|
|
done
|
2021-02-11 10:26:44 +01:00
|
|
|
|
|
|
|
# update default container CPU and memory
|
|
|
|
sed -i "s/default_vcpus = .*/default_vcpus = 2/g;s/default_memory = .*/default-memory = $mempercore/g" /opt/kata/share/defaults/kata-containers/configuration-qemu-virtiofs.toml
|
|
|
|
|
|
|
|
trusty
|
|
|
|
xenial
|
|
|
|
bionic
|
|
|
|
focal
|