From 714c9f56fdad47fcad4df58fee7c8425f4559899 Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Tue, 15 Feb 2022 14:05:06 +0000 Subject: [PATCH] utils: Improve containerd configuration `kata-manager.sh` improvements for containerd: - Fixed containerd default branch (which is now `main`). - Only install service file if it doesn't already exist. - Enable the containerd service to ensure it can be started. Signed-off-by: James O. D. Hunt --- utils/kata-manager.sh | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/utils/kata-manager.sh b/utils/kata-manager.sh index f7e11e425e..e0cc954575 100755 --- a/utils/kata-manager.sh +++ b/utils/kata-manager.sh @@ -391,31 +391,35 @@ configure_containerd() local cfg="/etc/containerd/config.toml" - pushd "$tmpdir" >/dev/null - - local service_url=$(printf "%s/%s/%s/%s" \ - "https://raw.githubusercontent.com" \ - "${containerd_slug}" \ - "master" \ - "${containerd_service_name}") - - curl -LO "$service_url" - - printf "# %s: Service installed for Kata Containers\n" \ - "$(date -Iseconds)" |\ - tee -a "$containerd_service_name" - local systemd_unit_dir="/etc/systemd/system" sudo mkdir -p "$systemd_unit_dir" local dest="${systemd_unit_dir}/${containerd_service_name}" - sudo cp "${containerd_service_name}" "${dest}" - sudo systemctl daemon-reload + if [ ! -f "$dest" ] + then + pushd "$tmpdir" >/dev/null - info "Installed ${dest}" + local service_url=$(printf "%s/%s/%s/%s" \ + "https://raw.githubusercontent.com" \ + "${containerd_slug}" \ + "main" \ + "${containerd_service_name}") - popd >/dev/null + curl -LO "$service_url" + + printf "# %s: Service installed for Kata Containers\n" \ + "$(date -Iseconds)" |\ + tee -a "$containerd_service_name" + + + sudo cp "${containerd_service_name}" "${dest}" + sudo systemctl daemon-reload + + info "Installed ${dest}" + + popd >/dev/null + fi # Backup the original containerd configuration: sudo mkdir -p "$(dirname $cfg)" @@ -448,6 +452,7 @@ EOT info "Modified $cfg" } + sudo systemctl enable containerd sudo systemctl start containerd info "Configured $project\n"