forked from qualimente/gremlins
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·55 lines (48 loc) · 1.33 KB
/
entrypoint.sh
File metadata and controls
executable file
·55 lines (48 loc) · 1.33 KB
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
#!/bin/sh
#
# Validate input:
# ENTROPY_FAILURES
# - present
# - valid and defined by image
# ENTROPY_FREQUENCY
# - present
# - in whole seconds
# ENTROPY_PROBABILITY
# - present
# - decimal less than or equal to 1
#
if [ -z "$ENTROPY_PROBABILITY" ]; then
echo >&2 '[ERROR]: specify ENTROPY_PROBABILITY environment variable'
exit 1
fi
if [ -z "$ENTROPY_FREQUENCY" ]; then
echo >&2 '[ERROR]: specify ENTROPY_FREQUENCY environment variable'
exit 1
fi
if [ -z "$ENTROPY_FAILURES" ]; then
echo >&2 '[ERROR]: specify ENTROPY_FAILURES environment variable'
exit 1
fi
case $ENTROPY_FAILURES in
"packet_loss"|"partition"|"packet_reordering"|"latency")
;;
*)
echo >&2 '[ERROR]: This image only supports one of the following failures: "network_packet_loss", "network_partition", "packet_reordering", or "network_latency"'
exit 1
;;
esac
#
# Generate profile
#
ENTROPY_CLEAR_WEIGHT="$(echo 1 - $ENTROPY_PROBABILITY | bc)"
ENTROPY_FAILURE_WEIGHT=$ENTROPY_PROBABILITY
cat profile.tmpl | \
sed "s/ENTROPY_SECONDS/${ENTROPY_FREQUENCY}/" | \
sed "s/ENTROPY_FAILURE_WEIGHT/${ENTROPY_FAILURE_WEIGHT}/" | \
sed "s/ENTROPY_CLEAR_WEIGHT/${ENTROPY_CLEAR_WEIGHT}/" | \
sed "s/ENTROPY_FAILURE/${ENTROPY_FAILURES}/" \
> ./gremlins/profiles/entropy.py
#
# Start gremlins
#
exec "$@" # run the default command