[cli] Version command fix, add :/assembly mount option (#3835)
* version fix * add assembly mount option * move library * port check6.19.x
parent
25f18e1ce2
commit
c5118908f3
|
|
@ -46,7 +46,7 @@ cmd_config() {
|
|||
info "config" "Customizing docker-compose for running in a container"
|
||||
|
||||
|
||||
if local_repo; then
|
||||
if local_repo || local_assembly; then
|
||||
# in development mode to avoid permissions issues we copy tomcat assembly to ${CHE_INSTANCE}
|
||||
# if ${CHE_FORMAL_PRODUCT_NAME} development tomcat exist we remove it
|
||||
if [[ -d "${CHE_CONTAINER_INSTANCE}/dev" ]]; then
|
||||
|
|
@ -61,16 +61,17 @@ cmd_config() {
|
|||
rm -rf "${CHE_CONTAINER_INSTANCE}/dev"
|
||||
fi
|
||||
|
||||
if [[ ! -d $(echo ${CHE_CONTAINER_DEVELOPMENT_REPO}/${CHE_ASSEMBLY_IN_REPO}) ]]; then
|
||||
warning "You volume mounted a valid $CHE_FORMAL_PRODUCT_NAME repo to ':/repo', but we could not find a ${CHE_FORMAL_PRODUCT_NAME} assembly."
|
||||
warning "Have you built ${CHE_ASSEMBLY_IN_REPO_MODULE_NAME} with 'mvn clean install'?"
|
||||
if [[ ! -d $(echo ${CHE_CONTAINER_ASSEMBLY_FULL_PATH}) ]]; then
|
||||
warning "You mounted ':/repo' or ':/assembly', but we did not find an assembly."
|
||||
warning "Have you built the assembly with 'mvn clean install'?"
|
||||
warning "CHE_ASSEMBLY=${CHE_CONTAINER_ASSEMBLY_FULL_PATH}"
|
||||
return 2
|
||||
fi
|
||||
|
||||
# copy ${CHE_FORMAL_PRODUCT_NAME} development tomcat to ${CHE_INSTANCE} folder
|
||||
info "config" "Copying local binaries to ${CHE_HOST_INSTANCE}/dev..."
|
||||
mkdir -p "${CHE_CONTAINER_INSTANCE}/dev/${CHE_MINI_PRODUCT_NAME}-tomcat"
|
||||
cp -r "$(echo $CHE_CONTAINER_DEVELOPMENT_REPO/$CHE_ASSEMBLY_IN_REPO)/." \
|
||||
cp -r "$(echo ${CHE_CONTAINER_ASSEMBLY_FULL_PATH})/." \
|
||||
"${CHE_CONTAINER_INSTANCE}/dev/${CHE_MINI_PRODUCT_NAME}-tomcat/"
|
||||
fi
|
||||
|
||||
|
|
@ -96,9 +97,15 @@ generate_configuration_with_puppet() {
|
|||
WRITE_LOGS=">> \"${LOGS}\""
|
||||
fi
|
||||
|
||||
if local_repo; then
|
||||
CHE_REPO="off"
|
||||
WRITE_PARAMETERS=""
|
||||
|
||||
if local_repo || local_assembly; then
|
||||
CHE_REPO="on"
|
||||
WRITE_PARAMETERS=" -e \"CHE_ASSEMBLY=${CHE_ASSEMBLY}\""
|
||||
fi
|
||||
|
||||
if local_repo; then
|
||||
# add local mounts only if they are present
|
||||
if [ -d "/repo/dockerfiles/init/manifests" ]; then
|
||||
WRITE_PARAMETERS+=" -v \"${CHE_HOST_DEVELOPMENT_REPO}/dockerfiles/init/manifests\":/etc/puppet/manifests:ro"
|
||||
|
|
@ -110,10 +117,6 @@ generate_configuration_with_puppet() {
|
|||
if [ -d "/repo/dockerfiles/init/addon" ]; then
|
||||
WRITE_PARAMETERS+=" -v \"${CHE_HOST_DEVELOPMENT_REPO}/dockerfiles/init/addon/addon.pp\":/etc/puppet/manifests/addon.pp:ro"
|
||||
fi
|
||||
|
||||
else
|
||||
CHE_REPO="off"
|
||||
WRITE_PARAMETERS=""
|
||||
fi
|
||||
|
||||
GENERATE_CONFIG_COMMAND="docker_run \
|
||||
|
|
|
|||
|
|
@ -105,7 +105,9 @@ cmd_init() {
|
|||
info "init" " ${CHE_PRODUCT_NAME}_CONFIG=${CHE_HOST_CONFIG}"
|
||||
info "init" " ${CHE_PRODUCT_NAME}_INSTANCE=${CHE_HOST_INSTANCE}"
|
||||
if local_repo; then
|
||||
info "init" " ${CHE_PRODUCT_NAME}_DEVELOPMENT_REPO=${CHE_HOST_DEVELOPMENT_REPO}"
|
||||
info "init" " ${CHE_PRODUCT_NAME}_REPO=${CHE_HOST_DEVELOPMENT_REPO}"
|
||||
fi
|
||||
if local_repo || local_assembly; then
|
||||
info "init" " ${CHE_PRODUCT_NAME}_ASSEMBLY=${CHE_ASSEMBLY}"
|
||||
fi
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -62,6 +62,12 @@ cmd_start() {
|
|||
|
||||
cmd_start_check_ports() {
|
||||
|
||||
# Develop array of port #, description.
|
||||
# Format of array is "<port>;<port_string>" where the <port_string> is the text to appear in console
|
||||
local PORT_ARRAY=(
|
||||
"${CHE_PORT};port ${CHE_PORT} (http): "
|
||||
)
|
||||
|
||||
# If dev mode is on, then we also need to check the debug port set by the user for availability
|
||||
if debug_server; then
|
||||
USER_DEBUG_PORT=$(get_value_of_var_from_env_file CHE_DEBUG_PORT)
|
||||
|
|
@ -73,23 +79,14 @@ cmd_start_check_ports() {
|
|||
# Otherwise, this is the value set by the user
|
||||
CHE_DEBUG_PORT=$USER_DEBUG_PORT
|
||||
fi
|
||||
|
||||
PORT_ARRAY+=("$CHE_DEBUG_PORT;port ${CHE_DEBUG_PORT} (debug): ")
|
||||
fi
|
||||
|
||||
text " port ${CHE_PORT} (http): $(port_open ${CHE_PORT} && echo "${GREEN}[AVAILABLE]${NC}" || echo "${RED}[ALREADY IN USE]${NC}") \n"
|
||||
if debug_server; then
|
||||
text " port ${CHE_DEBUG_PORT} (debug): $(port_open ${CHE_DEBUG_PORT} && echo "${GREEN}[AVAILABLE]${NC}" || echo "${RED}[ALREADY IN USE]${NC}") \n"
|
||||
fi
|
||||
if ! $(port_open ${CHE_PORT}); then
|
||||
echo ""
|
||||
error "Ports required to run $CHE_MINI_PRODUCT_NAME are used by another program."
|
||||
return 1;
|
||||
fi
|
||||
if debug_server; then
|
||||
if ! $(port_open ${CHE_DEBUG_PORT}); then
|
||||
echo ""
|
||||
error "Ports required to run $CHE_MINI_PRODUCT_NAME are used by another program."
|
||||
return 1;
|
||||
fi
|
||||
if check_all_ports "${PORT_ARRAY[@]}"; then
|
||||
print_ports_as_ok "${PORT_ARRAY[@]}"
|
||||
else
|
||||
find_and_print_ports_as_notok "${PORT_ARRAY[@]}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,16 +20,33 @@ cmd_version() {
|
|||
else
|
||||
text "Your installed version is '<not-installed>'.\n"
|
||||
fi
|
||||
text "Available on DockerHub:\n"
|
||||
VERSION_LIST_JSON=$(curl -s https://hub.docker.com/v2/repositories/${CHE_IMAGE_NAME}/tags/)
|
||||
NUMBER_OF_VERSIONS=$(echo $VERSION_LIST_JSON | jq '.count')
|
||||
COUNTER=0
|
||||
while [ $COUNTER -lt $NUMBER_OF_VERSIONS ]; do
|
||||
TAG=$(echo $VERSION_LIST_JSON | jq ".results[$COUNTER].name")
|
||||
# DATE=$(echo $VERSION_LIST_JSON | jq ".results[$COUNTER].last_updated")
|
||||
# DATE=${DATE:0:10}
|
||||
# text "${DATE//\"} ${TAG//\"}\n"
|
||||
text " ${TAG//\"}\n"
|
||||
let COUNTER=COUNTER+1
|
||||
done
|
||||
|
||||
text "\n"
|
||||
|
||||
if is_offline; then
|
||||
text "Available on DockerHub: offline mode\n"
|
||||
else
|
||||
text "Available on DockerHub:\n"
|
||||
|
||||
local VERSION_LIST_JSON=$(curl -s https://hub.docker.com/v2/repositories/${CHE_IMAGE_NAME}/tags/)
|
||||
local NUMBER_OF_VERSIONS=$(echo $VERSION_LIST_JSON | jq '.count')
|
||||
|
||||
DISPLAY_LIMIT=10
|
||||
if [ $DISPLAY_LIMIT -gt $NUMBER_OF_VERSIONS ]; then
|
||||
DISPLAY_LIMIT=$NUMBER_OF_VERSIONS
|
||||
fi
|
||||
|
||||
COUNTER=0
|
||||
while [ $COUNTER -lt $DISPLAY_LIMIT ]; do
|
||||
TAG=$(echo $VERSION_LIST_JSON | jq ".results[$COUNTER].name")
|
||||
text " ${TAG//\"}\n"
|
||||
let COUNTER=COUNTER+1
|
||||
done
|
||||
|
||||
if [ $NUMBER_OF_VERSIONS -gt $DISPLAY_LIMIT ]; then
|
||||
OLDER_VERSION=$(echo $VERSION_LIST_JSON | jq '.next')
|
||||
text " See older versions at: $OLDER_VERSION\n"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -192,6 +192,14 @@ local_repo() {
|
|||
fi
|
||||
}
|
||||
|
||||
local_assembly() {
|
||||
if [ "${CHE_LOCAL_ASSEMBLY}" = "true" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_docker() {
|
||||
if ! has_docker; then
|
||||
error "Docker not found. Get it at https://docs.docker.com/engine/installation/."
|
||||
|
|
@ -225,12 +233,14 @@ check_docker() {
|
|||
# Detect version so that we can provide better error warnings
|
||||
DEFAULT_CHE_VERSION=$(cat "/version/latest.ver")
|
||||
CHE_IMAGE_FULLNAME=$(docker inspect --format='{{.Config.Image}}' $(get_this_container_id))
|
||||
CHE_IMAGE_NAME=$(echo "${CHE_IMAGE_FULLNAME}" | cut -d : -f1 -s)
|
||||
|
||||
# Note - cut command here fails if there is no colon : in the image
|
||||
CHE_IMAGE_NAME=${CHE_IMAGE_FULLNAME%:*}
|
||||
CHE_IMAGE_VERSION=$(echo "${CHE_IMAGE_FULLNAME}" | cut -d : -f2 -s)
|
||||
if [[ "${CHE_IMAGE_VERSION}" = "" ]] ||
|
||||
[[ "${CHE_IMAGE_VERSION}" = "latest" ]]; then
|
||||
warning "You are using CLI image version 'latest' which is set to '$DEFAULT_CHE_VERSION'."
|
||||
CHE_IMAGE_VERSION=$DEFAULT_CHE_VERSION
|
||||
warning "Bound '$CHE_IMAGE_NAME' to '$CHE_IMAGE_NAME:$CHE_IMAGE_VERSION'"
|
||||
else
|
||||
CHE_IMAGE_VERSION=$CHE_IMAGE_VERSION
|
||||
fi
|
||||
|
|
@ -285,6 +295,7 @@ check_mounts() {
|
|||
INSTANCE_MOUNT=$(get_container_folder ":${CHE_CONTAINER_ROOT}/instance")
|
||||
BACKUP_MOUNT=$(get_container_folder ":${CHE_CONTAINER_ROOT}/backup")
|
||||
REPO_MOUNT=$(get_container_folder ":/repo")
|
||||
ASSEMBLY_MOUNT=$(get_container_folder ":/assembly")
|
||||
SYNC_MOUNT=$(get_container_folder ":/sync")
|
||||
UNISON_PROFILE_MOUNT=$(get_container_folder ":/unison")
|
||||
CHEDIR_MOUNT=$(get_container_folder ":/chedir")
|
||||
|
|
@ -325,7 +336,7 @@ check_mounts() {
|
|||
DEFAULT_CHE_BACKUP="${BACKUP_MOUNT}"
|
||||
fi
|
||||
|
||||
# Set offline to CONFIG_MOUNT
|
||||
# DERIVED VARIABLES FROM MOUNTS
|
||||
CHE_HOST_CONFIG=${CHE_CONFIG:-${DEFAULT_CHE_CONFIG}}
|
||||
CHE_CONTAINER_CONFIG="${CHE_CONTAINER_ROOT}"
|
||||
|
||||
|
|
@ -335,10 +346,26 @@ check_mounts() {
|
|||
CHE_HOST_BACKUP=${CHE_BACKUP:-${DEFAULT_CHE_BACKUP}}
|
||||
CHE_CONTAINER_BACKUP="${CHE_CONTAINER_ROOT}/backup"
|
||||
|
||||
REFERENCE_HOST_ENVIRONMENT_FILE="${CHE_HOST_CONFIG}/${CHE_ENVIRONMENT_FILE}"
|
||||
REFERENCE_HOST_COMPOSE_FILE="${CHE_HOST_INSTANCE}/${CHE_COMPOSE_FILE}"
|
||||
REFERENCE_CONTAINER_ENVIRONMENT_FILE="${CHE_CONTAINER_CONFIG}/${CHE_ENVIRONMENT_FILE}"
|
||||
REFERENCE_CONTAINER_COMPOSE_FILE="${CHE_CONTAINER_INSTANCE}/${CHE_COMPOSE_FILE}"
|
||||
REFERENCE_CONTAINER_COMPOSE_HOST_FILE="${CHE_CONTAINER_INSTANCE}/${CHE_HOST_COMPOSE_FILE}"
|
||||
|
||||
CHE_CONTAINER_OFFLINE_FOLDER="${CHE_CONTAINER_BACKUP}"
|
||||
CHE_HOST_OFFLINE_FOLDER="${CHE_HOST_BACKUP}"
|
||||
|
||||
CHE_HOST_CONFIG_MANIFESTS_FOLDER="${CHE_HOST_INSTANCE}/manifests"
|
||||
CHE_CONTAINER_CONFIG_MANIFESTS_FOLDER="${CHE_CONTAINER_INSTANCE}/manifests"
|
||||
|
||||
CHE_HOST_CONFIG_MODULES_FOLDER="${CHE_HOST_INSTANCE}/modules"
|
||||
CHE_CONTAINER_CONFIG_MODULES_FOLDER="${CHE_CONTAINER_INSTANCE}/modules"
|
||||
|
||||
|
||||
### DEV MODE VARIABLES
|
||||
CHE_LOCAL_REPO=false
|
||||
if [[ "${REPO_MOUNT}" != "not set" ]]; then
|
||||
info "cli" ":/repo mounted - using binaries from your local repository"
|
||||
info "cli" ":/repo mounted - using assembly and manifests from your local repository"
|
||||
|
||||
CHE_LOCAL_REPO=true
|
||||
CHE_HOST_DEVELOPMENT_REPO="${REPO_MOUNT}"
|
||||
|
|
@ -355,7 +382,7 @@ check_mounts() {
|
|||
info ""
|
||||
info "Please check the path you mounted to verify that is a valid $CHE_FORMAL_PRODUCT_NAME git repository."
|
||||
info ""
|
||||
info "Simplest syntax::"
|
||||
info "Simplest syntax:"
|
||||
info " docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock"
|
||||
info " -v <YOUR_LOCAL_PATH>:${CHE_CONTAINER_ROOT}"
|
||||
info " -v <YOUR_${CHE_PRODUCT_NAME}_REPO>:/repo"
|
||||
|
|
@ -371,9 +398,36 @@ check_mounts() {
|
|||
info " ${CHE_IMAGE_FULLNAME} $*"
|
||||
return 2
|
||||
fi
|
||||
|
||||
CHE_CONTAINER_ASSEMBLY_FULL_PATH="${CHE_CONTAINER_DEVELOPMENT_REPO}"/"${CHE_ASSEMBLY_IN_REPO}"
|
||||
elif debug_server; then
|
||||
warning "Debugging activated without ':/repo' mount - using binaries inside Docker image"
|
||||
fi
|
||||
|
||||
CHE_LOCAL_ASSEMBLY=false
|
||||
if [[ "${ASSEMBLY_MOUNT}" != "not set" ]]; then
|
||||
info "cli" ":/assembly mounted - using assembly from local host"
|
||||
|
||||
CHE_LOCAL_ASSEMBLY=true
|
||||
CHE_ASSEMBLY="${CHE_HOST_INSTANCE}/dev/${CHE_MINI_PRODUCT_NAME}-tomcat"
|
||||
|
||||
CHE_CONTAINER_ASSEMBLY="/assembly"
|
||||
if [[ ! -d "${CHE_CONTAINER_ASSEMBLY}" ]]; then
|
||||
info "Welcome to $CHE_FORMAL_PRODUCT_NAME!"
|
||||
info ""
|
||||
info "You volume mounted ':/assembly', but we could not find a valid assembly."
|
||||
info ""
|
||||
info "Please check the path you mounted."
|
||||
info ""
|
||||
info "Syntax:"
|
||||
info " docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock"
|
||||
info " -v <YOUR_LOCAL_PATH>:${CHE_CONTAINER_ROOT}"
|
||||
info " -v <YOUR_${CHE_PRODUCT_NAME}_ASSEMBLY>:/assembly"
|
||||
info " ${CHE_IMAGE_FULLNAME} $*"
|
||||
return 2
|
||||
fi
|
||||
CHE_CONTAINER_ASSEMBLY_FULL_PATH="${CHE_CONTAINER_ASSEMBLY}"
|
||||
fi
|
||||
}
|
||||
|
||||
docker_compose() {
|
||||
|
|
|
|||
|
|
@ -88,28 +88,27 @@ initiate_offline_or_network_mode(){
|
|||
# If you are using ${CHE_FORMAL_PRODUCT_NAME} in offline mode, images must be loaded here
|
||||
# This is the point where we know that docker is working, but before we run any utilities
|
||||
# that require docker.
|
||||
if [[ "$@" == *"--offline"* ]]; then
|
||||
if is_offline; then
|
||||
info "init" "Importing ${CHE_MINI_PRODUCT_NAME} Docker images from tars..."
|
||||
|
||||
if [ ! -d ${CHE_CONTAINER_OFFLINE_FOLDER} ]; then
|
||||
info "init" "You requested offline image loading, but '${CHE_CONTAINER_OFFLINE_FOLDER}' folder not found"
|
||||
return 2;
|
||||
warning "Skipping offline image loading - '${CHE_CONTAINER_OFFLINE_FOLDER}' not found"
|
||||
else
|
||||
IFS=$'\n'
|
||||
for file in "${CHE_CONTAINER_OFFLINE_FOLDER}"/*.tar
|
||||
do
|
||||
if ! $(docker load < "${CHE_CONTAINER_OFFLINE_FOLDER}"/"${file##*/}" > /dev/null); then
|
||||
error "Failed to restore ${CHE_MINI_PRODUCT_NAME} Docker images"
|
||||
return 2;
|
||||
fi
|
||||
info "init" "Loading ${file##*/}..."
|
||||
done
|
||||
fi
|
||||
|
||||
IFS=$'\n'
|
||||
for file in "${CHE_CONTAINER_OFFLINE_FOLDER}"/*.tar
|
||||
do
|
||||
if ! $(docker load < "${CHE_CONTAINER_OFFLINE_FOLDER}"/"${file##*/}" > /dev/null); then
|
||||
error "Failed to restore ${CHE_MINI_PRODUCT_NAME} Docker images"
|
||||
return 2;
|
||||
fi
|
||||
info "init" "Loading ${file##*/}..."
|
||||
done
|
||||
else
|
||||
# If we are here, then we want to run in networking mode.
|
||||
# If we are in networking mode, we have had some issues where users have failed DNS networking.
|
||||
# See: https://github.com/eclipse/che/issues/3266#issuecomment-265464165
|
||||
if [[ "${FAST_BOOT}" = "false" ]]; then
|
||||
if ! is_fast; then
|
||||
info "cli" "Checking network... (hint: '--fast' skips version, network, and nightly checks)"
|
||||
local HTTP_STATUS_CODE=$(curl -I -k dockerhub.com -s -o /dev/null --write-out '%{http_code}')
|
||||
if [[ ! $HTTP_STATUS_CODE -eq "301" ]]; then
|
||||
|
|
@ -367,9 +366,17 @@ verify_version_compatibility() {
|
|||
## - If they don't match and one is nightly, fail
|
||||
## - If they don't match, then if CLI is older fail with message to get proper CLI
|
||||
## - If they don't match, then if CLLI is newer fail with message to run upgrade first
|
||||
|
||||
CHE_IMAGE_VERSION=$(get_image_version)
|
||||
|
||||
# Only check for newer versions if not in offline mode.
|
||||
if ! is_offline; then
|
||||
NEWER=$(compare_versions $CHE_IMAGE_VERSION)
|
||||
|
||||
if [[ "${NEWER}" != "" ]]; then
|
||||
warning "Newer version '$NEWER' available"
|
||||
fi
|
||||
fi
|
||||
|
||||
if is_initialized; then
|
||||
COMPARE_CLI_ENV=$(compare_cli_version_to_installed_version)
|
||||
INSTALLED_VERSION=$(get_installed_version)
|
||||
|
|
@ -539,3 +546,87 @@ wait_until_server_is_booted() {
|
|||
ELAPSED=$((ELAPSED+1))
|
||||
done
|
||||
}
|
||||
|
||||
# Compares $1 version to the first 10 versions listed as tags on Docker Hub
|
||||
# Returns "" if $1 is newest, otherwise returns the newest version available
|
||||
compare_versions() {
|
||||
|
||||
local VERSION_LIST_JSON=$(curl -s https://hub.docker.com/v2/repositories/${CHE_IMAGE_NAME}/tags/)
|
||||
local NUMBER_OF_VERSIONS=$(echo $VERSION_LIST_JSON | jq '.count')
|
||||
|
||||
DISPLAY_LIMIT=10
|
||||
if [ $DISPLAY_LIMIT -gt $NUMBER_OF_VERSIONS ]; then
|
||||
DISPLAY_LIMIT=$NUMBER_OF_VERSIONS
|
||||
fi
|
||||
|
||||
# Strips off -M#, -latest version information
|
||||
BASE_VERSION=$(echo $1 | cut -f1 -d"-")
|
||||
|
||||
COUNTER=0
|
||||
RETURN_VERSION=""
|
||||
while [ $COUNTER -lt $DISPLAY_LIMIT ]; do
|
||||
TAG=$(echo $VERSION_LIST_JSON | jq ".results[$COUNTER].name")
|
||||
TAG=${TAG//\"}
|
||||
|
||||
if [ "$TAG" != "nightly" ] && [ "$TAG" != "latest" ]; then
|
||||
if less_than $BASE_VERSION $TAG; then
|
||||
RETURN_VERSION=$TAG
|
||||
break;
|
||||
fi
|
||||
fi
|
||||
let COUNTER=COUNTER+1
|
||||
done
|
||||
|
||||
echo $RETURN_VERSION
|
||||
}
|
||||
|
||||
# Input - an array of ports and port descriptions to check
|
||||
# Output - true if all ports are open, false if any of them are already bound
|
||||
check_all_ports(){
|
||||
|
||||
declare -a PORT_INTERNAL_ARRAY=("${@}")
|
||||
|
||||
DOCKER_PORT_STRING=""
|
||||
HTTPD_PORT_STRING=""
|
||||
for index in "${!PORT_INTERNAL_ARRAY[@]}"; do
|
||||
PORT=${PORT_INTERNAL_ARRAY[$index]%;*}
|
||||
PORT_STRING=${PORT_INTERNAL_ARRAY[$index]#*;}
|
||||
|
||||
DOCKER_PORT_STRING+=" -p $PORT:$PORT"
|
||||
HTTPD_PORT_STRING+=" -p $PORT"
|
||||
done
|
||||
|
||||
EXECUTION_STRING="docker run -it --rm ${DOCKER_PORT_STRING} ${UTILITY_IMAGE_ALPINE} \
|
||||
sh -c \"echo hi\" > /dev/null 2>&1"
|
||||
eval ${EXECUTION_STRING}
|
||||
NETSTAT_EXIT=$?
|
||||
|
||||
if [[ $NETSTAT_EXIT = 125 ]]; then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
print_ports_as_ok() {
|
||||
declare -a PORT_INTERNAL_ARRAY=("${@}")
|
||||
|
||||
for index in "${!PORT_INTERNAL_ARRAY[@]}"; do
|
||||
PORT_STRING=${PORT_INTERNAL_ARRAY[$index]#*;}
|
||||
text " $PORT_STRING ${GREEN}[AVAILABLE]${NC}\n"
|
||||
done
|
||||
}
|
||||
|
||||
find_and_print_ports_as_notok() {
|
||||
declare -a PORT_INTERNAL_ARRAY=("${@}")
|
||||
|
||||
for index in "${!PORT_INTERNAL_ARRAY[@]}"; do
|
||||
PORT=${PORT_INTERNAL_ARRAY[$index]%;*}
|
||||
PORT_STRING=${PORT_INTERNAL_ARRAY[$index]#*;}
|
||||
text " ${PORT_STRING} $(port_open ${PORT} && echo "${GREEN}[AVAILABLE]${NC}" || echo "${RED}[ALREADY IN USE]${NC}") \n"
|
||||
done
|
||||
|
||||
echo ""
|
||||
error "Ports required to run $CHE_MINI_PRODUCT_NAME are used by another program."
|
||||
return 2;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ init_constants() {
|
|||
LOG_INITIALIZED=false
|
||||
FAST_BOOT=false
|
||||
CHE_DEBUG=false
|
||||
CHE_OFFLINE=false
|
||||
|
||||
DEFAULT_CHE_PRODUCT_NAME="CHE"
|
||||
CHE_PRODUCT_NAME=${CHE_PRODUCT_NAME:-${DEFAULT_CHE_PRODUCT_NAME}}
|
||||
|
|
@ -237,6 +238,14 @@ is_fast() {
|
|||
fi
|
||||
}
|
||||
|
||||
is_offline() {
|
||||
if [ "${CHE_OFFLINE}" = "true" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
init_logging() {
|
||||
# Initialize CLI folder
|
||||
CLI_DIR=$CHE_CONTAINER_ROOT
|
||||
|
|
@ -266,6 +275,10 @@ init() {
|
|||
CHE_DEBUG=true
|
||||
fi
|
||||
|
||||
if [[ "$@" == *"--offline"* ]]; then
|
||||
CHE_OFFLINE=true
|
||||
fi
|
||||
|
||||
SCRIPTS_BASE_CONTAINER_SOURCE_DIR="/scripts/base"
|
||||
# add helper scripts
|
||||
for HELPER_FILE in "${SCRIPTS_BASE_CONTAINER_SOURCE_DIR}"/*.sh
|
||||
|
|
@ -337,22 +350,6 @@ cli_init() {
|
|||
return 2;
|
||||
fi
|
||||
|
||||
# Derived variablea
|
||||
REFERENCE_HOST_ENVIRONMENT_FILE="${CHE_HOST_CONFIG}/${CHE_ENVIRONMENT_FILE}"
|
||||
REFERENCE_HOST_COMPOSE_FILE="${CHE_HOST_INSTANCE}/${CHE_COMPOSE_FILE}"
|
||||
REFERENCE_CONTAINER_ENVIRONMENT_FILE="${CHE_CONTAINER_CONFIG}/${CHE_ENVIRONMENT_FILE}"
|
||||
REFERENCE_CONTAINER_COMPOSE_FILE="${CHE_CONTAINER_INSTANCE}/${CHE_COMPOSE_FILE}"
|
||||
REFERENCE_CONTAINER_COMPOSE_HOST_FILE="${CHE_CONTAINER_INSTANCE}/${CHE_HOST_COMPOSE_FILE}"
|
||||
|
||||
CHE_CONTAINER_OFFLINE_FOLDER="${CHE_CONTAINER_BACKUP}"
|
||||
CHE_HOST_OFFLINE_FOLDER="${CHE_HOST_BACKUP}"
|
||||
|
||||
CHE_HOST_CONFIG_MANIFESTS_FOLDER="${CHE_HOST_INSTANCE}/manifests"
|
||||
CHE_CONTAINER_CONFIG_MANIFESTS_FOLDER="${CHE_CONTAINER_INSTANCE}/manifests"
|
||||
|
||||
CHE_HOST_CONFIG_MODULES_FOLDER="${CHE_HOST_INSTANCE}/modules"
|
||||
CHE_CONTAINER_CONFIG_MODULES_FOLDER="${CHE_CONTAINER_INSTANCE}/modules"
|
||||
|
||||
# TODO: Change this to use the current folder or perhaps ~?
|
||||
if is_boot2docker && has_docker_for_windows_client; then
|
||||
if [[ "${CHE_HOST_INSTANCE,,}" != *"${USERPROFILE,,}"* ]]; then
|
||||
|
|
@ -370,14 +367,12 @@ cli_init() {
|
|||
|
||||
# Do not perform a version compatibility check if running upgrade command.
|
||||
# The upgrade command has its own internal checks for version compatibility.
|
||||
if [ $1 != "upgrade" ]; then
|
||||
if [[ "${FAST_BOOT}" = "false" ]]; then
|
||||
verify_version_compatibility
|
||||
else
|
||||
warning "Skipping version compatibility check..."
|
||||
fi
|
||||
else
|
||||
if [[ "$@" == *"upgrade"* ]]; then
|
||||
verify_version_upgrade_compatibility
|
||||
elif ! is_fast; then
|
||||
verify_version_compatibility
|
||||
else
|
||||
warning "Skipping version compatibility check..."
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
@ -397,9 +392,10 @@ start() {
|
|||
# Bootstrap networking, docker, logging, and ability to load cli.sh and library.sh
|
||||
init "$@"
|
||||
|
||||
# Removes "--fast" and "--debug" from the positional arguments if it is set.
|
||||
# Removes "--fast", "--debug", "--offline" from the positional arguments if it is set.
|
||||
set -- "${@/\-\-fast/}"
|
||||
set -- "${@/\-\-debug/}"
|
||||
set -- "${@/\-\-offline/}"
|
||||
|
||||
# Begin product-specific CLI calls
|
||||
info "cli" "Loading cli..."
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ OPTIONAL DOCKER PARAMETERS:
|
|||
-e CHE_PORT=<YOUR_PORT> Port where ${CHE_MINI_PRODUCT_NAME} will bind itself to
|
||||
-v <LOCAL_PATH>:${CHE_CONTAINER_ROOT}/instance Where instance, user, log data will be saved
|
||||
-v <LOCAL_PATH>:${CHE_CONTAINER_ROOT}/backup Where backup files will be saved
|
||||
-v <LOCAL_PATH>:/repo ${CHE_MINI_PRODUCT_NAME} git repo - uses local binaries
|
||||
-v <LOCAL_PATH>:/repo ${CHE_MINI_PRODUCT_NAME} git repo - uses local binaries and manifests
|
||||
-v <LOCAL_PATH>:/assembly ${CHE_MINI_PRODUCT_NAME} assembly - uses local binaries
|
||||
-v <LOCAL_PATH>:/sync Where remote ws files will be copied with sync command
|
||||
-v <LOCAL_PATH>:/unison Where unison profile for optimizing sync command resides
|
||||
-v <LOCAL_PATH>:/chedir Soure repository to convert into workspace with Chedir utility
|
||||
|
|
@ -48,6 +49,7 @@ COMMANDS:
|
|||
|
||||
GLOBAL COMMAND OPTIONS:
|
||||
--fast Skips networking and version checks (saves 5 secs during bootstrap)
|
||||
--offline Runs CLI in offline mode, loading images from disk
|
||||
--debug Enable debugging of ${CHE_MINI_PRODUCT_NAME} server
|
||||
"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue