aboutsummaryrefslogtreecommitdiffstats
path: root/sdc-os-chef/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/templates/default/create_dox_keyspace.sh.erb
blob: f65bb945f3ea07f9de3a80c92a0fc84561724888 (plain)
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
#!/bin/bash

CASSANDRA_USER=asdc_user
CASSANDRA_PASS='Aa1234%^!'

KEYSPACE="CREATE KEYSPACE IF NOT EXISTS dox WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', '<%= @DC_NAME %>': '1'};"
KEYSPACE1="CREATE KEYSPACE IF NOT EXISTS zusammen_dox WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', '<%= @DC_NAME %>': '1'};"

echo "run create_dox_keyspace.cql"
echo -e "$KEYSPACE\n$KEYSPACE1" > /tmp/create_dox_keyspace.cql

chmod 755 /tmp/create_dox_keyspace.cql
cqlsh -u $CASSANDRA_USER -p $CASSANDRA_PASS -f /tmp/create_dox_keyspace.cql > /dev/null 2>&1


res=`echo "select keyspace_name from system.schema_keyspaces ;" | cqlsh -u $CASSANDRA_USER -p $CASSANDRA_PASS |grep -c dox 2>/dev/null`

if [ $res -gt 0 ]; then
        echo "`date` --- dox keyspace was created "
else
        echo "`date` --- Failed to create dox keyspace"
fi


echo "run create_dox_db.cql"
chmod 755 /tmp/create_dox_db.cql
cqlsh -u $CASSANDRA_USER -p $CASSANDRA_PASS -f /tmp/create_dox_db.cql > /dev/null 2>&1

sleep 10

echo "run alter_dox_db.cql"
chmod 755 /tmp/alter_dox_db.cql
cqlsh -u $CASSANDRA_USER -p $CASSANDRA_PASS -f /tmp/alter_dox_db.cql > /dev/null 2>&1