-
Notifications
You must be signed in to change notification settings - Fork 69
/
entrypoint.sh
executable file
·83 lines (66 loc) · 2.12 KB
/
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env bash
set -Eeuo pipefail
export FEATURE_KEY_FILE=${FEATURE_KEY_FILE:-"/etc/aerospike/features.conf"}
export LOGFILE=${LOGFILE:-""}
export SERVICE_ADDRESS=${SERVICE_ADDRESS:-any}
export SERVICE_PORT=${SERVICE_PORT:-3000}
export NAMESPACE=${NAMESPACE:-test}
export DATA_IN_MEMORY=${DATA_IN_MEMORY:-false}
export DEFAULT_TTL=${DEFAULT_TTL:-30d}
export MEM_GB=${MEM_GB:-1}
export NSUP_PERIOD=${NSUP_PERIOD:-120}
export STORAGE_GB=${STORAGE_GB:-4}
if [ "${DATA_IN_MEMORY}" = "true" ]; then
export READ_PAGE_CACHE="false"
else
export READ_PAGE_CACHE="true"
fi
if asd --version | grep -q "Community"; then
FEATURE_KEY_FILE="" # invalid for community edition
fi
function bash_eval_template() {
local template_file=$1
local target_file=$2
echo "" >"${target_file}"
while IFS= read -r line; do
if grep -qE "[$][(]|[{]" <<<"${line}"; then
local update
update=$(eval echo "\"${line}\"") || exit 1
grep -qE "[^[:space:]]*" <<<"${update}" && echo "${update}" >>"${target_file}"
else
echo "${line}" >>"${target_file}"
fi
done <"${template_file}"
# Ignore failure when template is mounted in a read-only filesystem.
rm "${template_file}" || true
}
# Fill out conffile with above values
if [ -f /etc/aerospike/aerospike.template.conf ]; then
conf=/etc/aerospike/aerospike.conf
template=/etc/aerospike/aerospike.template.conf
bash_eval_template "${template}" "${conf}"
fi
# if command starts with an option, prepend asd
if [ "${1:0:1}" = '-' ]; then
set -- asd "$@"
fi
# if asd is specified for the command, start it with any given options
if [ "$1" = 'asd' ]; then
NETLINK=${NETLINK:-eth0}
# We will wait a bit for the network link to be up.
NETLINK_UP=0
NETLINK_COUNT=0
echo "link ${NETLINK} state $(cat /sys/class/net/"${NETLINK}"/operstate)"
while [ ${NETLINK_UP} -eq 0 ] && [ ${NETLINK_COUNT} -lt 20 ]; do
if grep -q "up" /sys/class/net/"${NETLINK}"/operstate; then
NETLINK_UP=1
else
sleep 0.1
((++NETLINK_COUNT))
fi
done
echo "link ${NETLINK} state $(cat /sys/class/net/"${NETLINK}"/operstate) in ${NETLINK_COUNT}"
# asd should always run in the foreground.
set -- "$@" --foreground
fi
exec "$@"