-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathplanb-cassandra.sh
executable file
·55 lines (44 loc) · 1.41 KB
/
planb-cassandra.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/sh
# CLUSTER_NAME
# DATA_DIR
# COMMIT_LOG_DIR
# LISTEN_ADDRESS
if [ -z "$CLUSTER_NAME" ] ;
then
echo "Cluster name is not defined."
exit 1
fi
if [ -z "$LISTEN_ADDRESS" ] ;
then
export LISTEN_ADDRESS=$(curl -Ls -m 4 http://169.254.169.254/latest/meta-data/local-ipv4)
fi
echo "Node IP address is $LISTEN_ADDRESS ..."
while [ -z "$BROADCAST_ADDRESS" ] ;
do
echo "Waiting for Public IP address to be assigned ..."
export BROADCAST_ADDRESS=$(curl -Ls -m 4 http://169.254.169.254/latest/meta-data/public-ipv4)
sleep 5
done
echo "Public IP address is $BROADCAST_ADDRESS ..."
if [ -z $SNITCH ] ;
then
export SNITCH="Ec2MultiRegionSnitch"
fi
export DATA_DIR=${DATA_DIR:-/var/lib/cassandra}
export COMMIT_LOG_DIR=${COMMIT_LOG_DIR:-/var/lib/cassandra/commit_logs}
if [ -z "$TRUSTSTORE" ]; then
echo "TRUSTSTORE must be set (base64 encoded)."
exit 1
fi
if [ -z "$KEYSTORE" ]; then
echo "KEYSTORE must be set (base64 encoded)."
exit 1
fi
echo $TRUSTSTORE | base64 -d > /etc/cassandra/truststore
echo $KEYSTORE | base64 -d > /etc/cassandra/keystore
echo "Finished bootstrapping node."
# Add route 53record seed1.${CLUSTER_NAME}.domain.tld ?
echo "Generating configuration from template ..."
python -c "import sys, os; sys.stdout.write(os.path.expandvars(open('/etc/cassandra/cassandra_template.yaml').read()))" > /etc/cassandra/cassandra.yaml
echo "Starting Cassandra ..."
/usr/sbin/cassandra -f