2 ##############################################################################
3 # Copyright (c) 2018 Huawei and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
14 logger -s -t "fetch_k8_conf.info" "$*"
19 logger -s -t "fetch_k8_conf.error" "$*"
26 while getopts ":d:i:a:h:s:o:v" optchar; do
28 d) dest_path=${OPTARG} ;;
29 i) installer_type=${OPTARG} ;;
30 v) DEPLOY_TYPE="virt" ;;
31 *) echo "Non-option argument: '-${OPTARG}'" >&2
38 # set vars from env if not provided by user as options
39 dest_path=${dest_path:-$HOME/admin.conf}
40 installer_type=${installer_type:-$INSTALLER_TYPE}
42 if [ -z $dest_path ] || [ -z $installer_type ]; then
47 # Checking if destination path is valid
48 if [ -d $dest_path ]; then
49 error "Please provide the full destination path for the credentials file including the filename"
51 # Check if we can create the file (e.g. path is correct)
52 touch $dest_path || error "Cannot create the file specified. Check that the path is correct and run the script again."
55 if [ "$installer_type" == "compass" ]; then
56 info "Fetching admin.conf file on Compass"
57 sudo docker cp compass-tasks:/opt/admin.conf $dest_path &> /dev/null
58 sudo chown $(whoami):$(whoami) $dest_path
59 info "Fetch admin.conf successfully"
60 elif [ "$installer_type" == "joid" ]; then
61 info "Do nothing, config file has been provided in $HOME/joid_config/config for joid"
63 error "Installer $installer_type is not supported by this script"