-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathentrypoint.sh
executable file
·49 lines (44 loc) · 976 Bytes
/
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
SEARCH_TEXT=${SEARCH_TEXT:-kong}
ARGUMENTS=( "$@" )
while :
do
case "$1" in
--path )
CONFIG_FILE=$2
shift 2
;;
--host )
HOST=$2
shift 2
;;
*)
if [ "$1" == "" ]; then
break
fi
shift
;;
esac
done
if [ -n "$CONFIG" ]; then
>&2 echo "Writing $CONFIG_FILE from the \$CONFIG environment variable"
echo "$CONFIG" > "$CONFIG_FILE"
if [ "true" == "$DEBUG" ]; then
cat "$CONFIG_FILE"
fi
fi
COUNTER=0
>&2 echo -n "waiting for $HOST to start up..."
trap 'exit' INT
while [ $COUNTER -lt ${CHECK_ATTEMPTS} ]; do
let COUNTER=COUNTER+1
if `curl -s $HOST | grep -q -i "$SEARCH_TEXT"`; then
>&2 echo "started"
sleep ${POST_START_DELAY}
kongfig "${ARGUMENTS[@]}"
exit $?
else
echo -n "."
fi
sleep ${BETWEEN_CHECK_DELAY}
done