This repository has been archived by the owner on Jun 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5375 from cmaf/sgx-ci-helper-scripts
ci: add script to configure containerd for sgx
- Loading branch information
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2023 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
cidir=$(dirname "$0") | ||
source "${cidir}/lib.sh" | ||
|
||
[ "$#" -eq 1 ] || die "Specify configure or unconfigure" | ||
|
||
containerd_config_file="/etc/containerd/config.toml" | ||
pod_annotations_sgx="\"sgx.intel.com\/epc\"" | ||
pod_annotations_orig="\"io.katacontainers.*\"" | ||
pod_annotations_match="pod_annotations \= \[$pod_annotations_orig" | ||
|
||
configure_annotation() { | ||
echo "Configure pod annotations for sgx" | ||
if !(grep -q "$pod_annotations_sgx" "$containerd_config_file"); then | ||
sed -i -e 's/'$pod_annotations_orig'/'$pod_annotations_orig', '$pod_annotations_sgx'/g' $containerd_config_file | ||
systemctl restart containerd | ||
fi | ||
} | ||
|
||
unconfigure_annotation() { | ||
echo "Remove pod annotations for sgx" | ||
if grep -q "$pod_annotations_sgx" "$containerd_config_file"; then | ||
sed -i -e 's/, '$pod_annotations_sgx'//g' $containerd_config_file | ||
systemctl restart containerd | ||
fi | ||
} | ||
|
||
main() { | ||
cmd="$1" | ||
|
||
if !(grep -q "$pod_annotations_match" "$containerd_config_file"); then | ||
die "'$containerd_config_file' is missing expected pod annotations; check that Kata is set up with kata-deploy" | ||
fi | ||
|
||
case "$cmd" in | ||
configure ) configure_annotation ;; | ||
unconfigure ) unconfigure_annotation ;; | ||
*) die "invalid command: '$cmd'" ;; | ||
esac | ||
} | ||
|
||
main "$@" |