-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sh
executable file
·32 lines (28 loc) · 930 Bytes
/
init.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
#!/bin/bash
echo "$0: forked off"
set -e # if one init command fails - everything fails
function hang_until_cassandra_is_ready () {
# We check nodetool until we get a report that Cassandra status is Up and Normal
until [[ $CASS_STATUS == "UN" ]]; do
sleep 1;
echo "$0: checking if Cassandra is up already..."
CASS_STATUS=`nodetool status | tail --lines=2 | cut --bytes=1-2`
done
echo "$0: Cassandra appears to be Up and Normal, proceeding..."
# Needs more hanging here!
sleep 30
}
function run_init_stuff () {
for f in /docker-entrypoint-init.d/*; do
case "$f" in
*.sh) echo "$0: running $f"; . "$f" ;;
*.cql) echo "$0: running $f"; cqlsh < "$f"; echo ;;
*.cql.gz) echo "$0: running $f"; gunzip -c "$f" | cqlsh; echo ;;
*) echo "$0: ignoring $f" ;;
esac
echo
done
echo "$0: Initialization complete."
}
hang_until_cassandra_is_ready
run_init_stuff