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.
@@ -391,12 +391,19 @@ configure_containerd()
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
local service_url=$(printf "%s/%s/%s/%s" \
"https://raw.githubusercontent.com" \
"${containerd_slug}" \
- "master" \
+ "main" \
"${containerd_service_name}")
curl -LO "$service_url"
@@ -405,10 +412,6 @@ configure_containerd()
"$(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
@@ -416,6 +419,7 @@ configure_containerd()
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"
