forked from spring-projects/spring-data-cassandra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-cassandra.sh
executable file
·67 lines (52 loc) · 1.31 KB
/
setup-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
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env bash
if [ -z ${CASSANDRA_VERSION+x} ]; then
CASSANDRA_VERSION=3.11.12
fi
if [[ ! -d download ]] ; then
mkdir -p download
fi
FILENAME="apache-cassandra-${CASSANDRA_VERSION}-bin.tar.gz"
echo "[INFO] Downloading ${FILENAME}"
if [[ ! -f download/${FILENAME} ]] ; then
mkdir -p download
wget https://archive.apache.org/dist/cassandra/${CASSANDRA_VERSION}/${FILENAME} -O download/${FILENAME}
if [[ $? != 0 ]] ; then
echo "[ERROR] Download failed"
exit 1
fi
fi
if [[ ! -d work ]] ; then
mkdir -p work
fi
BASENAME=apache-cassandra-${CASSANDRA_VERSION}
if [[ ! -d work/${BASENAME} ]] ; then
echo "[INFO] Extracting ${FILENAME}"
mkdir -p work/${BASENAME}
cd work
tar xzf ../download/${FILENAME}
if [[ $? != 0 ]] ; then
echo "[ERROR] Extraction failed"
exit 1
fi
cd ..
fi
cd work/${BASENAME}
echo "[INFO] Cleaning data directory"
rm -Rf data
mkdir -p data
echo "[INFO] Starting Apache Cassandra ${CASSANDRA_VERSION}"
export MAX_HEAP_SIZE=1500M
export HEAP_NEWSIZE=300M
bin/cassandra
for start in {1..20}
do
nc -w 1 localhost 9042 </dev/null
if [[ $? == 0 ]] ; then
echo "[INFO] Cassandra is up and running"
cd ../..
exit 0
fi
sleep 1
done
echo "[ERROR] Cannot connect to Cassandra"
exit 1