From 3972c890193758097216204e866184e93b319281 Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Fri, 12 Feb 2021 08:19:23 +0100 Subject: [PATCH] Only install kata if not installed already --- docker-install-all.sh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/docker-install-all.sh b/docker-install-all.sh index 2148936..0f05b9b 100755 --- a/docker-install-all.sh +++ b/docker-install-all.sh @@ -27,16 +27,17 @@ mem=$(sed -E 's/^MemTotal: +([0-9]+) kB/\1/p;d' < /proc/meminfo) mempercore=$(((mem/1024-4096)/cores)) # install kata containers -echo "Installing kata...." -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) -# wait for finish -while [ "$(docker container inspect -f '{{.State.Running}}' "$cid")" == "true" ]; do - sleep 1 -done -echo "Kata installed" - -# 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 +if ! docker info 2>/dev/null|grep Runtimes:|grep -qs kata-qemu-virtiofs; then + echo "Installing kata...." + 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) + # wait for finish + while [ "$(docker container inspect -f '{{.State.Running}}' "$cid")" == "true" ]; do + sleep 1 + done + # 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 + echo "Kata installed" +fi trusty xenial