This repository has been archived by the owner on Nov 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
vamp-bootstrap.sh
executable file
·109 lines (86 loc) · 2.52 KB
/
vamp-bootstrap.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env bash
# check if kubernetes is installed
if ! type kubectl > /dev/null; then
echo "kubectl is not installed"
exit
fi
VERSION="magneticio/vamp2:0.7.0"
POSITIONAL=()
OUTCLUSTER=false
EXTERNALDB=false
DBURL="mongodb://mongo-0.vamp-mongodb:27017,mongo-1.vamp-mongodb:27017,mongo-2.vamp-mongodb:27017"
DBNAME="vamp"
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
--externaldb)
EXTERNALDB=true
shift # past argument
;;
--dburl)
DBURL="$2"
shift # past argument
shift # past value
;;
--dbname)
DBNAME="$2"
shift # past argument
shift # past value
;;
--outcluster)
OUTCLUSTER=true
shift # past argument
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
# Read Password
echo "A password needed for the default user (root) to be used in the UI."
echo "This password will be set as your root user password"
echo "Password will be asked twice and it will not be visible while typing"
echo "please enter the password for root user"
echo -n Password:
read -s password1
echo
echo "please re enter the same password"
echo -n Password:
read -s password2
echo
if [ $password1 != $password2 ]; then
echo "passwords do not match"
exit
fi
# sed with password
encodedpassword=$(echo -n $password1 | base64)
echo $DBURL
echo $DBNAME
if !($OUTCLUSTER); then
mkdir temp
sed -e 's,VAMP_VERSION,'${VERSION}',g' -e 's/VAMP_MODE/IN_CLUSTER/g' -e 's/VAMP_ROOT_PASSWORD/'${encodedpassword}'/g' -e 's;VAMP_DB_URL;'${DBURL}';g' -e 's,VAMP_DB_NAME,'${DBNAME}',g' ./templates/vamp-in-cluster-template.yaml > ./temp/vamp-in-cluster.yaml
kubectl create -f ./templates/vamp-namespace-in-cluster.yaml
if !($EXTERNALDB); then
echo "Setting up database"
kubectl create -f ./templates/vamp-db-in-cluster.yaml
fi
kubectl create -f ./temp/vamp-in-cluster.yaml
while true
do
echo "Waiting for ingress to be ready ..."
sleep 10
ip=$(kubectl describe svc vamp -n vamp-system | grep "LoadBalancer Ingress:" | awk '{print $3}')
echo $ip
if [ $ip ]; then
echo "use http://$ip:8888/ui/#/login to connect"
break
fi
done
else
docker run -d --rm --name=vamp -e MODE=OUTSIDE_CLUSTER -e HAZELCAST_SYNCH=false -e ROOT_PASSWORD=${password1} -e DBURL=${DBURL} -e DBNAME=${DBNAME} -p 8888:8888 $VERSION
sleep 5
echo "http://localhost:8888/ui/#/login"
fi