blob: 119d76d7988c54d2d0ade2d0d8965f0ce82de878 [file] [log] [blame]
Zhe Huang44fcaf02019-08-27 12:55:57 -04001#!/bin/bash
2##############################################################################
3#
4# Copyright (c) 2019 AT&T Intellectual Property.
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18##############################################################################
19
20# Installs well-known RIC charts then verifies specified helm chart
21# Requires chart tgz archives in /tmp
22
23
24while [ -n "$1" ]; do # while loop starts
25
26 case "$1" in
27
Zhe Huangdccf4732019-09-11 13:59:35 -040028 -f) IMAGELISTFILE=$2
Zhe Huang44fcaf02019-08-27 12:55:57 -040029 shift
30 ;;
31
32
33 -d) IMAGE_DIRECTORY_PATH=$2
34 shift
35 ;;
36
37
38 *) 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
39
40 esac
41
42 shift
43
44done
45
Zhe Huangdccf4732019-09-11 13:59:35 -040046if [ -z "$IMAGELISTFILE" ]; then
47 echo "Image list file is missing. Please use -f to specify the path."
Zhe Huang44fcaf02019-08-27 12:55:57 -040048 exit 1
49fi
50
Zhe Huangdccf4732019-09-11 13:59:35 -040051if [ -z "$IMAGE_DIRECTORY_PATH" ]; then
Zhe Huang44fcaf02019-08-27 12:55:57 -040052 IMAGE_DIRECTORY_PATH=/tmp/ric_image
Zhe Huang44fcaf02019-08-27 12:55:57 -040053fi
54
55
Zhe Huangdccf4732019-09-11 13:59:35 -040056rm -rf $IMAGE_DIRECTORY_PATH
57mkdir -p $IMAGE_DIRECTORY_PATH
Zhe Huang44fcaf02019-08-27 12:55:57 -040058
59
60while IFS= read -r image
61do
wrider0011afa2019-10-27 17:07:48 -040062 if [[ $image == "#"* ]]; then
63 # supporting comment lines
64 continue
65 fi
66
Zhe Huang44fcaf02019-08-27 12:55:57 -040067 IMAGENAME=$(echo $image | awk '{ n=split($0, a, "/"); print a[n] }')
68
69 echo "Pulling image $image"
70 RESULT=$(docker pull $image |& grep "no basic auth credentials" )
71 if [ ! -z "$RESULT" ]; then
72 echo "You are not logined to docker registry. Please login by running \"docker login DOCKER_REGISTRY\""
73 exit 1
74 fi
75
76 echo "Saving image $image"
77 docker save $image -o $IMAGE_DIRECTORY_PATH/$IMAGENAME
78
79 echo "************************************************************"
80
81
Zhe Huangdccf4732019-09-11 13:59:35 -040082done < "$IMAGELISTFILE"
Zhe Huang44fcaf02019-08-27 12:55:57 -040083
84
Zhe Huangdccf4732019-09-11 13:59:35 -040085echo "RIC Images are downloaded to: $IMAGE_DIRECTORY_PATH"