Zhe Huang | 44fcaf0 | 2019-08-27 12:55:57 -0400 | [diff] [blame] | 1 | #!/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 | |
| 24 | while [ -n "$1" ]; do # while loop starts |
| 25 | |
| 26 | case "$1" in |
| 27 | |
Zhe Huang | dccf473 | 2019-09-11 13:59:35 -0400 | [diff] [blame] | 28 | -f) IMAGELISTFILE=$2 |
Zhe Huang | 44fcaf0 | 2019-08-27 12:55:57 -0400 | [diff] [blame] | 29 | 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 | |
| 44 | done |
| 45 | |
Zhe Huang | dccf473 | 2019-09-11 13:59:35 -0400 | [diff] [blame] | 46 | if [ -z "$IMAGELISTFILE" ]; then |
| 47 | echo "Image list file is missing. Please use -f to specify the path." |
Zhe Huang | 44fcaf0 | 2019-08-27 12:55:57 -0400 | [diff] [blame] | 48 | exit 1 |
| 49 | fi |
| 50 | |
Zhe Huang | dccf473 | 2019-09-11 13:59:35 -0400 | [diff] [blame] | 51 | if [ -z "$IMAGE_DIRECTORY_PATH" ]; then |
Zhe Huang | 44fcaf0 | 2019-08-27 12:55:57 -0400 | [diff] [blame] | 52 | IMAGE_DIRECTORY_PATH=/tmp/ric_image |
Zhe Huang | 44fcaf0 | 2019-08-27 12:55:57 -0400 | [diff] [blame] | 53 | fi |
| 54 | |
| 55 | |
Zhe Huang | dccf473 | 2019-09-11 13:59:35 -0400 | [diff] [blame] | 56 | rm -rf $IMAGE_DIRECTORY_PATH |
| 57 | mkdir -p $IMAGE_DIRECTORY_PATH |
Zhe Huang | 44fcaf0 | 2019-08-27 12:55:57 -0400 | [diff] [blame] | 58 | |
| 59 | |
| 60 | while IFS= read -r image |
| 61 | do |
wrider | 0011afa | 2019-10-27 17:07:48 -0400 | [diff] [blame] | 62 | if [[ $image == "#"* ]]; then |
| 63 | # supporting comment lines |
| 64 | continue |
| 65 | fi |
| 66 | |
Zhe Huang | 44fcaf0 | 2019-08-27 12:55:57 -0400 | [diff] [blame] | 67 | 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 Huang | dccf473 | 2019-09-11 13:59:35 -0400 | [diff] [blame] | 82 | done < "$IMAGELISTFILE" |
Zhe Huang | 44fcaf0 | 2019-08-27 12:55:57 -0400 | [diff] [blame] | 83 | |
| 84 | |
Zhe Huang | dccf473 | 2019-09-11 13:59:35 -0400 | [diff] [blame] | 85 | echo "RIC Images are downloaded to: $IMAGE_DIRECTORY_PATH" |