forked from confidential-containers/guest-components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcdh-start.sh
executable file
·56 lines (48 loc) · 1.09 KB
/
cdh-start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
set -euo pipefail
set -o noglob
# Initialize parameters
trustee_address=''
key_id=''
resource_path=''
usage() {
echo "This script is used to start Attestation Agent" 1>&2
echo "" 1>&2
echo "Usage: $0 --trustee-addr Address of remote trustee" 1>&2
echo "--key-id the id of the confidential resource from trustee" 1>&2
echo "--resource-path the file path that will store the confidential resource" 1>&2
exit 1
}
# Parse cmd
while [[ "$#" -gt 0 ]]; do
case "$1" in
--trustee-addr)
trustee_address="$2"
shift 2
;;
--key-id)
key_id="$2"
shift 2
;;
--resource-path)
resource_path="$2"
shift 2
;;
-h|--help)
usage
;;
*)
echo "Unknown option: $1"
usage
;;
esac
done
cat << EOF > /etc/confidential-data-hub.toml
socket = "unix:///run/confidential-containers/cdh.sock"
[kbc]
name = "cc_kbc"
url = "${trustee_address}"
EOF
blob=$(confidential-data-hub -c /etc/confidential-data-hub.toml get-resource --resource-uri "${key_id}")
echo "$blob" | base64 -d > "$resource_path"
sleep 100000000