4 # first arg is `-f` or `--some-option`
6 if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
7 set -- cassandra -f "$@"
10 # allow the container to be started with `--user`
11 if [ "$1" = 'cassandra' -a "$(id -u)" = '0' ]; then
12 chown -R cassandra /var/lib/cassandra /var/log/cassandra "$CASSANDRA_CONFIG"
13 exec gosu cassandra "$BASH_SOURCE" "$@"
16 if [ "$1" = 'cassandra' ]; then
17 : ${CASSANDRA_RPC_ADDRESS='0.0.0.0'}
19 : ${CASSANDRA_LISTEN_ADDRESS='auto'}
20 if [ "$CASSANDRA_LISTEN_ADDRESS" = 'auto' ]; then
21 CASSANDRA_LISTEN_ADDRESS="$(hostname --ip-address)"
24 : ${CASSANDRA_BROADCAST_ADDRESS="$CASSANDRA_LISTEN_ADDRESS"}
26 if [ "$CASSANDRA_BROADCAST_ADDRESS" = 'auto' ]; then
27 CASSANDRA_BROADCAST_ADDRESS="$(hostname --ip-address)"
29 : ${CASSANDRA_BROADCAST_RPC_ADDRESS:=$CASSANDRA_BROADCAST_ADDRESS}
31 if [ -n "${CASSANDRA_NAME:+1}" ]; then
32 : ${CASSANDRA_SEEDS:="cassandra"}
34 : ${CASSANDRA_SEEDS:="$CASSANDRA_BROADCAST_ADDRESS"}
36 sed -ri 's/(- seeds:).*/\1 "'"$CASSANDRA_SEEDS"'"/' "$CASSANDRA_CONFIG/cassandra.yaml"
40 broadcast_rpc_address \
48 var="CASSANDRA_${yaml^^}"
51 sed -ri 's/^(# )?('"$yaml"':).*/\2 '"$val"'/' "$CASSANDRA_CONFIG/cassandra.yaml"
55 for rackdc in dc rack; do
56 var="CASSANDRA_${rackdc^^}"
59 sed -ri 's/^('"$rackdc"'=).*/\1 '"$val"'/' "$CASSANDRA_CONFIG/cassandra-rackdc.properties"
63 echo "################################ Let run Scripts ##############################"
64 for f in /docker-entrypoint-initdb.d/*; do
66 *.cql) echo "$0: running $f" && until cqlsh -u cassandra -p cassandra -f "$f"; do >&2 echo "Cassandra is unavailable - sleeping"; sleep 2; done & ;;
67 *) echo "$0: ignoring $f" ;;
71 echo "################################ Let run Scripts End ##############################"