Luca Prete | 8ae13c2 | 2018-11-06 16:06:58 -0800 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # Copyright 2018-present Open Networking Foundation |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 6 | # use this file except in compliance with the License. You may obtain a copy |
| 7 | # 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, WITHOUT |
| 13 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | # License for the specific language governing permissions and limitations under |
| 15 | # the License. |
| 16 | |
| 17 | # copy-ssh-keys.sh - Adds ssh keys to nodes given as parameters to the script, |
| 18 | # after removing them from the ~/.ssh/known_hosts file on the local system. |
| 19 | # |
| 20 | # This script should be run interactively as it will prompt for input, and only |
| 21 | # invoked once, so as not to add multiple copies of the SSH key to the remote |
| 22 | # system. |
| 23 | |
| 24 | ############################################################# |
| 25 | # # |
| 26 | # Pull a list of images into the local Docker Registry # |
| 27 | # # |
| 28 | ############################################################# |
| 29 | |
| 30 | display_help () { |
| 31 | echo "Downloads the images specified to the local Docker Registry." |
| 32 | echo " " |
| 33 | echo "Usage: $0 [-s|--source image-list-file] [-h|--help]" |
| 34 | echo " " |
| 35 | echo " image-list-file A file where to read images from (if not read by default from stdin)" |
| 36 | echo " " |
| 37 | echo "Example usages:" |
| 38 | echo " echo alpine:3.6 | bash $0" # read the list of images from stdin |
| 39 | echo " cat images | bash $0" # read the list of images from stdin |
| 40 | echo " bash $0 -f images" # read images from a file images |
| 41 | } |
| 42 | |
| 43 | while :; do |
| 44 | case $1 in |
| 45 | -s|--source) |
| 46 | shift |
| 47 | if [[ -z $1 ]] || [[ $1 = -h ]] |
| 48 | then |
| 49 | display_help |
| 50 | exit 1 |
| 51 | fi |
| 52 | custom_file="$1" |
| 53 | ;; |
| 54 | -h|--help) |
| 55 | display_help |
| 56 | exit 0 |
| 57 | ;; |
| 58 | *) break |
| 59 | esac |
| 60 | shift |
| 61 | done |
| 62 | |
| 63 | while IFS= read -r image; |
| 64 | do |
| 65 | docker pull "${image}" > /dev/null |
| 66 | echo "${image}" |
| 67 | done < "${custom_file:-/dev/stdin}" |