forked from borntorock/CassandraBrowserTool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddnode.sh
74 lines (53 loc) · 1.4 KB
/
addnode.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
67
68
69
70
71
#!/bin/sh
# Firstly to install the packages on the machine
# Assuming the user is loginned as Super-User and if not login then it will ask for sudo access
# Installing required libraries :: pycassa, flask
apt-get install python-pycassa
for i in python-pycassa python-flask; do
sudo apt-get install $i
done
echo
echo Pycassa API and Flask API Installed
echo
echo
# Installing cassandra server
sudo apt-get install cassandra
echo
echo Cassandra Server Installed
echo
echo
# Running cassandra server
cassandra -f # run in backend
echo
echo Cassandra Running
echo
echo
# Check whether Cassandra server is running or not on the added node
check_process(){
# check the args
if [ "$1" = "cassandra" ];
then
return 0
fi
PROCESS_NUM='ps -ef | grep "$1" | grep -v "grep"'
$PROCESS_NUM
if [ $PROCESS_NUM -eq 1 ];
then
return 1
else
return 0
fi
}
# to open the file cassandra.yaml on the added node
filename='cassandra.yaml' # Specify the complete path of cassandra.yaml file
# to make the desired changes in the cassandra.yaml file
while read line
do
string=`echo $line`
IFS=':' read -a array <<< "$string"
first=`echo "${array[0]}"`
cluster=`echo $line`
echo $cluster
sed -i "/$first/c\\$cluster" $filename
done < input
# to run another script to generate hashes # this has to be checked up