-
Notifications
You must be signed in to change notification settings - Fork 0
/
nuodb-control-plane-setup.sh
executable file
·75 lines (67 loc) · 1.99 KB
/
nuodb-control-plane-setup.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
#!/bin/bash
# (C) Copyright 2024 Dassault Systemes SE. All Rights Reserved.
function checkError() {
RC=$?
if [ $RC -ne 0 ] ; then
echo "ERROR: $1, RC=$RC"
exit $RC
fi
}
function addRepo() {
if [ "`helm repo list | grep -e "^nuodb-cp"`" == "" ] ; then
echo "Adding Helm repo nuodb-cp"
helm repo add nuodb-cp https://nuodb.github.io/nuodb-cp-releases/charts
checkError "unable to add helm repo nuodb-cp"
fi
}
function deleteRepo() {
if [ "`helm repo list | grep -e "^nuodb-cp"`" != "" ] ; then
echo "Deleting Helm repo nuodb-cp"
helm repo remove nuodb-cp
checkError "unable to delete helm repo nuodb-cp"
fi
}
function helmInstall() {
if [ "`helm list | grep -e "^$1"`" == "" ] ; then
echo "Installing helm chart nuodb-cp/$1"
helm install --wait "$1" "nuodb-cp/$1"
checkError "unable to install helm chart nuodb-cp/$1"
fi
}
function helmUninstall() {
if [ "`helm list -a | grep -e "^$1"`" != "" ] ; then
echo "Uninstalling helm chart $1"
helm delete "$1"
checkError "unable to delete helm chart $1"
fi
}
function installTunnel() {
if [ "`ps -ef | grep -e "kubectl port-forward service/nuodb-cp-rest 8080:8080" | grep -v -e grep`" == "" ] ; then
echo "Installing Tunnel"
kubectl port-forward service/nuodb-cp-rest 8080:8080 &
fi
}
function uninstallTunnel() {
PID="`ps -ef | grep -e "kubectl port-forward service/nuodb-cp-rest 8080:8080" | grep -v -e grep | awk ' { print $2 }'`"
if [ "$PID" != "" ] ; then
echo "Uninstalling Tunnel"
kill -9 $PID
fi
}
if [ "$1" = "install" ] ; then
addRepo
helmInstall nuodb-cp-crd
helmInstall nuodb-cp-operator
helmInstall nuodb-cp-rest
installTunnel
elif [ "$1" = "uninstall" ] ; then
uninstallTunnel
helmUninstall nuodb-cp-rest
helmUninstall nuodb-cp-operator
helmUninstall nuodb-cp-crd
deleteRepo
else
echo "$0 install"
echo "$0 uninstall"
exit 1
fi