-
Notifications
You must be signed in to change notification settings - Fork 524
/
generate_entrypoint.sh
executable file
·49 lines (42 loc) · 1.72 KB
/
generate_entrypoint.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
#!/bin/bash
set -e
source /opt/ceph-container/bin/variables_entrypoint.sh
# FUNCTIONS
function moving_on {
echo "INFO: moving on, using default entrypoint.sh.in file as is."
mv /opt/ceph-container/bin/entrypoint.sh.in /opt/ceph-container/bin/entrypoint.sh
exit 0
}
function check_scenario_file {
if [ -s /opt/ceph-container/bin/disabled_scenario ]; then
source /opt/ceph-container/bin/disabled_scenario
if [[ -z "$EXCLUDED_TAGS" ]]; then
echo "INFO: the variable EXCLUDED_TAGS is missing from the disabled_scenario file."
moving_on
fi
else
# (leseb): it is obviously empty since we add it as part of the Dockerfile ADD statement
# If we end up here, the file has been added but is empty (size non-greater than 0)
echo "INFO: disabled_scenario file is empty, no scenario to disable."
moving_on
fi
}
function build_sed_regex {
for tag in $EXCLUDED_TAGS; do
SED_LINE="s/# TAG: $tag/unsupported_scenario/g; ${SED_LINE}"
ALL_SCENARIOS="${ALL_SCENARIOS/$tag /}"
# If it's the last of the chain there is no space after it so the previous substitution missed it
ALL_SCENARIOS="${ALL_SCENARIOS/$tag/}"
done
# Remove trailing whitespace
ALL_SCENARIOS="${ALL_SCENARIOS% }"
}
# MAIN
check_scenario_file
build_sed_regex
sed -i "s/ALL_SCENARIOS=.*/ALL_SCENARIOS='${ALL_SCENARIOS}'/" /opt/ceph-container/bin/variables_entrypoint.sh
sed "${SED_LINE}" /opt/ceph-container/bin/entrypoint.sh.in > /opt/ceph-container/bin/entrypoint.sh
echo "INFO: entrypoint.sh successfully generated."
echo "INFO: the following scenario(s) was/were disabled: $EXCLUDED_TAGS."
chmod +x /opt/ceph-container/bin/entrypoint.sh
rm -f /opt/ceph-container/bin/entrypoint.sh.in /opt/ceph-container/bin/disabled_scenario