--- /dev/null
+#!/bin/bash
+##############################################################################
+#
+# Copyright (c) 2019 AT&T Intellectual Property.
+#
+# 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.
+#
+##############################################################################
+
+# Installs well-known RIC charts then verifies specified helm chart
+# Requires chart tgz archives in /tmp
+
+
+while [ -n "$1" ]; do # while loop starts
+
+ case "$1" in
+
+ -f) XAPPLISTFILE=$2
+ shift
+ ;;
+
+ -d) CHART_DIRECTORY_PATH=$2
+ shift
+ ;;
+
+
+ *) echo "Option $1 not recognized. Please use -f to specify the recipe path." ;; # In case you typed a different option other than a,b,c
+
+ esac
+
+ shift
+
+done
+
+if [ -z "$XAPPLISTFILE" ]; then
+ echo "xApp list file is missing. Please use -f to specify the path."
+ exit 1
+fi
+
+if [ -z "$CHART_DIRECTORY_PATH" ]; then
+ CHART_DIRECTORY_PATH=/tmp/xapp_charts
+fi
+
+
+rm -rf $CHART_DIRECTORY_PATH
+mkdir -p $CHART_DIRECTORY_PATH/helm_charts
+mkdir -p $CHART_DIRECTORY_PATH/docker_images
+
+
+while IFS= read -r chart
+do
+ CHARTNAME=$(echo $chart | awk '{ n=split($0, a, "/"); split(a[n],b,":"); print b[1] }')
+ CHARTVERSION=$(echo $chart | awk '{ n=split($0, a, "/"); split(a[n],b,":"); print b[2] }')
+ HELM_REPO=$(echo $chart | awk -F'/' '{gsub($NF,""); print substr($0,1,length($0)-1)}')
+
+ echo "Fetching helm charts $CHARTNAME version $CHARTVERSION from repo $HELM_REPO"
+ helm repo add temp $HELM_REPO > /dev/null
+ helm fetch temp/$CHARTNAME --version $CHARTVERSION -d $CHART_DIRECTORY_PATH/helm_charts --untar
+ helm repo remove temp > /dev/null
+
+
+done < "$XAPPLISTFILE"
+
+echo "************************************************************"
+for chart in $CHART_DIRECTORY_PATH/helm_charts/*; do
+
+
+ CHART_NAME=$(echo $chart | awk -F '/' '{print $NF}')
+ mkdir -p $CHART_DIRECTORY_PATH/docker_images/$CHART_NAME
+
+ IMAGE_ARRAY=$(helm template $chart | grep "image:" | awk '{ gsub(/.*image: /, "", $0); gsub(/"/, "", $0); print $0}' )
+
+ while read -r image; do
+
+ IMAGENAME=$(echo $image | awk '{ n=split($0, a, "/"); print a[n] }')
+ echo "Pulling image $image"
+ RESULT=$(docker pull $image |& grep "no basic auth credentials" )
+ if [ ! -z "$RESULT" ]; then
+ echo "You are not logined to docker registry. Please login by running \"docker login DOCKER_REGISTRY\""
+ exit 1
+ fi
+
+ echo "Saving image $image"
+ docker save $image -o $CHART_DIRECTORY_PATH/docker_images/$CHART_NAME/$IMAGENAME
+
+
+
+
+ done <<< "$IMAGE_ARRAY"
+
+
+done
+
+
+
+
+echo "************************************************************"
+echo "xApp helm charts are downloaded to: $CHART_DIRECTORY_PATH"