SMO NONRTRIC - Fix service manager preload
[it/dep.git] / bin / install
1 #!/bin/bash
2 ################################################################################
3 #   Copyright (c) 2020 Nordix Foundation.                                      #
4 #                                                                              #
5 #   Licensed under the Apache License, Version 2.0 (the "License");            #
6 #   you may not use this file except in compliance with the License.           #
7 #   You may obtain a copy of the License at                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
11 #   Unless required by applicable law or agreed to in writing, software        #
12 #   distributed under the License is distributed on an "AS IS" BASIS,          #
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
14 #   See the License for the specific language governing permissions and        #
15 #   limitations under the License.                                             #
16 ################################################################################
17
18 IS_HELM3=$(helm version -c --short|grep -e "^v3")
19 while [ -n "$1" ]; do # while loop starts
20
21     case "$1" in
22
23     -f) OVERRIDEYAML=$2
24         shift
25         ;; 
26     *) echo "Option $1 not recognized" ;; # In case you typed a different option other than a,b,c
27
28     esac
29
30     shift
31
32 done
33
34
35 if [ -z "$OVERRIDEYAML" ];then
36     echo "****************************************************************************************************************"
37     echo "                                                     ERROR                                                      "
38     echo "****************************************************************************************************************"
39     echo "RIC deployment without deployment recipe is currently disabled. Please specify an recipe with the -f option."
40     echo "****************************************************************************************************************"
41     exit 1
42 fi
43
44
45 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
46
47 COMMON_BLOCK=$(cat $OVERRIDEYAML | awk '/^common:/{getline; while ($0 ~ /^ +.*|^ *$/) {print $0; if (getline == 0) {break}}}')
48 NAMESPACE_BLOCK=$(cat $OVERRIDEYAML | awk '/^  namespace:/{getline; while ($0 ~ /^    .*|^ *$/) {print $0; if (getline == 0) {break}}}')
49 NONRTRIC_NAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *nonrtric:/{print $2}')
50 RELEASE_PREFIX=$(echo "$COMMON_BLOCK" | awk '/^ *releasePrefix:/{print $2}')
51 PARENT_CHART=$(cat $OVERRIDEYAML | awk '/^ *component:/{print $2}')
52 echo "Chart name- $PARENT_CHART"
53
54 if ! kubectl get ns ${NONRTRIC_NAMESPACE:-nonrtric}> /dev/null 2>&1; then
55     kubectl create ns ${NONRTRIC_NAMESPACE:-nonrtric}
56 fi
57 if ! kubectl get ns onap > /dev/null 2>&1; then
58     kubectl create ns onap
59 fi
60
61 kubectl create configmap -n ${NONRTRIC_NAMESPACE:-nonrtric} nonrtric-recipe --from-file=recipe=$OVERRIDEYAML
62
63 echo "Deploying NONRTRIC [$PARENT_CHART]"
64
65 HELM_NAME_OPT=""
66 if [ -z $IS_HELM3 ];then
67    HELM_NAME_OPT="--name"
68 fi
69
70 echo "helm install -f $OVERRIDEYAML --namespace ${NONRTRIC_NAMESPACE:-nonrtric} ${HELM_NAME_OPT} ${RELEASE_PREFIX} $DIR/../helm/${PARENT_CHART}"
71 helm install -f $OVERRIDEYAML --namespace "${NONRTRIC_NAMESPACE:-nonrtric}" ${HELM_NAME_OPT} "${RELEASE_PREFIX}" $DIR/../helm/"${PARENT_CHART}"
72