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 <james.o.hunt@intel.com>
This commit is contained in:
James O. D. Hunt 2022-02-15 14:05:06 +00:00
parent c464f32676
commit 714c9f56fd

View File

@ -391,12 +391,19 @@ configure_containerd()
local cfg="/etc/containerd/config.toml" local cfg="/etc/containerd/config.toml"
local systemd_unit_dir="/etc/systemd/system"
sudo mkdir -p "$systemd_unit_dir"
local dest="${systemd_unit_dir}/${containerd_service_name}"
if [ ! -f "$dest" ]
then
pushd "$tmpdir" >/dev/null pushd "$tmpdir" >/dev/null
local service_url=$(printf "%s/%s/%s/%s" \ local service_url=$(printf "%s/%s/%s/%s" \
"https://raw.githubusercontent.com" \ "https://raw.githubusercontent.com" \
"${containerd_slug}" \ "${containerd_slug}" \
"master" \ "main" \
"${containerd_service_name}") "${containerd_service_name}")
curl -LO "$service_url" curl -LO "$service_url"
@ -405,10 +412,6 @@ configure_containerd()
"$(date -Iseconds)" |\ "$(date -Iseconds)" |\
tee -a "$containerd_service_name" 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 cp "${containerd_service_name}" "${dest}"
sudo systemctl daemon-reload sudo systemctl daemon-reload
@ -416,6 +419,7 @@ configure_containerd()
info "Installed ${dest}" info "Installed ${dest}"
popd >/dev/null popd >/dev/null
fi
# Backup the original containerd configuration: # Backup the original containerd configuration:
sudo mkdir -p "$(dirname $cfg)" sudo mkdir -p "$(dirname $cfg)"
@ -448,6 +452,7 @@ EOT
info "Modified $cfg" info "Modified $cfg"
} }
sudo systemctl enable containerd
sudo systemctl start containerd sudo systemctl start containerd
info "Configured $project\n" info "Configured $project\n"