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 find /var/lib/cassandra /var/log/cassandra "$CASSANDRA_CONFIG" \
13 \! -user cassandra -exec chown cassandra '{}' +
14 exec gosu cassandra "$BASH_SOURCE" "$@"
18 # scrape the first non-localhost IP address of the container
19 # in Swarm Mode, we often get two IPs -- the container IP, and the (shared) VIP, and the container IP should always be first
21 $1 == "inet" && $NF != "lo" {
29 # "sed -i", but without "mv" (which doesn't work on a bind-mounted file, for example)
31 local filename="$1"; shift
34 sed "$@" "$filename" > "$tempFile"
35 cat "$tempFile" > "$filename"
39 if [ "$1" = 'cassandra' ]; then
40 : ${CASSANDRA_RPC_ADDRESS='0.0.0.0'}
42 : ${CASSANDRA_LISTEN_ADDRESS='auto'}
43 if [ "$CASSANDRA_LISTEN_ADDRESS" = 'auto' ]; then
44 CASSANDRA_LISTEN_ADDRESS="$(_ip_address)"
47 : ${CASSANDRA_BROADCAST_ADDRESS="$CASSANDRA_LISTEN_ADDRESS"}
49 if [ "$CASSANDRA_BROADCAST_ADDRESS" = 'auto' ]; then
50 CASSANDRA_BROADCAST_ADDRESS="$(_ip_address)"
52 : ${CASSANDRA_BROADCAST_RPC_ADDRESS:=$CASSANDRA_BROADCAST_ADDRESS}
54 if [ -n "${CASSANDRA_NAME:+1}" ]; then
55 : ${CASSANDRA_SEEDS:="cassandra"}
57 : ${CASSANDRA_SEEDS:="$CASSANDRA_BROADCAST_ADDRESS"}
59 _sed-in-place "$CASSANDRA_CONFIG/cassandra.yaml" \
60 -r 's/(- seeds:).*/\1 "'"$CASSANDRA_SEEDS"'"/'
64 broadcast_rpc_address \
73 var="CASSANDRA_${yaml^^}"
76 _sed-in-place "$CASSANDRA_CONFIG/cassandra.yaml" \
77 -r 's/^(# )?('"$yaml"':).*/\2 '"$val"'/'
81 for rackdc in dc rack; do
82 var="CASSANDRA_${rackdc^^}"
85 _sed-in-place "$CASSANDRA_CONFIG/cassandra-rackdc.properties" \
86 -r 's/^('"$rackdc"'=).*/\1 '"$val"'/'