aboutsummaryrefslogtreecommitdiffstats
path: root/workflow-designer-init/src/main/docker/start.sh
blob: 8acb2cf6d2efb215e114e25806533c1268124eec (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
35
36
37
38
#!/bin/sh

is_cs_unauthenticated=1
FALSE=0
if [[ -z "${CS_AUTHENTICATE}" || "${CS_AUTHENTICATE}" == "false" ]]; then
	is_cs_unauthenticated=$FALSE
fi

if [ $is_cs_unauthenticated -eq $FALSE ]; then
	echo "Establishing unsecured connection to Cassandra"
fi

if [[ $is_cs_unauthenticated -eq 1 &&  -z "${CS_USER}" ]]; then
	echo "CS_USER environment variable must be set"
	exit 1
fi

if [[ $is_cs_unauthenticated -eq 1 &&  -z "${CS_PASSWORD}" ]]; then
	echo "CS_PASSWORD environment variable must be set"
	exit 1
fi

if [[ -z "${CS_HOST}" ]]; then
	echo "CS_HOST environment variable must be set"
	exit 1
fi

cql_from_file() {

    if [ $is_cs_unauthenticated -eq 1 ]; then
        cqlsh -u ${CS_USER} -p ${CS_PASSWORD} -f $1 ${CS_HOST} ${CS_PORT}
    else
        cqlsh -f $1 ${CS_HOST} ${CS_PORT}
    fi
}

cql_from_file /create_keyspaces.cql
cql_from_file /create_tables.cql