4 # Removal for issues with Kubernetes - Need to make sure any injected files
5 # Are chown 664 or ID is smae ID as Cassandra in Container.
6 #for f in /docker-entrypoint-initdb.d/*.cql; do
7 # chown cassandra.root "$f"
11 # first arg is `-f` or `--some-option`
12 # or there are no args
13 if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
14 set -- cassandra -f "$@"
17 # allow the container to be started with `--user`
18 if [ "$1" = 'cassandra' -a "$(id -u)" = '0' ]; then
19 chown -R cassandra /var/lib/cassandra /var/log/cassandra "$CASSANDRA_CONFIG"
20 exec gosu cassandra "$BASH_SOURCE" "$@"
23 if [ "$1" = 'cassandra' ]; then
24 : ${CASSANDRA_RPC_ADDRESS='0.0.0.0'}
26 : ${CASSANDRA_LISTEN_ADDRESS='auto'}
27 if [ "$CASSANDRA_LISTEN_ADDRESS" = 'auto' ]; then
28 CASSANDRA_LISTEN_ADDRESS="$(hostname --ip-address)"
31 : ${CASSANDRA_BROADCAST_ADDRESS="$CASSANDRA_LISTEN_ADDRESS"}
33 if [ "$CASSANDRA_BROADCAST_ADDRESS" = 'auto' ]; then
34 CASSANDRA_BROADCAST_ADDRESS="$(hostname --ip-address)"
36 : ${CASSANDRA_BROADCAST_RPC_ADDRESS:=$CASSANDRA_BROADCAST_ADDRESS}
38 if [ -n "${CASSANDRA_NAME:+1}" ]; then
39 : ${CASSANDRA_SEEDS:="cassandra"}
41 : ${CASSANDRA_SEEDS:="$CASSANDRA_BROADCAST_ADDRESS"}
43 sed -ri 's/(- seeds:).*/\1 "'"$CASSANDRA_SEEDS"'"/' "$CASSANDRA_CONFIG/cassandra.yaml"
47 broadcast_rpc_address \
55 var="CASSANDRA_${yaml^^}"
58 sed -ri 's/^(# )?('"$yaml"':).*/\2 '"$val"'/' "$CASSANDRA_CONFIG/cassandra.yaml"
62 for rackdc in dc rack; do
63 var="CASSANDRA_${rackdc^^}"
66 sed -ri 's/^('"$rackdc"'=).*/\1 '"$val"'/' "$CASSANDRA_CONFIG/cassandra-rackdc.properties"
71 echo "Updating username and password"
72 for f in /docker-entrypoint-initdb.d/music*.cql; do
73 if [ "${CASSUSER}" ]; then
74 sed -ri 's/CASSUSER/'${CASSUSER}'/' "$f"
76 if [ "${CASSPASS}" ]; then
77 sed -ri 's/CASSPASS/'${CASSPASS}'/' "$f"
80 echo "Updating username and password - Complete"
85 echo "################################ Let run cql's ##############################"
86 for f in /docker-entrypoint-initdb.d/*; do
90 echo "$0: running $f" && until cqlsh -u cassandra -p cassandra -f "$f"; do >&2 echo "Cassandra is unavailable - sleeping"; sleep 2; done & ;;
91 *) echo "$0: ignoring $f" ;;