5 # first arg is `-f` or `--some-option`
7 if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
8 set -- cassandra -f "$@"
11 # allow the container to be started with `--user`
12 if [ "$1" = 'cassandra' -a "$(id -u)" = '0' ]; then
13 find /var/lib/cassandra /var/log/cassandra "$CASSANDRA_CONFIG" \
14 \! -user cassandra -exec chown cassandra '{}' +
15 exec gosu cassandra "$0" "$@"
19 # scrape the first non-localhost IP address of the container
20 # in Swarm Mode, we often get two IPs -- the container IP, and the (shared) VIP, and the container IP should always be first
22 $1 == "inet" && $NF != "lo" {
30 # "sed -i", but without "mv" (which doesn't work on a bind-mounted file, for example)
36 sed "$@" "$filename" > "$tempFile"
37 cat "$tempFile" > "$filename"
41 if [ "$1" = 'cassandra' ]; then
42 : ${CASSANDRA_RPC_ADDRESS='0.0.0.0'}
44 : ${CASSANDRA_LISTEN_ADDRESS='auto'}
45 if [ "$CASSANDRA_LISTEN_ADDRESS" = 'auto' ]; then
46 CASSANDRA_LISTEN_ADDRESS="$(_ip_address)"
49 : ${CASSANDRA_BROADCAST_ADDRESS="$CASSANDRA_LISTEN_ADDRESS"}
51 if [ "$CASSANDRA_BROADCAST_ADDRESS" = 'auto' ]; then
52 CASSANDRA_BROADCAST_ADDRESS="$(_ip_address)"
54 : ${CASSANDRA_BROADCAST_RPC_ADDRESS:=$CASSANDRA_BROADCAST_ADDRESS}
56 if [ -n "${CASSANDRA_NAME:+1}" ]; then
57 : ${CASSANDRA_SEEDS:="cassandra"}
59 : ${CASSANDRA_SEEDS:="$CASSANDRA_BROADCAST_ADDRESS"}
61 _sed_in_place "$CASSANDRA_CONFIG/cassandra.yaml" \
62 -r 's/(- seeds:).*/\1 "'"$CASSANDRA_SEEDS"'"/'
66 broadcast_rpc_address \
75 var="CASSANDRA_$(echo $yaml | tr '[:lower:]' '[:upper:]')"
76 # eval presents no security issue here because of limited possible values of var
79 _sed_in_place "$CASSANDRA_CONFIG/cassandra.yaml" \
80 -r 's/^(# )?('"$yaml"':).*/\2 '"$val"'/'
84 for rackdc in dc rack; do
85 var="CASSANDRA_$(echo $rackdc | tr '[:lower:]' '[:upper:]')"
86 # eval presents no security issue here because of limited possible values of var
89 _sed_in_place "$CASSANDRA_CONFIG/cassandra-rackdc.properties" \
90 -r 's/^('"$rackdc"'=).*/\1 '"$val"'/'