X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=ric-xapps%2F90-xApps%2Fbin%2Finstall;fp=ric-xapps%2F90-xApps%2Fbin%2Finstall;h=08f45635149df1f6f3e9517a2fad7bb90e75f4f6;hb=563da71692a22c4ad04089f756fcebb86944e787;hp=0000000000000000000000000000000000000000;hpb=97a3693d4035b13c6aa0c80f1dceefa1cd10ce5b;p=it%2Fdep.git diff --git a/ric-xapps/90-xApps/bin/install b/ric-xapps/90-xApps/bin/install new file mode 100755 index 00000000..08f45635 --- /dev/null +++ b/ric-xapps/90-xApps/bin/install @@ -0,0 +1,170 @@ +#!/bin/bash +################################################################################ +# Copyright (c) 2019 AT&T Intellectual Property. # +# Copyright (c) 2019 Nokia. # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ + + +while [ -n "$1" ]; do # while loop starts + + case "$1" in + + -n) + CHART_NAME=$2 + shift + ;; + + -v) CHART_VERSION=$2 + shift + ;; # Message for -b option + + -f) OVERRIDEYAML=$2 + shift + ;; # Message for -c option + + -i) FULLIMAGE=$2 + shift + ;; + + -d) DESCRIPTOR_PATH=$2 + shift + ;; + + -c) CONFIG_JSON_PATH=$2 + shift + ;; + + -h) HELM_REPO_USERNAME=$2 + shift + ;; + + -p) HELM_REPO_PASSWORD=$2 + shift + ;; + + *) echo "Option $1 not recognized" ;; # In case you typed a different option other than a,b,c + + esac + + shift + +done + + + + +if [ -z $CHART_NAME ]; then + echo "Please specify chart name using -n option." + exit 1 +fi +if [ -z $CHART_VERSION ]; then + echo "Please specify chart version using -v option." + exit 1 +fi +if [ -z $FULLIMAGE ]; then + echo "Please specify image using -i option." + exit 1 +fi +if [ -z $DESCRIPTOR_PATH ]; then + echo "Please specify descriptor file using -d option." + exit 1 +fi +if [ -z $CONFIG_JSON_PATH ]; then + echo "Please specify config json file using -c option." + exit 1 +fi + + +if [ ! -f $DESCRIPTOR_PATH ]; then + echo "Descriptor file cannot be founded at $DESCRIPTOR_PATH" + exit 1 +fi +if [ ! -f $CONFIG_JSON_PATH ]; then + echo "Config json file cannot be founded at $CONFIG_JSON_PATH" + exit 1 +fi + + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" + + +source $DIR/../etc/xapp.conf + +if [ -z $OVERRIDEYAML ]; then + HELM_REPO=$default_helm_repo + DOCKER_REGISTRY=$default_docker_registry +else + helm_repo_override=$(grep "^ *helmRepository:" $OVERRIDEYAML | awk '{gsub(/ /,""); gsub(/\"/,""); split($0, b, "tory:");split(b[2],c,"#"); print c[1]}') + docker_reg_override=$(grep "^ *repository:" $OVERRIDEYAML | awk '{ gsub(/ /,""); gsub(/\"/,""); split($0, b, "tory:");split(b[2],c,"#"); print c[1]}') + if [ -z $helm_repo_override ]; then + HELM_REPO=$default_helm_repo + else + HELM_REPO=$helm_repo_override + fi + + if [ -z $docker_reg_override ]; then + DOCKER_REGISTRY=$default_docker_registry + else + DOCKER_REGISTRY=$docker_reg_override + fi +fi + + + + +rm -rf /tmp/$CHART_NAME + +cp -r $DIR/../helm/xapp-std/ /tmp/$CHART_NAME + + + +sed -i "s/^name: xapp-std/name: $CHART_NAME/" /tmp/$CHART_NAME/Chart.yaml +sed -i "s/^version: 0.0.1/version: $CHART_VERSION/" /tmp/$CHART_NAME/Chart.yaml + + +registry_path=$(echo $FULLIMAGE | awk '{n=split($0, a, "/"); if(n>1) print a[1]}') + + + +tag=$(echo $FULLIMAGE | awk '{n=split($0, a, "/"); split(a[n], b, ":"); print b[2]}') + +image=$(echo $FULLIMAGE | awk -v head="$registry_path/" -v tail=":$tag" '{gsub (head, ""); gsub(tail,""); gsub(/\//,"\\/"); print $0}') + + +sed -i "s/^ name: xapp-std/ name: $CHART_NAME/" /tmp/$CHART_NAME/values.yaml +sed -i "s/^ name: xapp-std/ name: $image/" /tmp/$CHART_NAME/values.yaml +sed -i "s/^ tag: latest/ tag: $tag/" /tmp/$CHART_NAME/values.yaml + + +if [ -z $registry_path ]; then + sed -i "s/^ repository: xapp-std-reg/ repository: $DOCKER_REGISTRY/" /tmp/$CHART_NAME/values.yaml +else + sed -i "s/^ repository: xapp-std-reg/ repository: $registry_path/" /tmp/$CHART_NAME/values.yaml +fi + + + + +cp $CONFIG_JSON_PATH /tmp/$CHART_NAME/config/ +cp $DESCRIPTOR_PATH /tmp/$CHART_NAME/descriptors/ + + +helm package -d /tmp /tmp/$CHART_NAME + + +echo $HELM_REPO +curl -k -u $HELM_REPO_USERNAME:$HELM_REPO_PASSWORD $HELM_REPO --upload-file /tmp/$CHART_NAME-$CHART_VERSION.tgz -v + +