@@ -8,7 +8,7 @@ docker_path="/var/run/docker.sock"
8
8
9
9
# Argument parser, arguments for both container preparation and key shipping should be handled here.
10
10
parse_args () {
11
- while [[ " $# " -gt 0 ] ]; do
11
+ while [ " ${ # } " -gt 0 ]; do
12
12
case " $1 " in
13
13
--config)
14
14
config=" $2 "
@@ -69,7 +69,7 @@ parse_args() {
69
69
done
70
70
71
71
# Check for required arguments
72
- 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
72
+ 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
73
73
echo echo " Please provides options for both of these programs : "
74
74
python3 ./prepare_container.py --help
75
75
python3 ./utils/ship_a_key.py --help
@@ -79,7 +79,7 @@ parse_args() {
79
79
80
80
# Cleanup spire-agent generated files
81
81
end_entrypoint () {
82
- if ! [ -n " $encrypted " ]; then
82
+ if [ -z " $encrypted " ]; then
83
83
echo " No encryption, nothing to clean"
84
84
else
85
85
echo " Cleaning everything before leaving ..."
@@ -100,21 +100,21 @@ NC='\033[0m' # No Color
100
100
# Parse arguments from cli
101
101
parse_args " $@ "
102
102
103
- echo -e " ${YELLOW} [LUMI-SD]${NC}${BLUE} [Container preparation]${NC} Entering entrypoint"
103
+ printf " %b\n " " ${YELLOW} [LUMI-SD]${NC}${BLUE} [Container preparation]${NC} Entering entrypoint"
104
104
105
105
#
106
106
# # [RUN] Perform node attestation (spawn agent, register it's and it's workload's spiffeID)
107
107
#
108
108
109
109
if [ -n " $encrypted " ]; then
110
- echo -e " ${YELLOW} [LUMI-SD]${NC}${BLUE} [Container preparation]${NC} Encryption mode is on. Registering and running SPIRE Agent"
110
+ printf " %b\n " " ${YELLOW} [LUMI-SD]${NC}${BLUE} [Container preparation]${NC} Encryption mode is on. Registering and running SPIRE Agent"
111
111
112
- python3 ./utils/spawn_agent.py --config $config > /dev/null 2> /dev/null &
112
+ python3 ./utils/spawn_agent.py --config " $config " > /dev/null 2> /dev/null &
113
113
spire_agent_pid=$!
114
114
115
115
fi
116
116
117
- ps $spire_agent_pid > /dev/null || (
117
+ ps " $spire_agent_pid " > /dev/null || (
118
118
echo " spire agent died, aborting"
119
119
end_entrypoint " $spire_agent_pid " 1
120
120
)
@@ -123,7 +123,7 @@ ps $spire_agent_pid >/dev/null || (
123
123
# # [END] Perform node attestation
124
124
#
125
125
126
- echo -e " ${YELLOW} [LUMI-SD]${NC}${BLUE} [Container preparation]${NC} Run container preparation"
126
+ printf " %b\n " " ${YELLOW} [LUMI-SD]${NC}${BLUE} [Container preparation]${NC} Run container preparation"
127
127
128
128
#
129
129
# # [RUN] Run container preparation (Preparation of new image, build of new image, build of Apptainer/Singularity image)
139
139
# # [END] Run container preparation
140
140
#
141
141
142
- echo -e " ${YELLOW} [LUMI-SD]${NC}${BLUE} [Container preparation]${NC} Container preparation ended"
142
+ printf " %b\n " " ${YELLOW} [LUMI-SD]${NC}${BLUE} [Container preparation]${NC} Container preparation ended"
143
143
144
144
#
145
145
# # [RUN] Ship private key to the vault (Creation of workload identity to give access to the key, writing key to the vault)
@@ -150,29 +150,29 @@ if [ -n "$encrypted" ]; then
150
150
fi
151
151
152
152
if [ -z " $encrypted " ]; then
153
- echo -e " ${YELLOW} [LUMI-SD]${NC}${BLUE} [Container preparation]${NC} Encryption mode is off, nothing to do"
153
+ printf " %b\n " " ${YELLOW} [LUMI-SD]${NC}${BLUE} [Container preparation]${NC} Encryption mode is off, nothing to do"
154
154
155
155
else
156
- echo -e " ${YELLOW} [LUMI-SD]${NC}${BLUE} [Container preparation]${NC} Encryption mode is on, writing key to the vault, using spiffeID $spiffeID "
156
+ printf " %b\n " " ${YELLOW} [LUMI-SD]${NC}${BLUE} [Container preparation]${NC} Encryption mode is on, writing key to the vault, using spiffeID $spiffeID "
157
157
158
158
if [ -z " $users " ]; then
159
159
# If the user provided only groups
160
- 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
160
+ 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
161
161
elif [ -z " $groups " ]; then
162
162
# If the user provided only users
163
- 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
163
+ 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
164
164
else
165
165
# If the user provided both
166
- 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
166
+ 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
167
167
fi
168
168
169
- echo -e " ${YELLOW} [LUMI-SD]${NC}${BLUE} [Container preparation]${NC} Key written to the vault"
169
+ printf " %b\n " " ${YELLOW} [LUMI-SD]${NC}${BLUE} [Container preparation]${NC} Key written to the vault"
170
170
fi
171
171
172
172
#
173
173
# # [END] Ship private key to the vault
174
174
#
175
175
176
- echo -e " ${YELLOW} [LUMI-SD]${NC}${BLUE} [Container preparation]${NC} Leaving entrypoint"
176
+ printf " %b\n " " ${YELLOW} [LUMI-SD]${NC}${BLUE} [Container preparation]${NC} Leaving entrypoint"
177
177
178
178
end_entrypoint " $spire_agent_pid " 0
0 commit comments