1
- #! /bin/bash
1
+ #! /bin/sh
2
2
#
3
3
# # This entrypoint wraps up the container preparation with the agent spawning and the key shipping.
4
4
#
@@ -10,6 +10,7 @@ docker_path="/var/run/docker.sock"
10
10
parse_args () {
11
11
while [[ " $# " -gt 0 ]]; do
12
12
case " $1 " in
13
+ --config) config=" $2 " ; shift 2 ;;
13
14
-b|--base-oci-image) base_oci_image=" $2 " ; shift 2 ;;
14
15
-s|--sif-path) sif_path=" $2 " ; shift 2 ;;
15
16
-e|--encrypted) encrypted=true; shift ;;
@@ -26,7 +27,7 @@ parse_args() {
26
27
done
27
28
28
29
# Check for required arguments
29
- if [ -z " $base_oci_image " ] || [ -z " $sif_path " ] || [ -z " $data_path " ] || [ -z " $data_path_at_rest " ] || ( [ -z " $users " ] && [ -z " $groups " ] ) || [ -z " $compute_nodes " ]; then
30
+ if [ -z " $config " ] || [ -z " $ base_oci_image" ] || [ -z " $sif_path " ] || [ -z " $data_path " ] || [ -z " $data_path_at_rest " ] || ( [ -z " $users " ] && [ -z " $groups " ] ) || [ -z " $compute_nodes " ]; then
30
31
echo echo " Please provides options for both of these programs : "
31
32
python3 ./prepare_container.py --help
32
33
python3 ./utils/ship_a_key.py --help
@@ -66,11 +67,14 @@ echo -e "${YELLOW}[LUMI-SD]${NC}${BLUE}[Container preparation]${NC} Entering ent
66
67
if [ -n " $encrypted " ]; then
67
68
echo -e " ${YELLOW} [LUMI-SD]${NC}${BLUE} [Container preparation]${NC} Encryption mode is on. Registering and running SPIRE Agent"
68
69
69
- python3 ./utils/spawn_agent.py > /dev/null 2> /dev/null || exit 1 &
70
+ python3 ./utils/spawn_agent.py --config $config > /dev/null 2> /dev/null &
70
71
spire_agent_pid=$!
71
72
72
73
fi
73
74
75
+
76
+ ps $spire_agent_pid > /dev/null || ( echo " spire agent died, aborting" ; end_entrypoint " $spire_agent_pid " 1)
77
+
74
78
#
75
79
# # [END] Perform node attestation
76
80
#
@@ -110,13 +114,13 @@ else
110
114
111
115
if [ -z " $users " ]; then
112
116
# If the user provided only groups
113
- python3 ./utils/ship_a_key.py --username " $username " -g " $groups " -c " $compute_nodes " --data-path " $data_path " --data-path-at-rest " $data_path_at_rest " -i " $spiffeID " || end_entrypoint " $spire_agent_pid " 1
117
+ python3 ./utils/ship_a_key.py --config $config -- username " $username " -g " $groups " -c " $compute_nodes " --data-path " $data_path " --data-path-at-rest " $data_path_at_rest " -i " $spiffeID " || end_entrypoint " $spire_agent_pid " 1
114
118
elif [ -z " $groups " ] ; then
115
119
# If the user provided only users
116
- python3 ./utils/ship_a_key.py --username " $username " -u " $users " -c " $compute_nodes " --data-path " $data_path " --data-path-at-rest " $data_path_at_rest " -i " $spiffeID " || end_entrypoint " $spire_agent_pid " 1
120
+ python3 ./utils/ship_a_key.py --config $config -- username " $username " -u " $users " -c " $compute_nodes " --data-path " $data_path " --data-path-at-rest " $data_path_at_rest " -i " $spiffeID " || end_entrypoint " $spire_agent_pid " 1
117
121
else
118
122
# If the user provided both
119
- python3 ./utils/ship_a_key.py --username " $username " -u " $users " -g " $groups " -c " $compute_nodes " --data-path " $data_path " --data-path-at-rest " $data_path_at_rest " -i " $spiffeID " || end_entrypoint " $spire_agent_pid " 1
123
+ python3 ./utils/ship_a_key.py --config $config -- username " $username " -u " $users " -g " $groups " -c " $compute_nodes " --data-path " $data_path " --data-path-at-rest " $data_path_at_rest " -i " $spiffeID " || end_entrypoint " $spire_agent_pid " 1
120
124
fi
121
125
122
126
echo -e " ${YELLOW} [LUMI-SD]${NC}${BLUE} [Container preparation]${NC} Key written to the vault"
0 commit comments