e6df168e35
As part of the providing remote CLI capabilities, we provide docker images for both platform and application, each containing clients preinstalled. To make remote clients easier to use, we also provide a set of configuration and wrapper scripts. These scripts take as input an RC file downloaded from Horizon (platform or application horizon) and generate a script with the proper authentication variables and aliases. For more details, a README file is also included. These scripts also work on Windows, by using cygwin to interpret the bash scripts Note: these files are not supposed to be included in the ISO or be built as part of the normal build. These files are to be distributed separately as a tarball. Change-Id: I00f6358b8b984150fc11e9087afba83063cb8bb3 Signed-off-by: Stefan Dinescu <stefan.dinescu@windriver.com> Closes-Bug: 1834667 Closes-Bug: 1834668
117 lines
3.1 KiB
Bash
Executable File
117 lines
3.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
#
|
|
# Copyright (c) 2019 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
# Default values
|
|
RC_FILE="admin-openrc.sh"
|
|
CONF_FILE=remote_client_config.sh
|
|
ALIAS_FILE=config_aliases.sh
|
|
WORK_DIR='.'
|
|
custom_conf_file=0
|
|
explicit_client_type=0
|
|
|
|
# The script may be called from locations other
|
|
# than its own folder, so build the full path to
|
|
# the script.
|
|
if [[ $BASH_SOURCE = '/'* ]]; then
|
|
PATH_TO_SCRIPT="$(dirname $BASH_SOURCE)"
|
|
else
|
|
PATH_TO_SCRIPT="$(pwd)/$(dirname $BASH_SOURCE)"
|
|
fi
|
|
|
|
usage(){
|
|
echo "Usage:"
|
|
echo "configure_client [-t client_type] [-h] [-w workdir] [-o outputfile] [-r RC_FILE]"
|
|
echo "-h show help options"
|
|
echo "-t client_type type of client configuration (platform/openstack)"
|
|
echo " (default value is platform)"
|
|
echo "-w workdir local directory to be mounted in docker container"
|
|
echo " (default is local directory)"
|
|
echo "-o output output RC file"
|
|
echo " (default is remote_client_<app/platform>.sh)"
|
|
echo "-r RC_FILE tenant RC file"
|
|
echo " (default value is admin-openrc.sh"
|
|
}
|
|
|
|
while getopts ":hr:w:o:t:" opt; do
|
|
case $opt in
|
|
h)
|
|
usage
|
|
exit 1
|
|
;;
|
|
r)
|
|
RC_FILE=${OPTARG}
|
|
;;
|
|
w)
|
|
WORK_DIR=${OPTARG}
|
|
;;
|
|
o)
|
|
CUSTOM_CONF_FILE=${OPTARG}
|
|
custom_conf_file=1
|
|
;;
|
|
t)
|
|
CLIENT_TYPE=${OPTARG}
|
|
explicit_client_type=1
|
|
;;
|
|
*)
|
|
echo "Invalid parameter provided"
|
|
usage
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# Check if we configure a platform or an application client
|
|
if [[ $explicit_client_type -eq 1 ]]; then
|
|
if [[ "$CLIENT_TYPE" == "platform" ]]; then
|
|
CONFIG_TYPE="platform"
|
|
CONF_FILE="remote_client_platform.sh"
|
|
elif [[ "$CLIENT_TYPE" == "openstack" ]]; then
|
|
CONFIG_TYPE="application"
|
|
CONF_FILE="remote_client_openstack.sh"
|
|
else
|
|
echo "ERROR: Invalid client type option."
|
|
echo "Valid options are platform or openstack."
|
|
exit 1
|
|
fi
|
|
else
|
|
CONFIG_TYPE="platform"
|
|
CONF_FILE="remote_client_platform.sh"
|
|
fi
|
|
|
|
# If custom output RC_FILE is given, use that instead
|
|
if [[ $custom_conf_file -eq 1 ]]; then
|
|
CONF_FILE=$CUSTOM_CONF_FILE
|
|
fi
|
|
|
|
# Check if input RC file path actually exists
|
|
if [[ ! -f "$RC_FILE" ]]; then
|
|
echo "ERROR: File at location $RC_FILE does NOT exist"
|
|
exit 1
|
|
fi
|
|
|
|
# Delete previous config file
|
|
rm -f $CONF_FILE
|
|
|
|
# We output a complete path for the scripts, so first determine
|
|
# if the given path is relative or absolute
|
|
if [[ $RC_FILE = '/'* ]]; then
|
|
echo "source $RC_FILE" >> $CONF_FILE
|
|
else
|
|
echo "source $(pwd)/$RC_FILE" >> $CONF_FILE
|
|
fi
|
|
|
|
echo "export CONFIG_TYPE=${CONFIG_TYPE}" >> $CONF_FILE
|
|
|
|
if [[ $WORK_DIR = '/'* ]]; then
|
|
echo "export OSC_WORKDIR=${WORK_DIR}" >> $CONF_FILE
|
|
else
|
|
echo "export OSC_WORKDIR=$(pwd)/${WORK_DIR}" >> $CONF_FILE
|
|
fi
|
|
|
|
echo "source ${PATH_TO_SCRIPT}/$ALIAS_FILE" >> $CONF_FILE
|