Remove Docker CLI and images parts of the CLI
Fix #13649 move init files used by keycloak and postgres to their folders Change-Id: I66dbb2d6df1f3c062e981a6a513c36be8aa1d39a Signed-off-by: Florent Benoit <fbenoit@redhat.com>7.20.x
parent
65bb7943a0
commit
a50ad093f2
|
|
@ -1 +0,0 @@
|
|||
lib
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
# Copyright (c) 2017 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# build:
|
||||
# docker build -t eclipse/che-action .
|
||||
#
|
||||
# use:
|
||||
# docker run -v /var/run/docker.sock:/var/run/docker.sock eclipse/che-action [command]
|
||||
|
||||
FROM ${BUILD_ORGANIZATION}/${BUILD_PREFIX}-lib:${BUILD_TAG}
|
||||
|
||||
ENTRYPOINT ["node", "/che-lib/index.js", "che-action"]
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
### Performing actions on a local or remote Eclipse Che instance with a Docker container
|
||||
|
||||
## Build container
|
||||
```
|
||||
$ build.sh (on Unix)
|
||||
```
|
||||
|
||||
## Run container
|
||||
```
|
||||
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock eclipse/che-action <name-of-action>
|
||||
```
|
||||
|
||||
## Get available actions
|
||||
```
|
||||
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock eclipse/che-action
|
||||
```
|
||||
|
||||
## Get help on a test
|
||||
```
|
||||
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock eclipse/che-action <name-of-action> --help
|
||||
```
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2017 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
|
||||
base_dir=$(cd "$(dirname "$0")"; pwd)
|
||||
. "${base_dir}"/../build.include
|
||||
|
||||
init --name:action "$@"
|
||||
build
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
# Copyright (c) 2017 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# build:
|
||||
# docker build -t eclipse/che-base .
|
||||
#
|
||||
# use:
|
||||
# docker run eclipse/che-base
|
||||
|
||||
FROM alpine:3.4
|
||||
|
||||
ENV DOCKER_BUCKET get.docker.com
|
||||
ENV DOCKER_VERSION 1.11.2
|
||||
ENV DOCKER_SHA256 8c2e0c35e3cda11706f54b2d46c2521a6e9026a7b13c7d4b8ae1f3a706fc55e1
|
||||
|
||||
# install packages
|
||||
# coreutils is required for iso8601 compliant date utility
|
||||
RUN mkdir -p /version \
|
||||
&& mkdir -p /cli \
|
||||
&& mkdir /scripts/ \
|
||||
&& apk add --no-cache ca-certificates coreutils curl openssl jq \
|
||||
&& apk add --update bash \
|
||||
&& rm -rf /var/cache/apk/* \
|
||||
&& set -x \
|
||||
&& curl -fSL "https://${DOCKER_BUCKET}/builds/Linux/x86_64/docker-${DOCKER_VERSION}.tgz" -o docker.tgz \
|
||||
&& echo "${DOCKER_SHA256} *docker.tgz" | sha256sum -c - \
|
||||
&& tar -xzvf docker.tgz \
|
||||
&& mv docker/docker /usr/local/bin/ \
|
||||
&& rm -rf docker \
|
||||
&& rm docker.tgz \
|
||||
&& docker -v
|
||||
|
||||
COPY scripts/base /scripts/base/
|
||||
COPY scripts/entrypoint.sh /scripts/entrypoint.sh
|
||||
|
||||
RUN chmod u+x /scripts/entrypoint.sh
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2017 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
|
||||
base_dir=$(cd "$(dirname "$0")"; pwd)
|
||||
. "${base_dir}"/../build.include
|
||||
|
||||
init --name:base "$@"
|
||||
build
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Tyler Jewell - Initial Implementation
|
||||
#
|
||||
|
||||
pre_cmd_abuild() {
|
||||
UTILITY_IMAGE_DEV="eclipse/che-dev"
|
||||
|
||||
if ! is_fast && ! skip_pull; then
|
||||
load_utilities_images_if_not_done
|
||||
update_image $UTILITY_IMAGE_DEV
|
||||
fi
|
||||
|
||||
if [ ! -d /archetype/$ASSEMBLY_ID ]; then
|
||||
error "Assembly at ${ARCHETYPE_MOUNT}/$ASSEMBLY_ID not found."
|
||||
return 2
|
||||
fi
|
||||
}
|
||||
|
||||
cmd_abuild() {
|
||||
cd /archetype/$ASSEMBLY_ID
|
||||
|
||||
WRITE_PARAMETERS=""
|
||||
if is_docker_for_mac || is_native; then
|
||||
WRITE_PARAMETERS+="-v /etc/group:/etc/group:ro "
|
||||
WRITE_PARAMETERS+="-v /etc/passwd:/etc/passwd:ro "
|
||||
WRITE_PARAMETERS+="--user $CHE_USER "
|
||||
IFS=$' '
|
||||
for TMP_GROUP in ${CHE_USER_GROUPS}; do
|
||||
WRITE_PARAMETERS+="--group-add ${TMP_GROUP}"
|
||||
done
|
||||
fi
|
||||
|
||||
GENERATE_COMMAND="docker run -it --rm --name build-che ${WRITE_PARAMETERS} \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||
-v \"${M2_MOUNT}\":/home/user/.m2/repository \
|
||||
-v \"${ARCHETYPE_MOUNT}/${ASSEMBLY_ID}\":/home/user/che-build \
|
||||
-w /home/user/che-build \
|
||||
${UTILITY_IMAGE_DEV} \
|
||||
mvn clean install -pl '${ASSEMBLY_GROUP}.${ASSEMBLY_TYPE}:assembly-main' --am"
|
||||
log ${GENERATE_COMMAND}
|
||||
eval ${GENERATE_COMMAND}
|
||||
}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Tyler Jewell - Initial Implementation
|
||||
#
|
||||
|
||||
help_cmd_action() {
|
||||
text "\n"
|
||||
text "USAGE: ${CHE_IMAGE_FULLNAME} action <ACTION_NAME> [ACTION_PARAMETERS]\n"
|
||||
text "\n"
|
||||
text "Executes a REST action against ${CHE_MINI_PRODUCT_NAME} server or workspace.\n"
|
||||
text "\n"
|
||||
text "ACTIONS:\n"
|
||||
text " create-start-workspace\n"
|
||||
text " add-user\n"
|
||||
text " remove-user\n"
|
||||
text " execute-command\n"
|
||||
text " list-workspaces\n"
|
||||
text " workspace-ssh\n"
|
||||
text " get-ssh-data\n"
|
||||
text " graceful-stop\n"
|
||||
text "\n"
|
||||
text "Run '${CHE_IMAGE_FULLNAME} action' for action parameters"
|
||||
text "\n"
|
||||
}
|
||||
|
||||
pre_cmd_action() {
|
||||
# Not loaded as part of the init process to save on download time
|
||||
load_utilities_images_if_not_done
|
||||
}
|
||||
|
||||
post_cmd_action() {
|
||||
:
|
||||
}
|
||||
|
||||
cmd_action() {
|
||||
docker_run $(get_docker_run_terminal_options) ${UTILITY_IMAGE_CHEACTION} "$@"
|
||||
}
|
||||
|
|
@ -1,115 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Tyler Jewell - Initial Implementation
|
||||
#
|
||||
|
||||
pre_cmd_agenerate() {
|
||||
# Not loaded as part of the init process to save on download time
|
||||
|
||||
UTILITY_IMAGE_DEV="eclipse/che-dev"
|
||||
|
||||
if ! is_fast && ! skip_pull; then
|
||||
load_utilities_images_if_not_done
|
||||
update_image $UTILITY_IMAGE_DEV
|
||||
fi
|
||||
}
|
||||
|
||||
cmd_agenerate() {
|
||||
if ! $SKIP_INTERACTIVE; then
|
||||
info "archetype" "Welcome to $CHE_FORMAL_PRODUCT_NAME custom assembly generator!"
|
||||
info "archetype" ""
|
||||
info "archetype" "You can skip this message with '--no:interactive'."
|
||||
info "archetype" ""
|
||||
info "archetype" "This generator requires:"
|
||||
info "archetype" " 1. Maven 3.3+ to be installed on your host."
|
||||
info "archetype" " 2. Your host Maven M2 repo mounted to ':/m2'."
|
||||
info "archetype" " 3. A local path for us to place the assembly mounted to ':/archetype'."
|
||||
|
||||
text "\n"
|
||||
read -p " Ready? [Y/n] " -n 1 -r
|
||||
text "\n"
|
||||
if [[ $REPLY =~ ^[Nn]$ ]]; then
|
||||
return 2
|
||||
fi
|
||||
|
||||
PS3="Please enter your choice: "
|
||||
options=("agent-archetype - Assembly with sample agent" \
|
||||
"plugin-menu-archetype - Assembly with IDE extension to customize menu" \
|
||||
"plugin-wizard-archetype - Assembly with custom C project type extension" \
|
||||
"plugin-serverservice-archetype - Assembly with simple IDE extesion and a server service" \
|
||||
"plugin-embedjs-archetype - Assembly with simple IDE extesion for using native javascript in widgets" \
|
||||
"plugin-json-archetype - Assembly with sample JSON project type, editor codeassistant, and workspace services" \
|
||||
"stacks-archetype - Assembly with sample stack packaging module, for using custom stacks in assemblies")
|
||||
select opt in "${options[@]}"
|
||||
do
|
||||
case $opt in
|
||||
"agent-archetype - Assembly with sample agent")
|
||||
ARCHETYPE_ID="agent-archetype"
|
||||
break
|
||||
;;
|
||||
"plugin-menu-archetype - Assembly with IDE extension to customize menu")
|
||||
ARCHETYPE_ID="plugin-menu-archetype"
|
||||
break
|
||||
;;
|
||||
"plugin-wizard-archetype - Assembly with custom C project type extension")
|
||||
ARCHETYPE_ID="plugin-wizard-archetype"
|
||||
break
|
||||
;;
|
||||
"plugin-serverservice-archetype - Assembly with simple IDE extesion and a server service")
|
||||
ARCHETYPE_ID="plugin-serverservice-archetype"
|
||||
break
|
||||
;;
|
||||
"plugin-embedjs-archetype - Assembly with simple IDE extesion for using native javascript in widgets")
|
||||
ARCHETYPE_ID="plugin-embedjs-archetype"
|
||||
break
|
||||
;;
|
||||
"plugin-json-archetype - Assembly with sample JSON project type, editor codeassistant, and workspace services")
|
||||
ARCHETYPE_ID="plugin-json-archetype"
|
||||
break
|
||||
;;
|
||||
"stacks-archetype - Assembly with sample stack packaging module, for using custom stacks in assemblies")
|
||||
ARCHETYPE_ID="stacks-archetype"
|
||||
break
|
||||
;;
|
||||
*) echo invalid option;;
|
||||
esac
|
||||
done
|
||||
text "\n"
|
||||
fi
|
||||
|
||||
WRITE_PARAMETERS=""
|
||||
if is_docker_for_mac || is_native; then
|
||||
WRITE_PARAMETERS+="-v /etc/group:/etc/group:ro "
|
||||
WRITE_PARAMETERS+="-v /etc/passwd:/etc/passwd:ro "
|
||||
WRITE_PARAMETERS+="--user $CHE_USER "
|
||||
IFS=$' '
|
||||
for TMP_GROUP in ${CHE_USER_GROUPS}; do
|
||||
WRITE_PARAMETERS+="--group-add ${TMP_GROUP} "
|
||||
done
|
||||
fi
|
||||
|
||||
GENERATE_COMMAND="docker run -it --rm --name generate-che ${WRITE_PARAMETERS} \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||
-v \"${M2_MOUNT}\":/home/user/.m2/repository \
|
||||
-v \"${ARCHETYPE_MOUNT}\":/home/user/che-build \
|
||||
-w /home/user/che-build \
|
||||
${UTILITY_IMAGE_DEV} \
|
||||
mvn -Dmaven.repo.local=/home/user/.m2/repository/ org.apache.maven.plugins:maven-archetype-plugin:2.4:generate \
|
||||
-DarchetypeGroupId=org.eclipse.che.archetype \
|
||||
-DarchetypeArtifactId=$ARCHETYPE_ID \
|
||||
-DarchetypeVersion=$ARCHETYPE_VERSION \
|
||||
-DgroupId=$ASSEMBLY_GROUP \
|
||||
-DartifactId=$ASSEMBLY_ID \
|
||||
-Dversion=$ASSEMBLY_VERSION \
|
||||
-DinteractiveMode=false"
|
||||
log ${GENERATE_COMMAND}
|
||||
eval ${GENERATE_COMMAND}
|
||||
}
|
||||
|
|
@ -1,185 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Tyler Jewell - Initial Implementation
|
||||
#
|
||||
|
||||
help_cmd_archetype() {
|
||||
text "\n"
|
||||
text "USAGE: DOCKER_PARAMS ${CHE_IMAGE_FULLNAME} archetype ACTION [PARAMETERS]\n"
|
||||
text "\n"
|
||||
text "Use an archetype to generate, build or run a custom ${CHE_MINI_PRODUCT_NAME} assembly\n"
|
||||
text "\n"
|
||||
text "MANDATORY DOCKER PARAMETERS:\n"
|
||||
text " -v <path>:/archetype Local path where your custom assembly will be generated\n"
|
||||
text "\n"
|
||||
text "OPTIONAL DOCKER PARAMETERS:\n"
|
||||
text " -v <path>:/m2 Local path to your host's Maven M2 repository\n"
|
||||
text "\n"
|
||||
text "ACTION:\n"
|
||||
text " all Generate, build and run a new custom assembly\n"
|
||||
text " generate Generate a new custom assembly to folder mounted to '/archetype'\n"
|
||||
text " build Uses 'eclipse/che-dev' image to compile archetype in '/archetype'\n"
|
||||
text " run Starts ${CHE_MINI_PRODUCT_NAME} from custom assembly in '/archetype'\n"
|
||||
text "\n"
|
||||
text "PARAMETERS:\n"
|
||||
text " --che For run and stop commands. Select Che assembly\n"
|
||||
text " --codenvy For run and stop commands. Select Codenvy assembly\n"
|
||||
text " --archid=<id> Different archetypes generate different types of customizations\n"
|
||||
text " --archversion=<version> Sets archetype version - default = tag of CLI image\n"
|
||||
text " --version=<version> Sets custom assembly version - default = archetype version\n"
|
||||
text " --group=<group> Sets groupId of generated assembly - default = com.sample\n"
|
||||
text " --id=<id> Sets artifaceId of generated assembly - default = assembly\n"
|
||||
text " --no:interactive Disables interactive mode\n"
|
||||
text "\n"
|
||||
text "An assembly is a bundling of extensions, plugins, stacks, agents, branding elements, and a CLI\n"
|
||||
text "that can be built into a new binary for distribution. In essence, an assemly is a custom ${CHE_MINI_PRODUCT_NAME}.\n"
|
||||
text "\n"
|
||||
text "An archetype is a maven technique for generating code templates. A single archetype has an ID and\n"
|
||||
text "generates a complete custom assembly. Differnent archetypes generate assemblies with different\n"
|
||||
text "types of customizations. We make each archetype customize the minimal number of features to make\n"
|
||||
text "learning about customizations simpler.\n"
|
||||
text "\n"
|
||||
text "Your host system must have Maven 3.3+ installed to facilitate generation and compiling of custom\n"
|
||||
text "assemblies. You must pass in your Maven's M2 repository path on your host. Our archetype generator\n"
|
||||
text "will download libraries into that repository making repeated compilations faster over time.\n"
|
||||
text "On most Linux based systems, your M2 repo is located at '/home/user/.m2/repository' and it is\n"
|
||||
text "'%%USERPROFILE%%/.m2/repostory 'for Windows. We default your M2 home to '/home/user/.m2'. If your.\n"
|
||||
text "local Maven pom.xml changes the location of the repository, put the full path to the repo.\n"
|
||||
text "\n"
|
||||
text "Your custom assembly will be generated in the host path mounted to '/archetype'. This generates a \n"
|
||||
text "Maven multi-module project. You can enter the folder and build it with 'mvn clean install' or use\n"
|
||||
text "this utility to build it. Compiling an assembly requires other tools like Java, Angular, Go to be\n"
|
||||
text "installed on your host system. However, if you use this tool to compile your custom assembly we\n"
|
||||
text "use 'eclipse/che-dev' Docker image which contains all of these utilities preinstalled. It is simple\n"
|
||||
text "but is a large download >1GB and compilation is slower than using your host since the Docker\n"
|
||||
text "container is performing compilation against files that are host-mounted.\n"
|
||||
}
|
||||
|
||||
pre_cmd_archetype() {
|
||||
if [ $# -eq 0 ]; then
|
||||
help_cmd_archetype
|
||||
return 2;
|
||||
fi
|
||||
|
||||
ARCHETYPE_ACTION="all"
|
||||
ARCHETYPE_ID="plugin-menu-archetype"
|
||||
|
||||
##############################
|
||||
ARCHETYPE_VERSION=$(get_image_version)
|
||||
ASSEMBLY_VERSION=$ARCHETYPE_VERSION
|
||||
ASSEMBLY_GROUP="com.sample"
|
||||
ASSEMBLY_ID="assembly"
|
||||
SKIP_INTERACTIVE=false
|
||||
ASSEMBLY_TYPE="che"
|
||||
|
||||
for i in "$@"
|
||||
do
|
||||
case $1 in
|
||||
all|generate|build|run|stop)
|
||||
ARCHETYPE_ACTION=$1
|
||||
shift
|
||||
;;
|
||||
|
||||
--che)
|
||||
ASSEMBLY_TYPE="che"
|
||||
shift
|
||||
;;
|
||||
|
||||
--codenvy)
|
||||
ASSEMBLY_TYPE="codenvy"
|
||||
shift
|
||||
;;
|
||||
|
||||
--archid=*)
|
||||
ARCHETYPE_ID="${i#*=}"
|
||||
shift
|
||||
;;
|
||||
|
||||
--archversion=*)
|
||||
ARCHETYPE_VERSION="${i#*=}"
|
||||
shift
|
||||
;;
|
||||
|
||||
--version=*)
|
||||
ASSEMBLY_VERSION="${i#*=}"
|
||||
shift
|
||||
;;
|
||||
|
||||
--group=*)
|
||||
ASSEMBLY_GROUP="${i#*=}"
|
||||
shift
|
||||
;;
|
||||
|
||||
--id=*)
|
||||
ASSEMBLY_ID="${i#*=}"
|
||||
shift
|
||||
;;
|
||||
|
||||
--no:interactive)
|
||||
SKIP_INTERACTIVE=true
|
||||
shift
|
||||
;;
|
||||
|
||||
*)
|
||||
# unknown option
|
||||
error "You passed an unknown command line option."
|
||||
return 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
ARCHETYPE_MOUNT=$(get_container_folder ":/archetype")
|
||||
M2_MOUNT=$(get_container_folder ":/m2")
|
||||
|
||||
if [[ "${ARCHETYPE_MOUNT}" = "not set" ]]; then
|
||||
info "Welcome to $CHE_FORMAL_PRODUCT_NAME custom assembly generator!"
|
||||
info ""
|
||||
info "We could not detect a location to create your custom assembly."
|
||||
info "Volume mount a local directory to ':/archetype'."
|
||||
info ""
|
||||
info "Syntax:"
|
||||
info " docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock"
|
||||
info " -v <DATA_LOCAL_PATH>:${CHE_CONTAINER_ROOT}"
|
||||
info " -v <ASSEMBLY_LOCAL_PATH>:/archetype"
|
||||
info " ${CHE_IMAGE_FULLNAME} archetype $*"
|
||||
info ""
|
||||
return 2;
|
||||
fi
|
||||
|
||||
if [[ "${M2_MOUNT}" = "not set" ]]; then
|
||||
warning "archetype" "Maven M2 repository detected - setting to '/home/user/.m2/repository'"
|
||||
M2_MOUNT="/home/user/.m2/repository"
|
||||
fi
|
||||
}
|
||||
|
||||
cmd_archetype() {
|
||||
cd /archetype
|
||||
|
||||
case $ARCHETYPE_ACTION in
|
||||
generate)
|
||||
cmd_lifecycle agenerate
|
||||
;;
|
||||
build)
|
||||
cmd_lifecycle abuild
|
||||
;;
|
||||
run)
|
||||
cmd_lifecycle arun
|
||||
;;
|
||||
stop)
|
||||
cmd_lifecycle astop
|
||||
;;
|
||||
all)
|
||||
cmd_lifecycle agenerate || true
|
||||
cmd_lifecycle abuild || true
|
||||
cmd_lifecycle arun || true
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Tyler Jewell - Initial Implementation
|
||||
#
|
||||
|
||||
pre_cmd_arun() {
|
||||
if [ ! -d /archetype/$ASSEMBLY_ID ]; then
|
||||
error "Assembly at ${ARCHETYPE_MOUNT}/$ASSEMBLY_ID not found."
|
||||
return 2
|
||||
fi
|
||||
}
|
||||
|
||||
cmd_arun() {
|
||||
|
||||
case $ASSEMBLY_TYPE in
|
||||
codenvy ) CLI_IMAGE=codenvy/cli:nightly
|
||||
DATA_MOUNT=$HOME/.codenvy/sample/data
|
||||
ASSEMBLY_LOCATION=$ASSEMBLY_ID/assembly-codenvy/assembly-main/target/codenvy-onpremises-$ASSEMBLY_VERSION
|
||||
;;
|
||||
che ) CLI_IMAGE=eclipse/che-cli:nightly
|
||||
DATA_MOUNT=$HOME/.che/sample/data
|
||||
ASSEMBLY_LOCATION=$ASSEMBLY_ID/assembly-che/assembly-main/target/eclipse-che-$ASSEMBLY_VERSION/eclipse-che-$ASSEMBLY_VERSION
|
||||
;;
|
||||
esac
|
||||
|
||||
cd /archetype/$ASSEMBLY_ID
|
||||
|
||||
RUN_COMMAND="docker run -it --rm --name run-che \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||
-v \"${DATA_MOUNT}\":${CHE_CONTAINER_ROOT} \
|
||||
-v \"${ARCHETYPE_MOUNT}\"/\"${ASSEMBLY_LOCATION}\":/assembly \
|
||||
${CLI_IMAGE} \
|
||||
start --skip:nightly"
|
||||
log ${RUN_COMMAND}
|
||||
eval ${RUN_COMMAND}
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Tyler Jewell - Initial Implementation
|
||||
#
|
||||
|
||||
pre_cmd_astop() {
|
||||
if [ ! -d /archetype/$ASSEMBLY_ID ]; then
|
||||
error "Assembly at ${ARCHETYPE_MOUNT}/$ASSEMBLY_ID not found."
|
||||
return 2
|
||||
fi
|
||||
}
|
||||
|
||||
cmd_astop() {
|
||||
|
||||
case $ASSEMBLY_TYPE in
|
||||
codenvy ) CLI_IMAGE=codenvy/cli:nightly
|
||||
DATA_MOUNT=$HOME/.codenvy/sample/data
|
||||
ASSEMBLY_LOCATION=$ASSEMBLY_ID/assembly-codenvy/assembly-main/target/codenvy-onpremises-$ASSEMBLY_VERSION
|
||||
;;
|
||||
che ) CLI_IMAGE=eclipse/che-cli:nightly
|
||||
DATA_MOUNT=$HOME/.che/sample/data
|
||||
ASSEMBLY_LOCATION=$ASSEMBLY_ID/assembly-che/assembly-main/target/eclipse-che-$ASSEMBLY_VERSION/eclipse-che-$ASSEMBLY_VERSION
|
||||
;;
|
||||
esac
|
||||
|
||||
cd /archetype/$ASSEMBLY_ID
|
||||
|
||||
STOP_COMMAND="docker run -it --rm --name run-che \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||
-v \"${DATA_MOUNT}\":${CHE_CONTAINER_ROOT} \
|
||||
-v \"${ARCHETYPE_MOUNT}\"/\"${ASSEMBLY_LOCATION}\":/assembly \
|
||||
${CLI_IMAGE} \
|
||||
stop --skip:nightly --skip:graceful"
|
||||
log ${STOP_COMMAND}
|
||||
eval ${STOP_COMMAND}
|
||||
}
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Tyler Jewell - Initial Implementation
|
||||
#
|
||||
|
||||
help_cmd_backup() {
|
||||
text "\n"
|
||||
text "USAGE: ${CHE_IMAGE_FULLNAME} backup [PARAMETERS]\n"
|
||||
text "\n"
|
||||
text "Backup ${CHE_MINI_PRODUCT_NAME} configuration and user data\n"
|
||||
text "\n"
|
||||
text "PARAMETERS:\n"
|
||||
text " --no-skip-data Excludes user data in /instance/data\n"
|
||||
text "\n"
|
||||
}
|
||||
|
||||
pre_cmd_backup() {
|
||||
:
|
||||
}
|
||||
|
||||
post_cmd_backup() {
|
||||
:
|
||||
}
|
||||
|
||||
cmd_backup() {
|
||||
# possibility to skip ${CHE_FORMAL_PRODUCT_NAME} projects backup
|
||||
SKIP_BACKUP_CHE_DATA=${1:-"--no-skip-data"}
|
||||
if [[ "${SKIP_BACKUP_CHE_DATA}" == "--skip-data" ]]; then
|
||||
TAR_EXTRA_EXCLUDE="--exclude=instance/data${CHE_CONTAINER_ROOT}"
|
||||
else
|
||||
TAR_EXTRA_EXCLUDE=""
|
||||
fi
|
||||
|
||||
if [[ ! -d "${CHE_CONTAINER_CONFIG}" ]]; then
|
||||
error "Cannot find existing CHE_CONFIG or CHE_INSTANCE."
|
||||
return;
|
||||
fi
|
||||
|
||||
if get_server_container_id "${CHE_SERVER_CONTAINER_NAME}" >> "${LOGS}" 2>&1; then
|
||||
error "$CHE_MINI_PRODUCT_NAME is running. Stop before performing a backup."
|
||||
return 2;
|
||||
fi
|
||||
|
||||
if [[ ! -d "${CHE_CONTAINER_BACKUP}" ]]; then
|
||||
mkdir -p "${CHE_CONTAINER_BACKUP}"
|
||||
fi
|
||||
|
||||
# check if backups already exist and if so we move it with time stamp in name
|
||||
if [[ -f "${CHE_CONTAINER_BACKUP}/${CHE_BACKUP_FILE_NAME}" ]]; then
|
||||
mv "${CHE_CONTAINER_BACKUP}/${CHE_BACKUP_FILE_NAME}" \
|
||||
"${CHE_CONTAINER_BACKUP}/moved-$(get_current_date)-${CHE_BACKUP_FILE_NAME}"
|
||||
fi
|
||||
|
||||
info "backup" "Saving Eclipse Che data..."
|
||||
docker_run -v "${CHE_HOST_CONFIG}":/root${CHE_CONTAINER_ROOT} \
|
||||
-v "${CHE_HOST_BACKUP}":/root/backup \
|
||||
$(cmd_backup_extra_args) \
|
||||
${BOOTSTRAP_IMAGE_ALPINE} sh -c "tar czf /root/backup/${CHE_BACKUP_FILE_NAME} -C /root${CHE_CONTAINER_ROOT} . --exclude='backup' --exclude='instance/dev' --exclude='instance/logs' ${TAR_EXTRA_EXCLUDE}"
|
||||
info ""
|
||||
info "backup" "${CHE_MINI_PRODUCT_NAME} data saved in ${CHE_HOST_BACKUP}/${CHE_BACKUP_FILE_NAME}"
|
||||
}
|
||||
|
||||
cmd_backup_extra_args() {
|
||||
echo ""
|
||||
}
|
||||
|
||||
# return date in format which can be used as a unique file or dir name
|
||||
# example 2016-10-31-1477931458
|
||||
get_current_date() {
|
||||
date +'%Y-%m-%d-%s'
|
||||
}
|
||||
|
|
@ -1,207 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Tyler Jewell - Initial Implementation
|
||||
#
|
||||
|
||||
help_cmd_config() {
|
||||
text "\n"
|
||||
text "USAGE: ${CHE_IMAGE_FULLNAME} config [PARAMETERS]\n"
|
||||
text "\n"
|
||||
text "Generate a ${CHE_MINI_PRODUCT_NAME} runtime configuration into /instance. The configurator uses
|
||||
values from your host, ${CHE_MINI_PRODUCT_NAME}.env, and optionally your local repository to generate
|
||||
a runtime configuration used to start and stop ${CHE_MINI_PRODUCT_NAME}. A configuration is generated
|
||||
before every execution of ${CHE_MINI_PRODUCT_NAME}. The configuration phase will download all Docker
|
||||
images required to start or stop ${CHE_MINI_PRODUCT_NAME} to guarantee that the right images are cached
|
||||
before execution. If you have mounted a local repository or assembly, the ${CHE_MINI_PRODUCT_NAME} Docker
|
||||
images will use those binaries instead of their embedded ones.\n"
|
||||
text "\n"
|
||||
text "PARAMETERS:\n"
|
||||
text " --force Uses 'docker rmi' and 'docker pull' to forcibly retrieve latest images\n"
|
||||
text " --no-force Updates images if matching tag not found in local cache\n"
|
||||
text " --pull Uses 'docker pull' to check for new remote versions of images\n"
|
||||
text " --skip:config Skip re-generation of config files placed into /instance\n"
|
||||
text "\n"
|
||||
}
|
||||
|
||||
pre_cmd_config() {
|
||||
CHE_SKIP_CONFIG=false
|
||||
FORCE_UPDATE="--no-force"
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
--skip:config)
|
||||
CHE_SKIP_CONFIG=true
|
||||
shift ;;
|
||||
--force)
|
||||
FORCE_UPDATE="--force"
|
||||
shift ;;
|
||||
--no-force)
|
||||
FORCE_UPDATE="--no-force"
|
||||
shift ;;
|
||||
--pull)
|
||||
FORCE_UPDATE="--pull"
|
||||
shift ;;
|
||||
*) error "Unknown parameter: $1" return 2 ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
post_cmd_config() {
|
||||
:
|
||||
}
|
||||
|
||||
cmd_config() {
|
||||
# If the system is not initialized, initalize it.
|
||||
# If the system is already initialized, but a user wants to update images, then re-download.
|
||||
if ! is_initialized; then
|
||||
cmd_lifecycle init $FORCE_UPDATE
|
||||
elif [[ "${FORCE_UPDATE}" == "--pull" ]] || \
|
||||
[[ "${FORCE_UPDATE}" == "--force" ]]; then
|
||||
cmd_lifecycle download $FORCE_UPDATE
|
||||
elif is_nightly && ! is_fast && ! skip_pull; then
|
||||
cmd_lifecycle download --pull
|
||||
fi
|
||||
|
||||
# If using a local repository, then we need to always perform an updated init with those files
|
||||
if local_repo; then
|
||||
# if user has mounted local repo, use configuration files from the repo.
|
||||
# please note that in production mode update of configuration sources must be only on update.
|
||||
docker_run -v "${CHE_HOST_CONFIG}":/copy \
|
||||
-v "${CHE_HOST_DEVELOPMENT_REPO}"/dockerfiles/init:/files \
|
||||
$IMAGE_INIT
|
||||
|
||||
fi
|
||||
|
||||
# Run the docker configurator
|
||||
if ! skip_config; then
|
||||
generate_configuration_with_puppet
|
||||
fi
|
||||
|
||||
# Replace certain environment file lines with their container counterparts
|
||||
info "config" "Customizing docker-compose for running in a container"
|
||||
|
||||
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
|
||||
log "docker_run -v \"${CHE_HOST_INSTANCE}/dev\":/root/dev ${BOOTSTRAP_IMAGE_ALPINE} sh -c \"rm -rf /root/dev/*\""
|
||||
|
||||
# Super weird bug - sometimes, the RM command doesn't wipe everything, so we have to repeat it a couple times
|
||||
until config_directory_is_empty; do
|
||||
docker_run -v "${CHE_HOST_INSTANCE}/dev":/root/dev ${BOOTSTRAP_IMAGE_ALPINE} sh -c "rm -rf /root/dev/${CHE_MINI_PRODUCT_NAME}-tomcat" > /dev/null 2>&1 || true
|
||||
done
|
||||
|
||||
log "rm -rf \"${CHE_HOST_INSTANCE}/dev\" >> \"${LOGS}\""
|
||||
rm -rf "${CHE_CONTAINER_INSTANCE}/dev"
|
||||
fi
|
||||
|
||||
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_ASSEMBLY_FULL_PATH})/." \
|
||||
"${CHE_CONTAINER_INSTANCE}/dev/${CHE_MINI_PRODUCT_NAME}-tomcat/"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Runs puppet image to generate che configuration
|
||||
generate_configuration_with_puppet() {
|
||||
info "config" "Generating $CHE_MINI_PRODUCT_NAME configuration..."
|
||||
|
||||
if is_docker_for_windows; then
|
||||
CHE_ENV_FILE=$(convert_posix_to_windows "${CHE_HOST_INSTANCE}/config/$CHE_MINI_PRODUCT_NAME.env")
|
||||
else
|
||||
CHE_ENV_FILE="${CHE_HOST_INSTANCE}/config/$CHE_MINI_PRODUCT_NAME.env"
|
||||
fi
|
||||
|
||||
if debug_server; then
|
||||
CHE_ENVIRONMENT="development"
|
||||
WRITE_LOGS=""
|
||||
else
|
||||
CHE_ENVIRONMENT="production"
|
||||
WRITE_LOGS=">> \"${LOGS}\""
|
||||
fi
|
||||
|
||||
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"
|
||||
fi
|
||||
if [ -d "/repo/dockerfiles/init/modules" ]; then
|
||||
WRITE_PARAMETERS+=" -v \"${CHE_HOST_DEVELOPMENT_REPO}/dockerfiles/init/modules\":/etc/puppet/modules:ro"
|
||||
fi
|
||||
# Handle override/addon
|
||||
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"
|
||||
if [ -d "/repo/dockerfiles/init/addon/modules" ]; then
|
||||
WRITE_PARAMETERS+=" -v \"${CHE_HOST_DEVELOPMENT_REPO}/dockerfiles/init/addon/modules/\":/etc/puppet/addon/:ro"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
for element in "${CLI_ENV_ARRAY[@]}"
|
||||
do
|
||||
var1=$(echo $element | cut -f1 -d=)
|
||||
var2=$(echo $element | cut -f2 -d=)
|
||||
|
||||
if [[ $var1 == CHE_* ]] ||
|
||||
[[ $var1 == IMAGE_* ]] ||
|
||||
[[ $var1 == *_IMAGE_* ]] ||
|
||||
[[ $var1 == ${CHE_PRODUCT_NAME}_* ]]; then
|
||||
WRITE_PARAMETERS+=" -e $var1='$var2'"
|
||||
fi
|
||||
done
|
||||
|
||||
GENERATE_CONFIG_COMMAND="docker_run \
|
||||
--env-file=\"${REFERENCE_CONTAINER_ENVIRONMENT_FILE}\" \
|
||||
--env-file=/version/$CHE_VERSION/images \
|
||||
-v \"${CHE_HOST_INSTANCE}\":/opt/${CHE_MINI_PRODUCT_NAME}:rw \
|
||||
${WRITE_PARAMETERS} \
|
||||
-e \"CHE_ENV_FILE=${CHE_ENV_FILE}\" \
|
||||
-e \"CHE_CONTAINER_ROOT=${CHE_CONTAINER_ROOT}\" \
|
||||
-e \"CHE_CONTAINER_NAME=${CHE_CONTAINER_NAME}\" \
|
||||
-e \"CHE_ENVIRONMENT=${CHE_ENVIRONMENT}\" \
|
||||
-e \"CHE_CONFIG=${CHE_HOST_INSTANCE}\" \
|
||||
-e \"CHE_USER=${CHE_USER}\" \
|
||||
-e \"CHE_INSTANCE=${CHE_HOST_INSTANCE}\" \
|
||||
-e \"CHE_REPO=${CHE_REPO}\" \
|
||||
--entrypoint=/usr/bin/puppet \
|
||||
$IMAGE_INIT \
|
||||
apply --modulepath \
|
||||
/etc/puppet/modules/:/etc/puppet/addon/ \
|
||||
/etc/puppet/manifests/ --show_diff ${WRITE_LOGS}"
|
||||
|
||||
log ${GENERATE_CONFIG_COMMAND}
|
||||
eval ${GENERATE_CONFIG_COMMAND}
|
||||
}
|
||||
|
||||
config_directory_is_empty() {
|
||||
if [[ -d "${CHE_CONTAINER_INSTANCE}/dev/${CHE_MINI_PRODUCT_NAME}-tomcat" ]]; then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
|
@ -1,99 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Tyler Jewell - Initial Implementation
|
||||
#
|
||||
|
||||
help_cmd_destroy() {
|
||||
text "\n"
|
||||
text "USAGE: ${CHE_IMAGE_FULLNAME} destroy [PARAMETERS]\n"
|
||||
text "\n"
|
||||
text "Deletes a ${CHE_MINI_PRODUCT_NAME} installation\n"
|
||||
text "\n"
|
||||
text "PARAMETERS:\n"
|
||||
text " --quiet Do not ask user for confirmation\n"
|
||||
text " --cli Removes the 'cli.log'\n"
|
||||
text "\n"
|
||||
}
|
||||
|
||||
|
||||
pre_cmd_destroy() {
|
||||
:
|
||||
}
|
||||
|
||||
post_cmd_destroy() {
|
||||
:
|
||||
}
|
||||
|
||||
cmd_destroy_post_action() {
|
||||
true
|
||||
}
|
||||
|
||||
cmd_destroy() {
|
||||
debug $FUNCNAME
|
||||
|
||||
QUIET=""
|
||||
DESTROY_CLI="false"
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
--quiet)
|
||||
QUIET="--quiet"
|
||||
shift ;;
|
||||
--cli)
|
||||
DESTROY_CLI="true"
|
||||
shift ;;
|
||||
*) error "Unknown parameter: $1; did you mean --quiet or --cli?" ; return 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
WARNING="${YELLOW}!!!${RED} Stopping services and ${YELLOW}!!!${RED} deleting data ${YELLOW}!!!${RED} this is unrecoverable ${YELLOW}!!!${NC}"
|
||||
if ! confirm_operation "${WARNING}" "${QUIET}"; then
|
||||
return;
|
||||
fi
|
||||
|
||||
cmd_lifecycle stop --skip:graceful
|
||||
|
||||
info "destroy" "Deleting instance and config..."
|
||||
|
||||
log "docker_run -v \"${CHE_HOST_CONFIG}\":${CHE_CONTAINER_ROOT} \
|
||||
${BOOTSTRAP_IMAGE_ALPINE} sh -c \"rm -rf /root${CHE_CONTAINER_ROOT}/docs \
|
||||
&& rm -rf /root${CHE_CONTAINER_ROOT}/instance \
|
||||
&& rm -rf /root${CHE_CONTAINER_ROOT}/${CHE_MINI_PRODUCT_NAME}.env\""
|
||||
# Super weird bug. For some reason on windows, this command has to be run 3x for everything
|
||||
# to be destroyed properly if you are in dev mode.
|
||||
until directory_is_empty; do
|
||||
docker_run -v "${CHE_HOST_CONFIG}":/root${CHE_CONTAINER_ROOT} \
|
||||
${BOOTSTRAP_IMAGE_ALPINE} sh -c "rm -rf /root${CHE_CONTAINER_ROOT}/docs \
|
||||
; rm -rf /root${CHE_CONTAINER_ROOT}/instance \
|
||||
; rm -rf /root${CHE_CONTAINER_ROOT}/${CHE_MINI_PRODUCT_NAME}.env" > /dev/null 2>&1 || true
|
||||
done
|
||||
rm -rf "${CHE_CONTAINER_INSTANCE}"
|
||||
|
||||
cmd_destroy_post_action
|
||||
|
||||
# Sometimes users want the CLI log after they have destroyed their instance
|
||||
# If they pass destroy --cli then we will also destroy the CLI log
|
||||
if [[ "${DESTROY_CLI}" = "true" ]]; then
|
||||
info "destroy" "Deleting cli.log..."
|
||||
docker_run -v "${CHE_HOST_CONFIG}":/root${CHE_CONTAINER_ROOT} \
|
||||
${BOOTSTRAP_IMAGE_ALPINE} sh -c "rm -rf /root${CHE_CONTAINER_ROOT}/cli.log" > /dev/null 2>&1 || true
|
||||
fi
|
||||
}
|
||||
|
||||
directory_is_empty() {
|
||||
if [[ -d "${CHE_CONTAINER_CONFIG}/docs" ]] ||
|
||||
[[ -d "${CHE_CONTAINER_CONFIG}/instance" ]] ||
|
||||
[[ -f "${CHE_CONTAINER_CONFIG}/${CHE_MINI_PRODUCT_NAME}.env" ]]; then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
|
||||
help_cmd_dir() {
|
||||
text "\n"
|
||||
text "USAGE: ${CHE_IMAGE_FULLNAME} dir COMMAND [PARAMETERS]\n"
|
||||
text "\n"
|
||||
text "Create a workspace using a local directory mounted to ':\chedir'\n"
|
||||
text "\n"
|
||||
text "COMMANDS:\n"
|
||||
text " init Initializes an empty local directory with a new Chefile\n"
|
||||
text " down Stops the workspace and ${CHE_MINI_PRODUCT_NAME} representing this directory\n"
|
||||
text " ssh SSH into the workspace that represents the local directory\n"
|
||||
text " status Reports on the runtime status of ${CHE_MINI_PRODUCT_NAME} and the workspace runtime\n"
|
||||
text " up Starts ${CHE_MINI_PRODUCT_NAME} and creates a new workspace with a project from your local dir\n"
|
||||
text "\n"
|
||||
}
|
||||
|
||||
pre_cmd_dir() {
|
||||
# Not loaded as part of the init process to save on download time
|
||||
load_utilities_images_if_not_done
|
||||
}
|
||||
|
||||
post_cmd_dir() {
|
||||
:
|
||||
}
|
||||
|
||||
cmd_dir() {
|
||||
CHE_LOCAL_REPO=false
|
||||
if [[ "${CHEDIR_MOUNT}" != "not set" ]]; then
|
||||
local HOST_FOLDER_TO_USE="${CHEDIR_MOUNT}"
|
||||
else
|
||||
local HOST_FOLDER_TO_USE="${DATA_MOUNT}"
|
||||
|
||||
warning "':/chedir' not mounted - using ${DATA_MOUNT} as source location"
|
||||
fi
|
||||
|
||||
docker_run $(get_docker_run_terminal_options) -v ${HOST_FOLDER_TO_USE}:${HOST_FOLDER_TO_USE} \
|
||||
${UTILITY_IMAGE_CHEDIR} ${HOST_FOLDER_TO_USE} "$@"
|
||||
}
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Tyler Jewell - Initial Implementation
|
||||
#
|
||||
|
||||
help_cmd_download() {
|
||||
text "\n"
|
||||
text "USAGE: ${CHE_IMAGE_FULLNAME} download [PARAMETERS]\n"
|
||||
text "\n"
|
||||
text "Downloads Docker images required to execute ${CHE_MINI_PRODUCT_NAME}\n"
|
||||
text "\n"
|
||||
text "PARAMETERS:\n"
|
||||
text " --force Uses 'docker rmi' and 'docker pull' to forcibly retrieve latest images\n"
|
||||
text " --no-force Updates images if matching tag not found in local cache\n"
|
||||
text " --pull Uses 'docker pull' to check for new remote versions of images\n"
|
||||
text "\n"
|
||||
}
|
||||
|
||||
pre_cmd_download() {
|
||||
:
|
||||
}
|
||||
|
||||
post_cmd_download() {
|
||||
:
|
||||
}
|
||||
|
||||
|
||||
cmd_download() {
|
||||
FORCE_UPDATE=${1:-"--no-force"}
|
||||
local IMAGES=${IMAGE_LIST}
|
||||
IMAGES+=$'\n'${BOOTSTRAP_IMAGE_LIST}
|
||||
IMAGES+=$'\n'${UTILITY_IMAGE_LIST}
|
||||
|
||||
IFS=$'\n'
|
||||
for SINGLE_IMAGE in $IMAGES; do
|
||||
VALUE_IMAGE=$(echo $SINGLE_IMAGE | cut -d'=' -f2)
|
||||
if [[ $FORCE_UPDATE == "--force" ]] ||
|
||||
[[ $FORCE_UPDATE == "--pull" ]]; then
|
||||
update_image $FORCE_UPDATE $VALUE_IMAGE
|
||||
else
|
||||
update_image_if_not_found $VALUE_IMAGE
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Tyler Jewell - Initial Implementation
|
||||
#
|
||||
|
||||
help_cmd_help() {
|
||||
text "\n"
|
||||
text "Usage: ${CHE_IMAGE_FULLNAME} help"
|
||||
text "\n"
|
||||
}
|
||||
|
||||
cmd_help() {
|
||||
usage
|
||||
}
|
||||
|
||||
pre_cmd_help() {
|
||||
:
|
||||
}
|
||||
|
||||
post_cmd_help() {
|
||||
:
|
||||
}
|
||||
|
|
@ -1,194 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Tyler Jewell - Initial Implementation
|
||||
#
|
||||
|
||||
help_cmd_info() {
|
||||
text "\n"
|
||||
text "USAGE: ${CHE_IMAGE_FULLNAME} info [PARAMETERS]\n"
|
||||
text "\n"
|
||||
text "Status, information, and support diagnostic bundles for ${CHE_MINI_PRODUCT_NAME}\n"
|
||||
text "\n"
|
||||
text "PARAMETERS:\n"
|
||||
text " --all Prints info, runs networking tests, ad prepares diagnostic bundle\n"
|
||||
text " --bundle Prepares diagnostic bundle for ${CHE_MINI_PRODUCT_NAME} and Docker\n"
|
||||
text " --network Runs simulated network diagnostic to confirm network routing\n"
|
||||
text " --print Default - displays status and configuration of ${CHE_MINI_PRODUCT_NAME}\n"
|
||||
text "\n"
|
||||
}
|
||||
|
||||
|
||||
pre_cmd_info() {
|
||||
:
|
||||
}
|
||||
|
||||
post_cmd_info() {
|
||||
:
|
||||
}
|
||||
|
||||
cmd_info() {
|
||||
debug $FUNCNAME
|
||||
if [ $# -eq 0 ]; then
|
||||
TESTS="--print"
|
||||
else
|
||||
TESTS=$1
|
||||
fi
|
||||
|
||||
case $TESTS in
|
||||
--all|-all)
|
||||
print_info
|
||||
cmd_network
|
||||
prepare_bundle
|
||||
;;
|
||||
--network|-network)
|
||||
cmd_network
|
||||
;;
|
||||
--print|-print)
|
||||
print_info
|
||||
;;
|
||||
--bundle|-bundle)
|
||||
prepare_bundle
|
||||
;;
|
||||
*)
|
||||
info "info" "Unknown info flag passed: $1."
|
||||
return;
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
prepare_bundle() {
|
||||
info "info" "Preparing diagnostic bundle..."
|
||||
docker run --net host ${BOOTSTRAP_IMAGE_ALPINE} ip a show >> "${CLI_DIR}/ip.output"
|
||||
docker run --net host ${BOOTSTRAP_IMAGE_ALPINE} route >> "${CLI_DIR}/route.output"
|
||||
curl -s https://hub.docker.com/v2/repositories/${CHE_IMAGE_NAME}/tags/ >> "${CLI_DIR}/curlversion.output"
|
||||
curl -I -k https://hub.docker.com >> "${CLI_DIR}/curldockerhub.output"
|
||||
df "${CHE_CONTAINER_ROOT}" >> "${CLI_DIR}/df.output"
|
||||
cmd_network >> "${CLI_DIR}/cli-network.output"
|
||||
print_info >> "${CLI_DIR}/cli-info.output"
|
||||
|
||||
tar -cf "${CLI_DIR}"/${CHE_MINI_PRODUCT_NAME}-diagnostic-bundle.tar \
|
||||
"${CLI_DIR}/ip.output" \
|
||||
"${CLI_DIR}/route.output" \
|
||||
"${CLI_DIR}/curlversion.output" \
|
||||
"${CLI_DIR}/curldockerhub.output" \
|
||||
"${CLI_DIR}/df.output" \
|
||||
"${CLI_DIR}/cli.log" \
|
||||
"${CLI_DIR}/cli-network.output" \
|
||||
"${CLI_DIR}/cli-info.output" \
|
||||
"${CHE_CONTAINER_INSTANCE}/logs" > /dev/null 2>&1 || true
|
||||
|
||||
|
||||
info "info" "Diagnostic bundle ${CHE_MINI_PRODUCT_NAME}-diagnostic-bundle.tar prepared"
|
||||
|
||||
# Clean
|
||||
docker_run -v "${CHE_HOST_CONFIG}":/root${CHE_CONTAINER_ROOT} \
|
||||
${BOOTSTRAP_IMAGE_ALPINE} \
|
||||
sh -c "rm -rf /root${CHE_CONTAINER_ROOT}/ip.output \
|
||||
; rm -rf /root${CHE_CONTAINER_ROOT}/route.output \
|
||||
; rm -rf /root${CHE_CONTAINER_ROOT}/curlversion.output \
|
||||
; rm -rf /root${CHE_CONTAINER_ROOT}/curldockerhub.output \
|
||||
; rm -rf /root${CHE_CONTAINER_ROOT}/df.output \
|
||||
; rm -rf /root${CHE_CONTAINER_ROOT}/cli-info.output \
|
||||
; rm -rf /root${CHE_CONTAINER_ROOT}/cli-network.output" > /dev/null 2>&1 || true
|
||||
}
|
||||
|
||||
print_info() {
|
||||
DOCKER_CONNECT="${DOCKER_MOUNT}"
|
||||
if [[ "${DOCKER_MOUNT}" = "not set" ]]; then
|
||||
DOCKER_CONNECT=$(docker inspect $(get_this_container_id) | grep DOCKER_HOST)
|
||||
DOCKER_CONNECT=${DOCKER_CONNECT//\"}
|
||||
DOCKER_CONNECT=${DOCKER_CONNECT//\,}
|
||||
DOCKER_CONNECT=${DOCKER_CONNECT#*=}
|
||||
fi
|
||||
text "\n"
|
||||
text "CLI:\n"
|
||||
text " TTY: ${TTY_ACTIVATED}\n"
|
||||
text " Daemon: ${DOCKER_CONNECT}\n"
|
||||
text " Image: ${CHE_IMAGE_FULLNAME}\n"
|
||||
text " Version: ${CHE_IMAGE_VERSION}\n"
|
||||
text " Command: $(echo $COMMAND | cut -f2 -d'_')\n"
|
||||
text " Parameters: ${ORIGINAL_PARAMETERS}\n"
|
||||
text "Mounts:\n"
|
||||
text " $CHE_CONTAINER_ROOT: $DATA_MOUNT\n"
|
||||
text " $CHE_CONTAINER_ROOT/instance: $INSTANCE_MOUNT\n"
|
||||
text " $CHE_CONTAINER_ROOT/backup: $BACKUP_MOUNT\n"
|
||||
text " /repo: $REPO_MOUNT\n"
|
||||
text " /assembly: $ASSEMBLY_MOUNT\n"
|
||||
text " /sync: $SYNC_MOUNT\n"
|
||||
text " /unison: $UNISON_PROFILE_MOUNT\n"
|
||||
text " /chedir: $CHEDIR_MOUNT\n"
|
||||
text "System:\n"
|
||||
text " Docker: $(get_docker_install_type)\n"
|
||||
if [[ ${HTTP_PROXY} = "" ]] &&
|
||||
[[ ${HTTPS_PROXY} = "" ]] &&
|
||||
[[ ${NO_PROXY} = "" ]]; then
|
||||
text " Proxy: not set\n"
|
||||
else
|
||||
text " Proxy: HTTP_PROXY=${HTTP_PROXY}, HTTPS_PROXY=${HTTPS_PROXY}, NO_PROXY=${NO_PROXY}\n"
|
||||
fi
|
||||
text "Internal:\n"
|
||||
text " ${CHE_PRODUCT_NAME}_VERSION: ${CHE_VERSION}\n"
|
||||
text " ${CHE_PRODUCT_NAME}_HOST: ${CHE_HOST}\n"
|
||||
text " ${CHE_PRODUCT_NAME}_INSTANCE: ${CHE_HOST_INSTANCE}\n"
|
||||
text " ${CHE_PRODUCT_NAME}_CONFIG: ${CHE_HOST_CONFIG}\n"
|
||||
text " ${CHE_PRODUCT_NAME}_BACKUP: ${CHE_HOST_BACKUP}\n"
|
||||
text " ${CHE_PRODUCT_NAME}_REGISTRY: ${CHE_MANIFEST_DIR}\n"
|
||||
text " ${CHE_PRODUCT_NAME}_DEBUG: ${CHE_DEBUG}\n"
|
||||
text " IP Detection: $(docker run --net host ${BOOTSTRAP_IMAGE_CHEIP})\n"
|
||||
if is_initialized; then
|
||||
text " Initialized: true\n"
|
||||
else
|
||||
text " Initialized: false\n"
|
||||
fi
|
||||
if local_repo; then
|
||||
text " ${CHE_PRODUCT_NAME}_DEVELOPMENT_REPO: ${CHE_HOST_DEVELOPMENT_REPO}\n"
|
||||
fi
|
||||
|
||||
text "Image Registry:\n"
|
||||
for SINGLE_IMAGE in $IMAGE_LIST; do
|
||||
text " $SINGLE_IMAGE\n"
|
||||
done
|
||||
for SINGLE_IMAGE in $BOOTSTRAP_IMAGE_LIST; do
|
||||
text " $SINGLE_IMAGE\n"
|
||||
done
|
||||
for SINGLE_IMAGE in $UTILITY_IMAGE_LIST; do
|
||||
text " $SINGLE_IMAGE\n"
|
||||
done
|
||||
|
||||
if ! is_initialized; then
|
||||
text "${CHE_ENVIRONMENT_FILE}: not initialized\n"
|
||||
else
|
||||
text "${CHE_ENVIRONMENT_FILE}:\n"
|
||||
# Implement loop of all lines that are uncommented.
|
||||
CONFIGURATION_ARRAY=($(grep "^[^#]" "${REFERENCE_CONTAINER_ENVIRONMENT_FILE}"))
|
||||
for SINGLE_CONFIGURATION in "${CONFIGURATION_ARRAY[@]}"; do
|
||||
text " $SINGLE_CONFIGURATION\n"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
cmd_network() {
|
||||
info ""
|
||||
info "---------------------------------------"
|
||||
info "-------- CONNECTIVITY TEST --------"
|
||||
info "---------------------------------------"
|
||||
|
||||
info "network" "${BOOTSTRAP_IMAGE_CHEIP}: ${CHE_HOST}"
|
||||
|
||||
start_test_server
|
||||
|
||||
info "network" "Browser => Workspace Agent (localhost): Connection $(test1 && echo "succeeded" || echo "failed")"
|
||||
info "network" "Browser => Workspace Agent ($AGENT_EXTERNAL_IP): Connection $(test2 && echo "succeeded" || echo "failed")"
|
||||
info "network" "Server => Workspace Agent (External IP): Connection $(test3 && echo "succeeded" || echo "failed")"
|
||||
info "network" "Server => Workspace Agent (Internal IP): Connection $(test4 && echo "succeeded" || echo "failed")"
|
||||
|
||||
stop_test_server
|
||||
}
|
||||
|
|
@ -1,172 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Tyler Jewell - Initial Implementation
|
||||
#
|
||||
|
||||
help_cmd_init() {
|
||||
text "\n"
|
||||
text "USAGE: ${CHE_IMAGE_FULLNAME} init [PARAMETERS]\n"
|
||||
text "\n"
|
||||
text "Initializes a directory with a new ${CHE_MINI_PRODUCT_NAME} installation\n"
|
||||
text "\n"
|
||||
text "PARAMETERS:\n"
|
||||
text " --accept-license If license acceptance required, auto accepts during installation\n"
|
||||
text " --force Uses 'docker rmi' and 'docker pull' to forcibly retrieve latest images\n"
|
||||
text " --no-force Updates images if matching tag not found in local cache\n"
|
||||
text " --pull Uses 'docker pull' to check for new remote versions of images\n"
|
||||
text " --reinit Reinitialize an existing installation overwriting defaults\n"
|
||||
text "\n"
|
||||
}
|
||||
|
||||
pre_cmd_init() {
|
||||
:
|
||||
}
|
||||
|
||||
post_cmd_init() {
|
||||
:
|
||||
}
|
||||
|
||||
cmd_init() {
|
||||
|
||||
# set an initial value for the flag
|
||||
if is_nightly && ! is_fast && ! skip_pull; then
|
||||
FORCE_UPDATE="--pull"
|
||||
else
|
||||
FORCE_UPDATE="--no-force"
|
||||
fi
|
||||
|
||||
AUTO_ACCEPT_LICENSE="false"
|
||||
REINIT="false"
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
--no-force|--force|--pull|--offline)
|
||||
FORCE_UPDATE=$1
|
||||
shift ;;
|
||||
--accept-license)
|
||||
AUTO_ACCEPT_LICENSE="true"
|
||||
shift ;;
|
||||
--reinit)
|
||||
REINIT="true"
|
||||
shift ;;
|
||||
*) error "Unknown parameter: $1" ; return 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "${FORCE_UPDATE}" == "--no-force" ]; then
|
||||
# If ${CHE_FORMAL_PRODUCT_NAME}.environment file exists, then fail
|
||||
if is_initialized; then
|
||||
if [[ "${REINIT}" = "false" ]]; then
|
||||
info "init" "Already initialized."
|
||||
return 2
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "${CHE_IMAGE_VERSION}" = "nightly" ]]; then
|
||||
warning "($CHE_MINI_PRODUCT_NAME init): 'nightly' installations cannot be upgraded to non-nightly versions"
|
||||
fi
|
||||
|
||||
if ! skip_pull; then
|
||||
cmd_lifecycle download $FORCE_UPDATE
|
||||
fi
|
||||
|
||||
if require_license; then
|
||||
if [[ "${AUTO_ACCEPT_LICENSE}" = "false" ]]; then
|
||||
info ""
|
||||
info "init" "Do you accept the ${CHE_FORMAL_PRODUCT_NAME} license? (${CHE_LICENSE_URL})"
|
||||
text "\n"
|
||||
read -p " I accept the license: [Y/n] " -r || { error "Shell is not in interactive mode. Add -i flag to the docker run command"; return 2; }
|
||||
if [[ $REPLY =~ ^[Nn]$ ]]; then
|
||||
return 2;
|
||||
fi
|
||||
text "\n"
|
||||
fi
|
||||
fi
|
||||
|
||||
info "init" "Installing configuration and bootstrap variables:"
|
||||
log "mkdir -p \"${CHE_CONTAINER_CONFIG}\""
|
||||
mkdir -p "${CHE_CONTAINER_CONFIG}"
|
||||
log "mkdir -p \"${CHE_CONTAINER_INSTANCE}\""
|
||||
mkdir -p "${CHE_CONTAINER_INSTANCE}"
|
||||
|
||||
if [ ! -w "${CHE_CONTAINER_CONFIG}" ]; then
|
||||
error "CHE_CONTAINER_CONFIG is not writable. Aborting."
|
||||
return 1;
|
||||
fi
|
||||
|
||||
if [ ! -w "${CHE_CONTAINER_INSTANCE}" ]; then
|
||||
error "CHE_CONTAINER_INSTANCE is not writable. Aborting."
|
||||
return 1;
|
||||
fi
|
||||
|
||||
# in development mode we use init files from repo otherwise we use it from docker image
|
||||
INIT_RUN_PARAMETERS=""
|
||||
if local_repo; then
|
||||
if [ -d "/repo/dockerfiles/init/manifests" ]; then
|
||||
INIT_RUN_PARAMETERS=" -v \"${CHE_HOST_DEVELOPMENT_REPO}/dockerfiles/init\":/files"
|
||||
INIT_RUN_PARAMETERS+=" -v \"${CHE_HOST_DEVELOPMENT_REPO}/dockerfiles/init/manifests/${CHE_MINI_PRODUCT_NAME}.env\":/etc/puppet/manifests/${CHE_MINI_PRODUCT_NAME}.env"
|
||||
fi
|
||||
fi
|
||||
GENERATE_INIT_COMMAND="docker_run -v \"${CHE_HOST_CONFIG}\":/copy ${INIT_RUN_PARAMETERS} $IMAGE_INIT"
|
||||
log $GENERATE_INIT_COMMAND
|
||||
eval $GENERATE_INIT_COMMAND
|
||||
|
||||
# If this is is a reinit, we should not overwrite these core template files.
|
||||
# If this is an initial init, then we have to override some values
|
||||
if [[ "${REINIT}" = "false" ]]; then
|
||||
# Otherwise, we are using the templated version and making some modifications.
|
||||
cmd_init_reinit_pre_action
|
||||
rm -rf "${REFERENCE_CONTAINER_ENVIRONMENT_FILE}".bak > /dev/null 2>&1
|
||||
|
||||
info "init" " ${CHE_PRODUCT_NAME}_HOST=${CHE_HOST}"
|
||||
info "init" " ${CHE_PRODUCT_NAME}_VERSION=${CHE_VERSION}"
|
||||
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}_REPO=${CHE_HOST_DEVELOPMENT_REPO}"
|
||||
fi
|
||||
if local_repo || local_assembly; then
|
||||
info "init" " ${CHE_PRODUCT_NAME}_ASSEMBLY=${CHE_ASSEMBLY}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Encode the version that we initialized into the version file
|
||||
echo "$CHE_VERSION" > "${CHE_CONTAINER_INSTANCE}/${CHE_VERSION_FILE}"
|
||||
}
|
||||
|
||||
cmd_init_reinit_pre_action() {
|
||||
|
||||
# One time only, set the value of CHE_HOST within the environment file.
|
||||
sed -i'.bak' "s|#${CHE_PRODUCT_NAME}_HOST=.*|${CHE_PRODUCT_NAME}_HOST=${CHE_HOST}|" "${REFERENCE_CONTAINER_ENVIRONMENT_FILE}"
|
||||
|
||||
if [[ ! ${HTTP_PROXY} = "" ]]; then
|
||||
sed -i'.bak' "s|#${CHE_PRODUCT_NAME}_HTTP_PROXY=.*|${CHE_PRODUCT_NAME}_HTTP_PROXY=${HTTP_PROXY}|" "${REFERENCE_CONTAINER_ENVIRONMENT_FILE}"
|
||||
sed -i'.bak' "s|#${CHE_PRODUCT_NAME}_WORKSPACE_HTTP__PROXY=.*|${CHE_PRODUCT_NAME}_WORKSPACE_HTTP__PROXY=${HTTP_PROXY}|" "${REFERENCE_CONTAINER_ENVIRONMENT_FILE}"
|
||||
fi
|
||||
if [[ ! ${HTTPS_PROXY} = "" ]]; then
|
||||
sed -i'.bak' "s|#${CHE_PRODUCT_NAME}_HTTPS_PROXY=.*|${CHE_PRODUCT_NAME}_HTTPS_PROXY=${HTTPS_PROXY}|" "${REFERENCE_CONTAINER_ENVIRONMENT_FILE}"
|
||||
sed -i'.bak' "s|#${CHE_PRODUCT_NAME}_WORKSPACE_HTTPS__PROXY=.*|${CHE_PRODUCT_NAME}_WORKSPACE_HTTPS__PROXY=${HTTPS_PROXY}|" "${REFERENCE_CONTAINER_ENVIRONMENT_FILE}"
|
||||
fi
|
||||
if [[ ! ${HTTP_PROXY} = "" ]] ||
|
||||
[[ ! ${HTTPS_PROXY} = "" ]]; then
|
||||
sed -i'.bak' "s|#${CHE_PRODUCT_NAME}_NO_PROXY=.*|${CHE_PRODUCT_NAME}_NO_PROXY=${NO_PROXY:-localhost},${CHE_HOST}|" "${REFERENCE_CONTAINER_ENVIRONMENT_FILE}"
|
||||
sed -i'.bak' "s|#${CHE_PRODUCT_NAME}_WORKSPACE_NO__PROXY=.*|${CHE_PRODUCT_NAME}_WORKSPACE_NO__PROXY=che-host,${NO_PROXY:-localhost},${CHE_HOST}|" "${REFERENCE_CONTAINER_ENVIRONMENT_FILE}"
|
||||
fi
|
||||
}
|
||||
|
||||
require_license() {
|
||||
if [[ "${CHE_LICENSE}" = "true" ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
|
@ -1,155 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Tyler Jewell - Initial Implementation
|
||||
#
|
||||
|
||||
help_cmd_offline() {
|
||||
text "\n"
|
||||
text "USAGE: ${CHE_IMAGE_FULLNAME} offline [PARAMETERS]\n"
|
||||
text "\n"
|
||||
text "Downloads and saves Docker images required to run ${CHE_MINI_PRODUCT_NAME} offline. Add the
|
||||
'--offline' global parameter command to execute ${CHE_MINI_PRODUCT_NAME} in offline mode. You can optionally
|
||||
download stack images used to start workspaces. Stack images are heavy and often larger than 1GB. You
|
||||
can save them all or selectively choose stacks.\n"
|
||||
text "\n"
|
||||
text "PARAMETERS:\n"
|
||||
text " --all-stacks Saves all stack images\n"
|
||||
text " --list Lists all images that will be downloaded and saved\n"
|
||||
text " --image:<name> Downloads specific stack image\n"
|
||||
text " --no-stacks Do not save any stack images\n"
|
||||
text "\n"
|
||||
}
|
||||
|
||||
|
||||
pre_cmd_offline() {
|
||||
:
|
||||
}
|
||||
|
||||
post_cmd_offline() {
|
||||
:
|
||||
}
|
||||
|
||||
cmd_offline() {
|
||||
# Read in optional stack images
|
||||
readarray -t STACK_IMAGE_LIST < /version/$CHE_VERSION/images-stacks
|
||||
BOOTSTRAP_IMAGE_LIST=$(cat /version/$CHE_VERSION/images-bootstrap)
|
||||
UTILITY_IMAGE_LIST=$(cat /version/$CHE_VERSION/images-utilities)
|
||||
|
||||
# List all images to be saved
|
||||
if [[ $# -gt 0 ]] && [[ $1 = "--list" ]]; then
|
||||
# First display mandatory
|
||||
info "offline" "Listing images to save for offline usage"
|
||||
info ""
|
||||
info "offline" "Always:"
|
||||
info "offline" " CLI: ${CHE_IMAGE_FULLNAME}"
|
||||
|
||||
IFS=$'\n'
|
||||
for SINGLE_IMAGE in $BOOTSTRAP_IMAGE_LIST; do
|
||||
IMAGE_NAME=$(echo $SINGLE_IMAGE | cut -d'=' -f2)
|
||||
info "offline" " BOOTSTRAP: ${IMAGE_NAME}"
|
||||
done
|
||||
|
||||
IFS=$'\n'
|
||||
for SINGLE_IMAGE in $IMAGE_LIST; do
|
||||
IMAGE_NAME=$(echo $SINGLE_IMAGE | cut -d'=' -f2)
|
||||
info "offline" " SYSTEM: ${IMAGE_NAME}"
|
||||
done
|
||||
|
||||
IFS=$'\n'
|
||||
for SINGLE_IMAGE in $UTILITY_IMAGE_LIST; do
|
||||
IMAGE_NAME=$(echo $SINGLE_IMAGE | cut -d'=' -f2)
|
||||
info "offline" " UTILITY: ${IMAGE_NAME}"
|
||||
done
|
||||
|
||||
info ""
|
||||
info "offline" "Optional: (repeat --image:<name> for stack, --all-stacks, or --no-stacks)"
|
||||
for STACK in $(seq 0 $((${#STACK_IMAGE_LIST[@]}-1)))
|
||||
do
|
||||
if [ ! -z ${STACK_IMAGE_LIST[$STACK]} ]; then
|
||||
info "offline" " STACK: ${STACK_IMAGE_LIST[$STACK]}"
|
||||
fi
|
||||
done
|
||||
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Make sure the images have been pulled and are in your local Docker registry
|
||||
cmd_lifecycle download
|
||||
|
||||
mkdir -p $CHE_CONTAINER_OFFLINE_FOLDER
|
||||
|
||||
info "offline" "Saving ${CHE_MINI_PRODUCT_NAME} cli image..."
|
||||
save_image ${CHE_IMAGE_FULLNAME}
|
||||
|
||||
info "offline" "Saving ${CHE_MINI_PRODUCT_NAME} bootstrap images..."
|
||||
IFS=$'\n'
|
||||
for SINGLE_IMAGE in ${BOOTSTRAP_IMAGE_LIST}; do
|
||||
IMAGE_NAME=$(echo $SINGLE_IMAGE | cut -d'=' -f2)
|
||||
save_image $IMAGE_NAME
|
||||
done
|
||||
|
||||
info "offline" "Saving ${CHE_MINI_PRODUCT_NAME} system images..."
|
||||
for SINGLE_IMAGE in $IMAGE_LIST; do
|
||||
IMAGE_NAME=$(echo $SINGLE_IMAGE | cut -d'=' -f2)
|
||||
save_image $IMAGE_NAME
|
||||
done
|
||||
|
||||
info "offline" "Saving utility images..."
|
||||
for SINGLE_IMAGE in ${UTILITY_IMAGE_LIST}; do
|
||||
IMAGE_NAME=$(echo $SINGLE_IMAGE | cut -d'=' -f2)
|
||||
save_image $IMAGE_NAME
|
||||
done
|
||||
|
||||
info "offline" "Saving ${CHE_MINI_PRODUCT_NAME} stack images..."
|
||||
STACK_SAVE="--no-stacks"
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
--all-stacks)
|
||||
for STACK in $(seq 0 $((${#STACK_IMAGE_LIST[@]}-1)))
|
||||
do
|
||||
if [ ! -z ${STACK_IMAGE_LIST[$STACK]} ]; then
|
||||
download_and_save_image ${STACK_IMAGE_LIST[$STACK]}
|
||||
fi
|
||||
done
|
||||
break
|
||||
shift ;;
|
||||
--no-stacks)
|
||||
info "offline" "--no-stacks indicated...skipping"
|
||||
break
|
||||
shift ;;
|
||||
--image:*|-i:*)
|
||||
download_and_save_image "${1#*:}"
|
||||
shift ;;
|
||||
*) error "Unknown parameter: $1" ; return 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
info "offline" "Done!"
|
||||
}
|
||||
|
||||
download_and_save_image() {
|
||||
update_image_if_not_found ${1}
|
||||
save_image ${1}
|
||||
}
|
||||
|
||||
save_image(){
|
||||
TAR_NAME=$(echo $1 | sed "s|\/|_|g")
|
||||
|
||||
if [ ! -f $CHE_CONTAINER_OFFLINE_FOLDER/$TAR_NAME.tar ]; then
|
||||
info "offline" "Saving $CHE_HOST_OFFLINE_FOLDER/$TAR_NAME.tar..."
|
||||
if ! $(docker save $1 > $CHE_CONTAINER_OFFLINE_FOLDER/$TAR_NAME.tar); then
|
||||
error "Docker was interrupted while saving $CHE_CONTAINER_OFFLINE_FOLDER/$TAR_NAME.tar"
|
||||
return 1;
|
||||
fi
|
||||
else
|
||||
info "offline" " Image $1 already saved...skipping"
|
||||
fi
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Tyler Jewell - Initial Implementation
|
||||
#
|
||||
|
||||
help_cmd_restart() {
|
||||
text "\n"
|
||||
text "USAGE: ${CHE_IMAGE_FULLNAME} restart [PARAMETERS]\n"
|
||||
text "\n"
|
||||
text "Stops ${CHE_MINI_PRODUCT_NAME} and starts again\n"
|
||||
text "\n"
|
||||
text "PARAMETERS:\n"
|
||||
text " --force Uses 'docker rmi' and 'docker pull' to forcibly retrieve latest images\n"
|
||||
text " --no-force Updates images if matching tag not found in local cache\n"
|
||||
text " --pull Uses 'docker pull' to check for new remote versions of images\n"
|
||||
text " --skip:config Skip re-generation of config files placed into /instance\n"
|
||||
text " --skip:graceful Do not wait for confirmation that workspaces have stopped\n"
|
||||
text " --skip:preflight Skip preflight checks\n"
|
||||
text " --skip:postflight Skip postflight checks\n"
|
||||
text "\n"
|
||||
}
|
||||
|
||||
pre_cmd_restart() {
|
||||
:
|
||||
}
|
||||
|
||||
post_cmd_restart() {
|
||||
:
|
||||
}
|
||||
|
||||
cmd_restart() {
|
||||
|
||||
info "restart" "Restarting..."
|
||||
cmd_lifecycle stop ${@}
|
||||
|
||||
# Need to remove any stop parameters from the command line otherwise the start will fail
|
||||
set -- "${@/\-\-skip\:graceful/}"
|
||||
|
||||
cmd_lifecycle start "${@}"
|
||||
}
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Tyler Jewell - Initial Implementation
|
||||
#
|
||||
|
||||
help_cmd_restore() {
|
||||
text "\n"
|
||||
text "USAGE: ${CHE_IMAGE_FULLNAME} restore\n"
|
||||
text "\n"
|
||||
text "Restores user data and recovers a ${CHE_MINI_PRODUCT_NAME} configuration\n"
|
||||
text "\n"
|
||||
}
|
||||
|
||||
pre_cmd_restore() {
|
||||
:
|
||||
}
|
||||
|
||||
post_cmd_restore() {
|
||||
:
|
||||
}
|
||||
|
||||
cmd_restore_pre_action() {
|
||||
true
|
||||
}
|
||||
|
||||
cmd_restore_extra_args() {
|
||||
echo ""
|
||||
}
|
||||
|
||||
cmd_restore() {
|
||||
debug $FUNCNAME
|
||||
|
||||
if [[ -d "${CHE_CONTAINER_CONFIG}" ]]; then
|
||||
WARNING="Restoration overwrites existing configuration and data. Are you sure?"
|
||||
if ! confirm_operation "${WARNING}" "$@"; then
|
||||
return;
|
||||
fi
|
||||
fi
|
||||
|
||||
if get_server_container_id "${CHE_SERVER_CONTAINER_NAME}" >> "${LOGS}" 2>&1; then
|
||||
error "${CHE_FORMAL_PRODUCT_NAME} is running. Stop before performing a restore."
|
||||
return;
|
||||
fi
|
||||
|
||||
if [[ ! -f "${CHE_CONTAINER_BACKUP}/${CHE_BACKUP_FILE_NAME}" ]]; then
|
||||
error "Backup files not found. To do restore please do backup first."
|
||||
return;
|
||||
fi
|
||||
|
||||
# remove config and instance folders
|
||||
log "docker_run -v \"${CHE_HOST_CONFIG}\":${CHE_CONTAINER_ROOT} \
|
||||
${BOOTSTRAP_IMAGE_ALPINE} sh -c \"rm -rf /root${CHE_CONTAINER_ROOT}/docs \
|
||||
; rm -rf /root${CHE_CONTAINER_ROOT}/instance \
|
||||
; rm -rf /root${CHE_CONTAINER_ROOT}/${CHE_MINI_PRODUCT_NAME}.env\""
|
||||
docker_run -v "${CHE_HOST_CONFIG}":/root${CHE_CONTAINER_ROOT} \
|
||||
${BOOTSTRAP_IMAGE_ALPINE} sh -c "rm -rf /root${CHE_CONTAINER_ROOT}/docs \
|
||||
; rm -rf /root${CHE_CONTAINER_ROOT}/instance \
|
||||
; rm -rf /root${CHE_CONTAINER_ROOT}/${CHE_MINI_PRODUCT_NAME}.env"
|
||||
|
||||
info "restore" "Recovering ${CHE_FORMAL_PRODUCT_NAME} data..."
|
||||
|
||||
cmd_restore_pre_action
|
||||
|
||||
docker_run -v "${CHE_HOST_CONFIG}":/root${CHE_CONTAINER_ROOT} \
|
||||
-v "${CHE_HOST_BACKUP}/${CHE_BACKUP_FILE_NAME}":"/root/backup/${CHE_BACKUP_FILE_NAME}" \
|
||||
$(cmd_restore_extra_args) \
|
||||
${BOOTSTRAP_IMAGE_ALPINE} sh -c "tar xf /root/backup/${CHE_BACKUP_FILE_NAME} -C /root${CHE_CONTAINER_ROOT}"
|
||||
}
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Tyler Jewell - Initial Implementation
|
||||
#
|
||||
|
||||
help_cmd_rmi() {
|
||||
text "\n"
|
||||
text "USAGE: ${CHE_IMAGE_FULLNAME} rmi\n"
|
||||
text "\n"
|
||||
text "Removes bootstrap, utility, and system Docker images used to run ${CHE_MINI_PRODUCT_NAME}\n"
|
||||
text "\n"
|
||||
}
|
||||
|
||||
pre_cmd_rmi() {
|
||||
:
|
||||
}
|
||||
|
||||
post_cmd_rmi() {
|
||||
:
|
||||
}
|
||||
|
||||
cmd_rmi() {
|
||||
info "rmi" "Checking registry for version '$CHE_VERSION' images"
|
||||
if ! has_version_registry $CHE_VERSION; then
|
||||
version_error $CHE_VERSION
|
||||
return 1;
|
||||
fi
|
||||
|
||||
WARNING="rmi !!! Removing images disables ${CHE_FORMAL_PRODUCT_NAME} and forces a pull !!!"
|
||||
if ! confirm_operation "${WARNING}" "$@"; then
|
||||
return;
|
||||
fi
|
||||
|
||||
IMAGE_LIST=$(cat "$CHE_MANIFEST_DIR"/$CHE_VERSION/images)
|
||||
IMAGE_LIST+=$'\n'${BOOTSTRAP_IMAGE_LIST}
|
||||
IMAGE_LIST+=$'\n'${UTILITY_IMAGE_LIST}
|
||||
|
||||
IFS=$'\n'
|
||||
info "rmi" "Removing ${CHE_MINI_PRODUCT_NAME} Docker images..."
|
||||
|
||||
for SINGLE_IMAGE in $IMAGE_LIST; do
|
||||
VALUE_IMAGE=$(echo $SINGLE_IMAGE | cut -d'=' -f2)
|
||||
info "rmi" "Removing $VALUE_IMAGE..."
|
||||
log "docker rmi -f ${VALUE_IMAGE} >> \"${LOGS}\" 2>&1 || true"
|
||||
docker rmi -f $VALUE_IMAGE >> "${LOGS}" 2>&1 || true
|
||||
done
|
||||
}
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Tyler Jewell - Initial Implementation
|
||||
#
|
||||
|
||||
help_cmd_ssh() {
|
||||
text "\n"
|
||||
text "USAGE: ${CHE_IMAGE_FULLNAME} ssh WORKSPACE [MACHINE] [PARAMETERS]\n"
|
||||
text "\n"
|
||||
text "Connect to a workspace in ${CHE_MINI_PRODUCT_NAME} over SSH\n"
|
||||
text "\n"
|
||||
text "WORKSPACE: Accepts workspace name, ID, or namespace:ws-name\n"
|
||||
text " List all workspaces with 'action list-workspaces'\n"
|
||||
text "\n"
|
||||
text "MACHINE: Choose machine (default is dev machine) if workspace as multiple containers\n"
|
||||
text "\n"
|
||||
text "PARAMETERS:\n"
|
||||
text " --url Location of ${CHE_MINI_PRODUCT_NAME}\n"
|
||||
text " --user User name of ${CHE_MINI_PRODUCT_NAME} if accessing authenticated system\n"
|
||||
text " --password Password of ${CHE_MINI_PRODUCT_NAME} if accessing authenticated system\n"
|
||||
}
|
||||
|
||||
pre_cmd_ssh() {
|
||||
:
|
||||
}
|
||||
|
||||
post_cmd_ssh() {
|
||||
:
|
||||
}
|
||||
|
||||
cmd_ssh() {
|
||||
cmd_lifecycle action "workspace-ssh" "$@"
|
||||
}
|
||||
|
|
@ -1,325 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Tyler Jewell - Initial Implementation
|
||||
#
|
||||
|
||||
help_cmd_start() {
|
||||
text "\n"
|
||||
text "USAGE: ${CHE_IMAGE_FULLNAME} start [PARAMETERS]\n"
|
||||
text "\n"
|
||||
text "Starts ${CHE_MINI_PRODUCT_NAME} and verifies its operation\n"
|
||||
text "\n"
|
||||
text "PARAMETERS:\n"
|
||||
text " --follow Displays server logs to console and blocks until user interrupts\n"
|
||||
text " --force Uses 'docker rmi' and 'docker pull' to forcibly retrieve latest images\n"
|
||||
text " --no-force Updates images if matching tag not found in local cache\n"
|
||||
text " --pull Uses 'docker pull' to check for new remote versions of images\n"
|
||||
text " --skip:config Skip re-generation of config files placed into /instance\n"
|
||||
text " --skip:preflight Skip preflight checks\n"
|
||||
text " --skip:postflight Skip postflight checks\n"
|
||||
text "\n"
|
||||
}
|
||||
|
||||
pre_cmd_start() {
|
||||
CHE_SKIP_CONFIG=false
|
||||
CHE_SKIP_PREFLIGHT=false
|
||||
CHE_SKIP_POSTFLIGHT=false
|
||||
CHE_FOLLOW_LOGS=false
|
||||
FORCE_UPDATE="--no-force"
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
--skip:config)
|
||||
CHE_SKIP_CONFIG=true
|
||||
shift ;;
|
||||
--skip:preflight)
|
||||
CHE_SKIP_PREFLIGHT=true
|
||||
shift ;;
|
||||
--skip:postflight)
|
||||
CHE_SKIP_POSTFLIGHT=true
|
||||
shift ;;
|
||||
--follow)
|
||||
CHE_FOLLOW_LOGS=true
|
||||
shift ;;
|
||||
--force)
|
||||
FORCE_UPDATE="--force"
|
||||
shift ;;
|
||||
--no-force)
|
||||
FORCE_UPDATE="--no-force"
|
||||
shift ;;
|
||||
--pull)
|
||||
FORCE_UPDATE="--pull"
|
||||
shift ;;
|
||||
*)
|
||||
shift ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
post_cmd_start() {
|
||||
:
|
||||
}
|
||||
|
||||
|
||||
cmd_start() {
|
||||
# If already running, just display output again
|
||||
check_if_booted
|
||||
|
||||
if server_is_booted $(get_server_container_id $CHE_CONTAINER_NAME); then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Always regenerate puppet configuration from environment variable source, whether changed or not.
|
||||
# If the current directory is not configured with an .env file, it will initialize
|
||||
if skip_config; then
|
||||
cmd_lifecycle config $FORCE_UPDATE --skip:config
|
||||
else
|
||||
cmd_lifecycle config $FORCE_UPDATE
|
||||
fi
|
||||
|
||||
# Preflight checks
|
||||
# a) Check for open ports
|
||||
# b) Test simulated connections for failures
|
||||
if ! is_fast && ! skip_preflight; then
|
||||
info "start" "Preflight checks"
|
||||
cmd_start_check_preflight
|
||||
text "\n"
|
||||
fi
|
||||
|
||||
# Start ${CHE_FORMAL_PRODUCT_NAME}
|
||||
# Note bug in docker requires relative path, not absolute path to compose file
|
||||
info "start" "Starting containers..."
|
||||
COMPOSE_UP_COMMAND="docker_compose --file=\"${REFERENCE_CONTAINER_COMPOSE_FILE}\" -p=\"${CHE_COMPOSE_PROJECT_NAME}\" up -d"
|
||||
|
||||
## validate the compose file (quiet mode)
|
||||
if local_repo; then
|
||||
docker_compose --file=${REFERENCE_CONTAINER_COMPOSE_FILE} config -q || (error "Invalid docker compose file content at ${REFERENCE_CONTAINER_COMPOSE_FILE}" && return 2)
|
||||
fi
|
||||
|
||||
if ! debug_server; then
|
||||
COMPOSE_UP_COMMAND+=" >> \"${LOGS}\" 2>&1"
|
||||
fi
|
||||
|
||||
log ${COMPOSE_UP_COMMAND}
|
||||
eval ${COMPOSE_UP_COMMAND} || (error "Error during 'compose up' - printing 30 line tail of ${CHE_HOST_CONFIG}/cli.log:" && tail -30 ${LOGS} && return 2)
|
||||
|
||||
wait_until_booted
|
||||
|
||||
if ! server_is_booted $(get_server_container_id $CHE_CONTAINER_NAME); then
|
||||
error "(${CHE_MINI_PRODUCT_NAME} start): Timeout waiting for server. Run \"docker logs ${CHE_CONTAINER_NAME}\" to inspect."
|
||||
return 2
|
||||
fi
|
||||
|
||||
if ! is_fast && ! skip_postflight; then
|
||||
cmd_start_check_postflight
|
||||
fi
|
||||
|
||||
check_if_booted
|
||||
}
|
||||
|
||||
cmd_start_check_host_resources() {
|
||||
HOST_RAM=$(docker info | grep "Total Memory:")
|
||||
HOST_RAM=$(echo ${HOST_RAM#*:} | xargs)
|
||||
HOST_RAM=${HOST_RAM% *}
|
||||
|
||||
PREFLIGHT=""
|
||||
if less_than_numerically $CHE_MIN_RAM $HOST_RAM; then
|
||||
text " mem ($CHE_MIN_RAM GiB): ${GREEN}[OK]${NC}\n"
|
||||
else
|
||||
text " mem ($CHE_MIN_RAM GiB): ${RED}[NOT OK]${NC}\n"
|
||||
PREFLIGHT="fail"
|
||||
fi
|
||||
|
||||
HOST_DISK=$(df "${CHE_CONTAINER_ROOT}" | grep "${CHE_CONTAINER_ROOT}" | awk '{ print $4}')
|
||||
|
||||
if less_than_numerically "$CHE_MIN_DISK"000 $HOST_DISK; then
|
||||
text " disk ($CHE_MIN_DISK MB): ${GREEN}[OK]${NC}\n"
|
||||
else
|
||||
text " disk ($CHE_MIN_DISK MB): ${RED}[NOT OK]${NC}\n"
|
||||
PREFLIGHT="fail"
|
||||
fi
|
||||
|
||||
if [[ "${PREFLIGHT}" = "fail" ]]; then
|
||||
text "\n"
|
||||
error "${CHE_MINI_PRODUCT_NAME} requires more RAM or disk to guarantee workspaces can start."
|
||||
return 2;
|
||||
fi
|
||||
}
|
||||
|
||||
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_PRODUCT_NAME}_DEBUG_PORT)
|
||||
|
||||
if [[ "$USER_DEBUG_PORT" = "" ]]; then
|
||||
# If the user has not set a debug port, then use the default
|
||||
CHE_LOCAL_DEBUG_PORT=8000
|
||||
else
|
||||
# Otherwise, this is the value set by the user
|
||||
CHE_LOCAL_DEBUG_PORT=$USER_DEBUG_PORT
|
||||
fi
|
||||
|
||||
PORT_ARRAY+=("$CHE_LOCAL_DEBUG_PORT;port ${CHE_LOCAL_DEBUG_PORT} (debug): ")
|
||||
fi
|
||||
|
||||
if check_all_ports "${PORT_ARRAY[@]}"; then
|
||||
print_ports_as_ok "${PORT_ARRAY[@]}"
|
||||
else
|
||||
find_and_print_ports_as_notok "${PORT_ARRAY[@]}"
|
||||
fi
|
||||
}
|
||||
|
||||
# See cmd_network.sh for utilities for unning these tests
|
||||
cmd_start_check_agent_network() {
|
||||
start_test_server
|
||||
|
||||
PREFLIGHT="success"
|
||||
if test1 || test2; then
|
||||
text " conn (browser => ws): ${GREEN}[OK]${NC}\n"
|
||||
else
|
||||
text " conn (browser => ws): ${RED}[NOT OK]${NC}\n"
|
||||
PREFLIGHT="fail"
|
||||
fi
|
||||
|
||||
if test3 && test4; then
|
||||
text " conn (server => ws): ${GREEN}[OK]${NC}\n"
|
||||
else
|
||||
text " conn (server => ws): ${RED}[NOT OK]${NC}\n\n"
|
||||
PREFLIGHT="fail"
|
||||
fi
|
||||
|
||||
stop_test_server
|
||||
|
||||
if [[ "${PREFLIGHT}" = "fail" ]]; then
|
||||
text "\n"
|
||||
error "Try 'docker run <options> ${CHE_IMAGE_FULLNAME} info --network' for more tests."
|
||||
return 2;
|
||||
fi
|
||||
}
|
||||
|
||||
cmd_start_check_preflight() {
|
||||
cmd_start_check_host_resources
|
||||
cmd_start_check_ports
|
||||
cmd_start_check_agent_network
|
||||
}
|
||||
|
||||
cmd_start_check_postflight() {
|
||||
true
|
||||
}
|
||||
|
||||
wait_until_booted() {
|
||||
CURRENT_CHE_SERVER_CONTAINER_ID=$(get_server_container_id $CHE_CONTAINER_NAME)
|
||||
|
||||
wait_until_container_is_running 20 ${CURRENT_CHE_SERVER_CONTAINER_ID}
|
||||
if ! container_is_running ${CURRENT_CHE_SERVER_CONTAINER_ID}; then
|
||||
error "(${CHE_MINI_PRODUCT_NAME} start): Timeout waiting for ${CHE_MINI_PRODUCT_NAME} container to start."
|
||||
return 2
|
||||
fi
|
||||
|
||||
info "start" "Services booting..."
|
||||
|
||||
# CHE-3546 - if in development mode, then display the che server logs to STDOUT
|
||||
# automatically kill the streaming of the log output when the server is booted
|
||||
if debug_server || follow_logs; then
|
||||
DOCKER_LOGS_COMMAND="docker logs -f ${CHE_CONTAINER_NAME}"
|
||||
|
||||
if debug_server; then
|
||||
DOCKER_LOGS_COMMAND+=" &"
|
||||
fi
|
||||
|
||||
eval $DOCKER_LOGS_COMMAND
|
||||
LOG_PID=$!
|
||||
else
|
||||
info "start" "Server logs at \"docker logs -f ${CHE_CONTAINER_NAME}\""
|
||||
fi
|
||||
|
||||
check_containers_are_running
|
||||
wait_until_server_is_booted 60 ${CURRENT_CHE_SERVER_CONTAINER_ID}
|
||||
check_containers_are_running
|
||||
|
||||
if debug_server; then
|
||||
kill $LOG_PID > /dev/null 2>&1
|
||||
info ""
|
||||
fi
|
||||
}
|
||||
|
||||
check_if_booted() {
|
||||
if container_exist_by_name $CHE_CONTAINER_NAME; then
|
||||
local CURRENT_CHE_SERVER_CONTAINER_ID=$(get_server_container_id $CHE_CONTAINER_NAME)
|
||||
if server_is_booted $CURRENT_CHE_SERVER_CONTAINER_ID; then
|
||||
DISPLAY_URL=$(get_display_url)
|
||||
info "start" "Booted and reachable"
|
||||
info "start" "Ver: $(get_installed_version)"
|
||||
info "start" "Use: ${DISPLAY_URL}"
|
||||
info "start" "API: ${DISPLAY_URL}/swagger"
|
||||
if debug_server; then
|
||||
DISPLAY_DEBUG_URL=$(get_debug_display_url)
|
||||
info "start" "Debug: ${DISPLAY_DEBUG_URL}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
check_containers_are_running() {
|
||||
# get list of docker compose services started by this docker compose
|
||||
local LIST_OF_COMPOSE_CONTAINERS=$(docker_compose --file=${REFERENCE_CONTAINER_COMPOSE_FILE} -p=$CHE_COMPOSE_PROJECT_NAME config --services)
|
||||
|
||||
# For each service of docker-compose file, get container and then check it is running
|
||||
while IFS= read -r DOCKER_COMPOSE_SERVICE_NAME ; do
|
||||
local CONTAINER_ID_MATCHING_SERVICE_NAMES=$(docker ps -q --filter label=com.docker.compose.service=${DOCKER_COMPOSE_SERVICE_NAME})
|
||||
if [[ -z "${CONTAINER_ID_MATCHING_SERVICE_NAMES}" ]]; then
|
||||
error "Unable to find a matching container for the docker compose service named ${DOCKER_COMPOSE_SERVICE_NAME}. Check logs at ${CHE_HOST_CONFIG}/cli.log"
|
||||
return 2
|
||||
fi
|
||||
|
||||
while IFS='\n' read -r CONTAINER_ID_MATCHING_SERVICE_NAME ; do
|
||||
debug "Container with id ${CONTAINER_ID_MATCHING_SERVICE_NAME} is matching ${DOCKER_COMPOSE_SERVICE_NAME} service"
|
||||
local IS_RUNNING_CONTAINER=$(docker inspect -f {{.State.Running}} ${CONTAINER_ID_MATCHING_SERVICE_NAME})
|
||||
debug "Running state of container ${CONTAINER_ID_MATCHING_SERVICE_NAME} is ${IS_RUNNING_CONTAINER}"
|
||||
|
||||
if [[ ${IS_RUNNING_CONTAINER} != "true" ]]; then
|
||||
error "The container with ID ${CONTAINER_ID_MATCHING_SERVICE_NAME} of docker-compose service ${DOCKER_COMPOSE_SERVICE_NAME} is not running, aborting."
|
||||
docker inspect ${CONTAINER_ID_MATCHING_SERVICE_NAME}
|
||||
return 2
|
||||
fi
|
||||
done <<< "${CONTAINER_ID_MATCHING_SERVICE_NAMES}"
|
||||
done <<< "${LIST_OF_COMPOSE_CONTAINERS}"
|
||||
}
|
||||
|
||||
skip_preflight() {
|
||||
if [ "${CHE_SKIP_PREFLIGHT}" = "true" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
skip_postflight() {
|
||||
if [ "${CHE_SKIP_POSTFLIGHT}" = "true" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
follow_logs() {
|
||||
if [ "${CHE_FOLLOW_LOGS}" = "true" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Tyler Jewell - Initial Implementation
|
||||
#
|
||||
|
||||
help_cmd_stop() {
|
||||
text "\n"
|
||||
text "USAGE: ${CHE_IMAGE_FULLNAME} restart [PARAMETERS]\n"
|
||||
text "\n"
|
||||
text "Stops ${CHE_MINI_PRODUCT_NAME} workspaces gracefully and then the server\n"
|
||||
text "\n"
|
||||
text "PARAMETERS:\n"
|
||||
text " --skip:graceful Do not wait for confirmation that workspaces have stopped\n"
|
||||
text " --user <username> Admin user name for authenticated Che systems\n"
|
||||
text " --password <password> Admin password for authenticated Che systems\n"
|
||||
text "\n"
|
||||
}
|
||||
|
||||
pre_cmd_stop() {
|
||||
:
|
||||
}
|
||||
|
||||
post_cmd_stop() {
|
||||
:
|
||||
}
|
||||
|
||||
cmd_stop() {
|
||||
debug $FUNCNAME
|
||||
FORCE_STOP=false
|
||||
if [[ "$@" == *"--skip:graceful"* ]]; then
|
||||
FORCE_STOP=true
|
||||
elif local_repo || local_assembly; then
|
||||
FORCE_STOP=true
|
||||
fi
|
||||
|
||||
if server_is_booted $(get_server_container_id $CHE_CONTAINER_NAME); then
|
||||
if [[ ${FORCE_STOP} = "false" ]]; then
|
||||
info "stop" "Stopping workspaces..."
|
||||
local GRACEFUL_STATUS_RESULT=0
|
||||
cmd_lifecycle action "graceful-stop" "$@" >> "${LOGS}" 2>&1 || GRACEFUL_STATUS_RESULT=$?
|
||||
# error on authentication (401 modulo 256 = 145)
|
||||
if [[ ${GRACEFUL_STATUS_RESULT} -eq 145 ]]; then
|
||||
error "Authentication failed (hint: --user/--password for auth, --skip:graceful bypasses workspace stop)"
|
||||
return 2;
|
||||
elif [[ ${GRACEFUL_STATUS_RESULT} -ne 0 ]]; then
|
||||
error "Error during graceful stop - see $CHE_HOST_CONFIG/cli.log. (hint: --skip:graceful bypasses workspace stop)"
|
||||
return 2;
|
||||
fi
|
||||
fi
|
||||
# stop containers booted by docker compose
|
||||
stop_containers
|
||||
else
|
||||
info "stop" "Server $CHE_CONTAINER_NAME on port $CHE_PORT not running..."
|
||||
fi
|
||||
}
|
||||
|
||||
# stop containers booted by docker compose and remove them
|
||||
stop_containers() {
|
||||
info "stop" "Stopping containers..."
|
||||
if is_initialized; then
|
||||
log "docker_compose --file=\"${REFERENCE_CONTAINER_COMPOSE_FILE}\" -p=$CHE_COMPOSE_PROJECT_NAME stop -t ${CHE_COMPOSE_STOP_TIMEOUT} >> \"${LOGS}\" 2>&1 || true"
|
||||
docker_compose --file="${REFERENCE_CONTAINER_COMPOSE_FILE}" \
|
||||
-p=$CHE_COMPOSE_PROJECT_NAME stop -t ${CHE_COMPOSE_STOP_TIMEOUT} >> "${LOGS}" 2>&1 || true
|
||||
info "stop" "Removing containers..."
|
||||
log "docker_compose --file=\"${REFERENCE_CONTAINER_COMPOSE_FILE}\" -p=$CHE_COMPOSE_PROJECT_NAME rm -v --force >> \"${LOGS}\" 2>&1 || true"
|
||||
docker_compose --file="${REFERENCE_CONTAINER_COMPOSE_FILE}" \
|
||||
-p=$CHE_COMPOSE_PROJECT_NAME rm -v --force >> "${LOGS}" 2>&1 || true
|
||||
fi
|
||||
}
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Tyler Jewell - Initial Implementation
|
||||
#
|
||||
|
||||
help_cmd_sync() {
|
||||
text "\n"
|
||||
text "USAGE: ${CHE_IMAGE_FULLNAME} sync WORKSPACE [PARAMETERS]\n"
|
||||
text "\n"
|
||||
text "Synchronizes a ${CHE_MINI_PRODUCT_NAME} workspace to a local path mounted to ':/sync'\n"
|
||||
text "\n"
|
||||
text "WORKSPACE: Accepts workspace name, ID, or namespace:ws-name\n"
|
||||
text " List all workspaces with 'action list-workspaces'\n"
|
||||
text "\n"
|
||||
text "PARAMETERS:\n"
|
||||
text " --url Location of ${CHE_MINI_PRODUCT_NAME}\n"
|
||||
text " --user User name of ${CHE_MINI_PRODUCT_NAME} if accessing authenticated system\n"
|
||||
text " --password Password of ${CHE_MINI_PRODUCT_NAME} if accessing authenticated system\n"
|
||||
text " --unison-verbose Verbose output of unison sync\n"
|
||||
}
|
||||
|
||||
pre_cmd_sync() {
|
||||
# Not loaded as part of the init process to save on download time
|
||||
load_utilities_images_if_not_done
|
||||
}
|
||||
|
||||
post_cmd_sync() {
|
||||
:
|
||||
}
|
||||
|
||||
cmd_sync() {
|
||||
if [[ "${SYNC_MOUNT}" = "not set" ]]; then
|
||||
info "Welcome to $CHE_FORMAL_PRODUCT_NAME!"
|
||||
info ""
|
||||
info "We could not detect a location to do the sync."
|
||||
info "Volume mount a local directory to ':/sync'."
|
||||
info ""
|
||||
info " docker run ... -v <YOUR_LOCAL_SYNC_PATH>:/sync ..."
|
||||
return 2;
|
||||
fi
|
||||
|
||||
# Determine the mount path to do the mount
|
||||
info "mount" "Starting sync process to ${SYNC_MOUNT}"
|
||||
|
||||
# grab docker run options to enable tty
|
||||
DOCKER_RUN_OPTIONS=$(get_docker_run_terminal_options)
|
||||
|
||||
docker_run ${DOCKER_RUN_OPTIONS} \
|
||||
--cap-add SYS_ADMIN \
|
||||
--device /dev/fuse \
|
||||
--security-opt apparmor:unconfined \
|
||||
-e CHE_VERSION=${CHE_VERSION} \
|
||||
--name che-mount \
|
||||
-v "${SYNC_MOUNT}":/mnthost \
|
||||
${UTILITY_IMAGE_CHEMOUNT} $*
|
||||
|
||||
# Docker doesn't seem to normally clean up this container
|
||||
docker rm -f che-mount
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
|
||||
help_cmd_test() {
|
||||
text "\n"
|
||||
text "USAGE: ${CHE_IMAGE_FULLNAME} test TEST [PARAMETERS]\n"
|
||||
text "\n"
|
||||
text "Synchronizes a ${CHE_MINI_PRODUCT_NAME} workspace to a local path mounted to ':/sync'\n"
|
||||
text "\n"
|
||||
text "TESTS:\n"
|
||||
text " post-flight-check Performs post-flight check to validate ${CHE_MINI_PRODUCT_NAME} install\n"
|
||||
text "\n"
|
||||
text "PARAMETERS:\n"
|
||||
text " --quiet Display not output during test\n"
|
||||
text " --user User name of ${CHE_MINI_PRODUCT_NAME} if accessing authenticated system\n"
|
||||
text " --password Password of ${CHE_MINI_PRODUCT_NAME} if accessing authenticated system\n"
|
||||
text " --port Define an optional port to use for the test\n"
|
||||
}
|
||||
|
||||
pre_cmd_test() {
|
||||
# Not loaded as part of the init process to save on download time
|
||||
load_utilities_images_if_not_done
|
||||
}
|
||||
|
||||
post_cmd_test() {
|
||||
:
|
||||
}
|
||||
|
||||
|
||||
cmd_test() {
|
||||
docker_run $(get_docker_run_terminal_options) ${UTILITY_IMAGE_CHETEST} "$@"
|
||||
}
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Tyler Jewell - Initial Implementation
|
||||
#
|
||||
|
||||
help_cmd_upgrade() {
|
||||
text "\n"
|
||||
text "USAGE: ${CHE_IMAGE_FULLNAME} upgrade [PARAMETERS]\n"
|
||||
text "\n"
|
||||
text "Upgrades ${CHE_MINI_PRODUCT_NAME} from one version to another while protecting user workspace data"
|
||||
text "\n"
|
||||
text "PARAMETERS:\n"
|
||||
text " --skip-backup Skip backup of user data before performing upgrade\n"
|
||||
}
|
||||
|
||||
pre_cmd_upgrade() {
|
||||
:
|
||||
}
|
||||
|
||||
post_cmd_upgrade() {
|
||||
:
|
||||
}
|
||||
|
||||
cmd_upgrade() {
|
||||
CHE_IMAGE_VERSION=$(get_image_version)
|
||||
DO_BACKUP="true"
|
||||
ARGS=""
|
||||
|
||||
for var in $@; do
|
||||
if [[ "$var" == *"--skip-backup"* ]]; then
|
||||
DO_BACKUP="false"
|
||||
continue
|
||||
fi
|
||||
ARGS+="$var "
|
||||
done
|
||||
|
||||
# If we got here, this means:
|
||||
# image version > configured & installed version
|
||||
# configured version = installed version
|
||||
#
|
||||
# We can now upgrade using the information contained in the CLI image
|
||||
|
||||
## Download version images
|
||||
info "upgrade" "Downloading $CHE_MINI_PRODUCT_NAME images for version $CHE_IMAGE_VERSION..."
|
||||
get_image_manifest $CHE_IMAGE_VERSION
|
||||
SAVEIFS=$IFS
|
||||
IFS=$'\n'
|
||||
for SINGLE_IMAGE in ${IMAGE_LIST}; do
|
||||
VALUE_IMAGE=$(echo ${SINGLE_IMAGE} | cut -d'=' -f2)
|
||||
update_image_if_not_found ${VALUE_IMAGE}
|
||||
done
|
||||
IFS=$SAVEIFS
|
||||
info "upgrade" "Downloading done."
|
||||
|
||||
if get_server_container_id "${CHE_SERVER_CONTAINER_NAME}" >> "${LOGS}" 2>&1; then
|
||||
error "$CHE_MINI_PRODUCT_NAME is running. Stop before performing an upgrade."
|
||||
return 2;
|
||||
fi
|
||||
|
||||
if [[ "${DO_BACKUP}" == "true" ]]; then
|
||||
info "upgrade" "Preparing backup..."
|
||||
cmd_lifecycle backup
|
||||
else
|
||||
info "upgrade" "Skipping backup"
|
||||
fi
|
||||
|
||||
info "upgrade" "Reinitializing the system with your configuration..."
|
||||
cmd_lifecycle init --accept-license --reinit
|
||||
|
||||
cmd_lifecycle start ${ARGS}
|
||||
}
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Tyler Jewell - Initial Implementation
|
||||
#
|
||||
|
||||
help_cmd_version() {
|
||||
text "\n"
|
||||
text "USAGE: ${CHE_IMAGE_FULLNAME} version\n"
|
||||
text "\n"
|
||||
text "List installed and available versions of ${CHE_MINI_PRODUCT_NAME}"
|
||||
text "\n"
|
||||
}
|
||||
|
||||
pre_cmd_version() {
|
||||
:
|
||||
}
|
||||
|
||||
post_cmd_version() {
|
||||
:
|
||||
}
|
||||
|
||||
cmd_version() {
|
||||
# Do not perform any logging in this method as it is runnable before the system is bootstrap
|
||||
echo ""
|
||||
text "Your CLI version is '%s'.\n" $(get_image_version)
|
||||
if is_initialized; then
|
||||
text "Your installed version is '%s'.\n" $(get_installed_version)
|
||||
else
|
||||
text "Your installed version is '<not-installed>'.\n"
|
||||
fi
|
||||
|
||||
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')
|
||||
|
||||
if [[ "${NUMBER_OF_VERSIONS}" = "" ]] || [[ "${NUMBER_OF_VERSIONS}" = "null" ]]; then
|
||||
warning "Unable to retrieve version list from public Docker Hub for image named ${CHE_IMAGE_NAME}."
|
||||
warning "Diagnose with 'docker run -it appropriate/curl -s https://hub.docker.com/v2/repositories/${CHE_IMAGE_NAME}/tags/'."
|
||||
warning "Use '--offline' to ignore this."
|
||||
return 2
|
||||
fi
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
|
@ -1,351 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2017 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
|
||||
convert_windows_to_posix() {
|
||||
# debug $FUNCNAME
|
||||
echo "/"$(echo "$1" | sed 's/\\/\//g' | sed 's/://')
|
||||
}
|
||||
|
||||
convert_posix_to_windows() {
|
||||
# debug $FUNCNAME
|
||||
# Remove leading slash
|
||||
VALUE="${1:1}"
|
||||
|
||||
# Get first character (drive letter)
|
||||
VALUE2="${VALUE:0:1}"
|
||||
|
||||
# Replace / with \
|
||||
VALUE3=$(echo ${VALUE} | tr '/' '\\' | sed 's/\\/\\\\/g')
|
||||
|
||||
# Replace c\ with c:\ for drive letter
|
||||
echo "$VALUE3" | sed "s/./$VALUE2:/1"
|
||||
}
|
||||
|
||||
get_boot_url() {
|
||||
echo "$CHE_HOST:$CHE_PORT/api/system/state"
|
||||
}
|
||||
|
||||
get_display_url() {
|
||||
# If the user has modified che.env with a custom CHE_HOST, we need to detect that here
|
||||
# and not use the in-memory one which is always set with eclipse/che-ip.
|
||||
local CHE_HOST_LOCAL=$${CHE_PRODUCT_NAME}_HOST
|
||||
|
||||
if is_initialized; then
|
||||
CHE_HOST_LOCAL=$(get_value_of_var_from_env_file ${CHE_PRODUCT_NAME}_HOST)
|
||||
fi
|
||||
|
||||
if ! is_docker_for_mac && ! is_docker_for_windows; then
|
||||
echo "http://${CHE_HOST_LOCAL}:${CHE_PORT}"
|
||||
else
|
||||
echo "http://localhost:${CHE_PORT}"
|
||||
fi
|
||||
}
|
||||
|
||||
get_debug_display_url() {
|
||||
local CHE_DEBUG_PORT_LOCAL=8000
|
||||
|
||||
if is_initialized; then
|
||||
DEBUG_PORT_FROM_CONFIG=$(get_value_of_var_from_env_file ${CHE_PRODUCT_NAME}_DEBUG_PORT)
|
||||
if [[ "${DEBUG_PORT_FROM_CONFIG}" != "" ]]; then
|
||||
CHE_DEBUG_PORT_LOCAL=$DEBUG_PORT_FROM_CONFIG
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! is_docker_for_mac && ! is_docker_for_windows; then
|
||||
echo "http://${CHE_HOST}:${CHE_DEBUG_PORT_LOCAL}"
|
||||
else
|
||||
echo "http://localhost:${CHE_DEBUG_PORT_LOCAL}"
|
||||
fi
|
||||
}
|
||||
|
||||
server_is_booted() {
|
||||
PING_URL=$(get_boot_url)
|
||||
HTTP_STATUS_CODE=$(curl -I -k ${PING_URL} -s -o /dev/null --write-out '%{http_code}')
|
||||
log "${HTTP_STATUS_CODE}"
|
||||
if [[ "${HTTP_STATUS_CODE}" = "200" ]] || [[ "${HTTP_STATUS_CODE}" = "302" ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
has_env_variables() {
|
||||
PROPERTIES=$(env | grep "${CHE_PRODUCT_NAME}_")
|
||||
|
||||
if [ "$PROPERTIES" = "" ]; then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
### check if all utilities images are loaded and update them if not found
|
||||
load_utilities_images_if_not_done() {
|
||||
IFS=$'\n'
|
||||
for UTILITY_IMAGE_LINE in ${UTILITY_IMAGE_LIST}; do
|
||||
local UTILITY_IMAGE=$(echo ${UTILITY_IMAGE_LINE} | cut -d'=' -f2)
|
||||
update_image_if_not_found ${UTILITY_IMAGE}
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
update_image_if_not_found() {
|
||||
local CHECKING_TEXT="${GREEN}INFO:${NC} (${CHE_MINI_PRODUCT_NAME} download): Checking for image '$1'..."
|
||||
CURRENT_IMAGE=$(docker images -q "$1")
|
||||
if [ "${CURRENT_IMAGE}" == "" ]; then
|
||||
text "${CHECKING_TEXT} not found\n"
|
||||
update_image $1
|
||||
else
|
||||
log "${CHECKING_TEXT} found"
|
||||
fi
|
||||
}
|
||||
|
||||
# Usage:
|
||||
# confirm_operation <Warning message> [--force|--no-force]
|
||||
confirm_operation() {
|
||||
FORCE_OPERATION=${2:-"--no-force"}
|
||||
|
||||
if [ ! "${FORCE_OPERATION}" == "--quiet" ]; then
|
||||
# Warn user with passed message
|
||||
info "${1}"
|
||||
text "\n"
|
||||
read -p " Are you sure? [N/y] " -n 1 -r
|
||||
text "\n\n"
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
port_open() {
|
||||
docker run -d -p $1:$1 --name fake ${BOOTSTRAP_IMAGE_ALPINE} httpd -f -p $1 -h /etc/ > /dev/null 2>&1
|
||||
NETSTAT_EXIT=$?
|
||||
docker rm -f fake > /dev/null 2>&1
|
||||
|
||||
if [ $NETSTAT_EXIT = 125 ]; then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
server_is_booted_extra_check() {
|
||||
true
|
||||
}
|
||||
|
||||
wait_until_server_is_booted() {
|
||||
SERVER_BOOT_TIMEOUT=${1}
|
||||
|
||||
ELAPSED=0
|
||||
until server_is_booted ${2} || [ ${ELAPSED} -eq "${SERVER_BOOT_TIMEOUT}" ]; do
|
||||
log "sleep 2"
|
||||
sleep 2
|
||||
server_is_booted_extra_check
|
||||
ELAPSED=$((ELAPSED+1))
|
||||
done
|
||||
}
|
||||
|
||||
less_than_numerically() {
|
||||
COMPARE=$(awk "BEGIN { print ($1 < $2) ? 0 : 1}")
|
||||
return $COMPARE
|
||||
}
|
||||
|
||||
# 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 --rm ${DOCKER_PORT_STRING} ${BOOTSTRAP_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;
|
||||
}
|
||||
|
||||
container_exist_by_name(){
|
||||
docker inspect ${1} > /dev/null 2>&1
|
||||
if [ "$?" == "0" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
get_server_container_id() {
|
||||
log "docker inspect -f '{{.Id}}' ${1}"
|
||||
docker inspect -f '{{.Id}}' ${1} 2>&1 || false
|
||||
}
|
||||
|
||||
container_is_running() {
|
||||
if [ "$(docker ps -qa -f "status=running" -f "id=${1}" | wc -l)" -eq 0 ]; then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
wait_until_container_is_running() {
|
||||
CONTAINER_START_TIMEOUT=${1}
|
||||
|
||||
ELAPSED=0
|
||||
until container_is_running ${2} || [ ${ELAPSED} -eq "${CONTAINER_START_TIMEOUT}" ]; do
|
||||
log "sleep 1"
|
||||
sleep 1
|
||||
ELAPSED=$((ELAPSED+1))
|
||||
done
|
||||
}
|
||||
|
||||
has_compose() {
|
||||
hash docker-compose 2>/dev/null && return 0 || return 1
|
||||
}
|
||||
|
||||
docker_compose() {
|
||||
# debug $FUNCNAME
|
||||
|
||||
if has_compose; then
|
||||
docker-compose "$@"
|
||||
else
|
||||
docker_run -v "${CHE_HOST_INSTANCE}":"${CHE_CONTAINER_INSTANCE}" \
|
||||
$IMAGE_COMPOSE "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
start_test_server() {
|
||||
export AGENT_INTERNAL_PORT=80
|
||||
export AGENT_EXTERNAL_PORT=32768
|
||||
export AGENT_CONTAINER_NAME="fakeagent-$CHE_PORT"
|
||||
|
||||
# Start mini httpd server to run simulated tests
|
||||
docker run -d -p $AGENT_EXTERNAL_PORT:$AGENT_INTERNAL_PORT --name $AGENT_CONTAINER_NAME \
|
||||
${BOOTSTRAP_IMAGE_ALPINE} httpd -f -p $AGENT_INTERNAL_PORT -h /etc/ >> "${LOGS}"
|
||||
|
||||
export AGENT_INTERNAL_IP=$(docker inspect --format='{{.NetworkSettings.IPAddress}}' $AGENT_CONTAINER_NAME)
|
||||
export AGENT_EXTERNAL_IP=$CHE_HOST
|
||||
}
|
||||
|
||||
stop_test_server() {
|
||||
# Remove httpd server
|
||||
docker rm -f $AGENT_CONTAINER_NAME >> "${LOGS}"
|
||||
}
|
||||
|
||||
test1() {
|
||||
HTTP_CODE=$(curl -I localhost:${AGENT_EXTERNAL_PORT}/alpine-release \
|
||||
-s -o /dev/null --connect-timeout 5 \
|
||||
--write-out '%{http_code}') || echo "28" >> "${LOGS}"
|
||||
|
||||
if check_http_code $HTTP_CODE; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
test2() {
|
||||
HTTP_CODE=$(curl -I ${AGENT_EXTERNAL_IP}:${AGENT_EXTERNAL_PORT}/alpine-release \
|
||||
-s -o /dev/null --connect-timeout 5 \
|
||||
--write-out '%{http_code}') || echo "28" >> "${LOGS}"
|
||||
|
||||
if check_http_code $HTTP_CODE; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
test3() {
|
||||
HTTP_CODE=$(docker_run --entrypoint=curl \
|
||||
$(eval "echo \${IMAGE_${CHE_PRODUCT_NAME}}") \
|
||||
-I ${AGENT_EXTERNAL_IP}:${AGENT_EXTERNAL_PORT}/alpine-release \
|
||||
-s -o /dev/null \
|
||||
--write-out '%{http_code}')
|
||||
|
||||
if check_http_code $HTTP_CODE; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
test4() {
|
||||
HTTP_CODE=$(docker_run --entrypoint=curl \
|
||||
$(eval "echo \${IMAGE_${CHE_PRODUCT_NAME}}") \
|
||||
-I ${AGENT_INTERNAL_IP}:${AGENT_INTERNAL_PORT}/alpine-release \
|
||||
-s -o /dev/null \
|
||||
--write-out '%{http_code}')
|
||||
|
||||
if check_http_code $HTTP_CODE; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_http_code() {
|
||||
if [ "${1}" = "200" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# return options for docker run used by end-user when calling cli
|
||||
get_docker_run_terminal_options() {
|
||||
local DOCKER_RUN_OPTIONS=""
|
||||
# if TTY is there, need to use -ti
|
||||
if [[ ${TTY_ACTIVATED} == "true" ]]; then
|
||||
DOCKER_RUN_OPTIONS="-t"
|
||||
fi
|
||||
if [[ ${CHE_CLI_IS_INTERACTIVE} == "true" ]]; then
|
||||
DOCKER_RUN_OPTIONS+="i"
|
||||
fi
|
||||
echo ${DOCKER_RUN_OPTIONS}
|
||||
}
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2017 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
|
||||
# Check pre/post functions are there or not
|
||||
declare -f pre_init > /dev/null
|
||||
if [ "$?" == "1" ]; then
|
||||
pre_init() {
|
||||
:
|
||||
}
|
||||
fi
|
||||
|
||||
declare -f post_init > /dev/null
|
||||
if [ "$?" == "1" ]; then
|
||||
post_init() {
|
||||
:
|
||||
}
|
||||
fi
|
||||
|
||||
source /scripts/base/startup_01_init.sh
|
||||
|
||||
# See: https://sipb.mit.edu/doc/safe-shell/
|
||||
set -e
|
||||
set -u
|
||||
|
||||
trap "cleanup" INT TERM EXIT
|
||||
|
|
@ -1,359 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2017 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
|
||||
|
||||
init_usage() {
|
||||
USAGE="
|
||||
USAGE:
|
||||
docker run -it --rm <DOCKER_PARAMETERS> ${CHE_IMAGE_FULLNAME} [COMMAND]
|
||||
|
||||
MANDATORY DOCKER PARAMETERS:
|
||||
-v <LOCAL_PATH>:${CHE_CONTAINER_ROOT} Where user, instance, and log data saved${ADDITIONAL_MANDATORY_PARAMETERS}
|
||||
|
||||
OPTIONAL DOCKER PARAMETERS:${ADDITIONAL_OPTIONAL_DOCKER_PARAMETERS}
|
||||
-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 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${ADDITIONAL_OPTIONAL_DOCKER_MOUNTS}
|
||||
|
||||
COMMANDS:
|
||||
archetype Generate, build, and run custom assemblies of ${CHE_MINI_PRODUCT_NAME}
|
||||
action <action-name> Start action on ${CHE_MINI_PRODUCT_NAME} instance
|
||||
backup Backups ${CHE_MINI_PRODUCT_NAME} configuration and data to ${CHE_CONTAINER_ROOT}/backup volume mount
|
||||
config Generates a ${CHE_MINI_PRODUCT_NAME} config from vars; run on any start / restart
|
||||
destroy Stops services, and deletes ${CHE_MINI_PRODUCT_NAME} instance data
|
||||
dir <command> Use Chedir and Chefile in the directory mounted to :/chedir
|
||||
download Pulls Docker images for the current ${CHE_MINI_PRODUCT_NAME} version
|
||||
help This message
|
||||
info Displays info about ${CHE_MINI_PRODUCT_NAME} and the CLI
|
||||
init Initializes a directory with a ${CHE_MINI_PRODUCT_NAME} install
|
||||
offline Saves ${CHE_MINI_PRODUCT_NAME} Docker images into TAR files for offline install
|
||||
restart Restart ${CHE_MINI_PRODUCT_NAME} services
|
||||
restore Restores ${CHE_MINI_PRODUCT_NAME} configuration and data from ${CHE_CONTAINER_ROOT}/backup mount
|
||||
rmi Removes the Docker images for <version>, forcing a repull
|
||||
ssh <wksp-name> [machine-name] SSH to a workspace if SSH agent enabled
|
||||
start Starts ${CHE_MINI_PRODUCT_NAME} services
|
||||
stop Stops ${CHE_MINI_PRODUCT_NAME} services
|
||||
sync <wksp-name> Synchronize workspace with local directory mounted to :/sync
|
||||
test <test-name> Start test on ${CHE_MINI_PRODUCT_NAME} instance
|
||||
upgrade Upgrades ${CHE_MINI_PRODUCT_NAME} from one version to another with migrations and backups
|
||||
version Installed version and upgrade paths${ADDITIONAL_COMMANDS}
|
||||
|
||||
GLOBAL COMMAND OPTIONS:
|
||||
--fast Skips networking, version, nightly and preflight checks
|
||||
--offline Runs CLI in offline mode, loading images from disk
|
||||
--debug Enable debugging of ${CHE_MINI_PRODUCT_NAME} server
|
||||
--trace Activates trace output for debugging CLI${ADDITIONAL_GLOBAL_OPTIONS}
|
||||
--help Get help for a command
|
||||
"
|
||||
}
|
||||
|
||||
init_constants() {
|
||||
BLUE='\033[1;34m'
|
||||
GREEN='\033[0;32m'
|
||||
RED='\033[0;31m'
|
||||
YELLOW='\033[38;5;220m'
|
||||
BOLD='\033[1m'
|
||||
UNDERLINE='\033[4m'
|
||||
NC='\033[0m'
|
||||
|
||||
# CLI DEVELOPERS - ONLY INCREMENT THIS CHANGE IF MODIFYING SECTIONS THAT AFFECT LOADING
|
||||
# BEFORE :/REPO IS VOLUME MOUNTED. CLI ASSEMBLIES WILL FAIL UNTIL THEY
|
||||
# ARE RECOMPILED WITH MATCHING VERSION.
|
||||
CHE_BASE_API_VERSION=2
|
||||
}
|
||||
|
||||
init_global_vars() {
|
||||
LOG_INITIALIZED=false
|
||||
FAST_BOOT=false
|
||||
CHE_DEBUG=false
|
||||
CHE_OFFLINE=false
|
||||
CHE_SKIP_NIGHTLY=false
|
||||
CHE_SKIP_NETWORK=false
|
||||
CHE_SKIP_PULL=false
|
||||
CHE_COMMAND_HELP=false
|
||||
CHE_SKIP_SCRIPTS=false
|
||||
|
||||
DEFAULT_CHE_PRODUCT_NAME="CHE"
|
||||
CHE_PRODUCT_NAME=${CHE_PRODUCT_NAME:-${DEFAULT_CHE_PRODUCT_NAME}}
|
||||
|
||||
# Name used in CLI statements
|
||||
DEFAULT_CHE_MINI_PRODUCT_NAME="che"
|
||||
CHE_MINI_PRODUCT_NAME=${CHE_MINI_PRODUCT_NAME:-${DEFAULT_CHE_MINI_PRODUCT_NAME}}
|
||||
|
||||
DEFAULT_CHE_FORMAL_PRODUCT_NAME="Eclipse Che"
|
||||
CHE_FORMAL_PRODUCT_NAME=${CHE_FORMAL_PRODUCT_NAME:-${DEFAULT_CHE_FORMAL_PRODUCT_NAME}}
|
||||
|
||||
# Path to root folder inside the container
|
||||
DEFAULT_CHE_CONTAINER_ROOT="/data"
|
||||
CHE_CONTAINER_ROOT=${CHE_CONTAINER_ROOT:-${DEFAULT_CHE_CONTAINER_ROOT}}
|
||||
|
||||
# Turns on stack trace
|
||||
DEFAULT_CHE_CLI_DEBUG="false"
|
||||
CHE_CLI_DEBUG=${CLI_DEBUG:-${DEFAULT_CHE_CLI_DEBUG}}
|
||||
|
||||
# Activates console output
|
||||
DEFAULT_CHE_CLI_INFO="true"
|
||||
CHE_CLI_INFO=${CLI_INFO:-${DEFAULT_CHE_CLI_INFO}}
|
||||
|
||||
# Activates console warnings
|
||||
DEFAULT_CHE_CLI_WARN="true"
|
||||
CHE_CLI_WARN=${CLI_WARN:-${DEFAULT_CHE_CLI_WARN}}
|
||||
|
||||
# Activates console output
|
||||
DEFAULT_CHE_CLI_LOG="true"
|
||||
CHE_CLI_LOG=${CLI_LOG:-${DEFAULT_CHE_CLI_LOG}}
|
||||
|
||||
DEFAULT_CHE_ASSEMBLY_IN_REPO_MODULE_NAME="assembly/assembly-main"
|
||||
CHE_ASSEMBLY_IN_REPO_MODULE_NAME=${CHE_ASSEMBLY_IN_REPO_MODULE_NAME:-${DEFAULT_CHE_ASSEMBLY_IN_REPO_MODULE_NAME}}
|
||||
|
||||
DEFAULT_CHE_ASSEMBLY_IN_REPO="${DEFAULT_CHE_ASSEMBLY_IN_REPO_MODULE_NAME}/target/eclipse-che*/eclipse-che-*"
|
||||
CHE_ASSEMBLY_IN_REPO=${CHE_ASSEMBLY_IN_REPO:-${DEFAULT_CHE_ASSEMBLY_IN_REPO}}
|
||||
|
||||
DEFAULT_CHE_SCRIPTS_CONTAINER_SOURCE_DIR="/repo/dockerfiles/cli/scripts"
|
||||
CHE_SCRIPTS_CONTAINER_SOURCE_DIR=${CHE_SCRIPTS_CONTAINER_SOURCE_DIR:-${DEFAULT_CHE_SCRIPTS_CONTAINER_SOURCE_DIR}}
|
||||
|
||||
DEFAULT_CHE_BASE_SCRIPTS_CONTAINER_SOURCE_DIR="/scripts/base"
|
||||
CHE_BASE_SCRIPTS_CONTAINER_SOURCE_DIR=${CHE_BASE_SCRIPTS_CONTAINER_SOURCE_DIR:-${DEFAULT_CHE_BASE_SCRIPTS_CONTAINER_SOURCE_DIR}}
|
||||
|
||||
DEFAULT_CHE_LICENSE_URL="https://www.eclipse.org/legal/epl-2.0/"
|
||||
CHE_LICENSE_URL=${CHE_LICENSE_URL:-${DEFAULT_CHE_LICENSE_URL}}
|
||||
|
||||
DEFAULT_CHE_IMAGE_FULLNAME="eclipse/che-cli:<version>"
|
||||
CHE_IMAGE_FULLNAME=${CHE_IMAGE_FULLNAME:-${DEFAULT_CHE_IMAGE_FULLNAME}}
|
||||
|
||||
# Constants
|
||||
CHE_MANIFEST_DIR="/version"
|
||||
CHE_VERSION_FILE="${CHE_MINI_PRODUCT_NAME}.ver.do_not_modify"
|
||||
CHE_ENVIRONMENT_FILE="${CHE_MINI_PRODUCT_NAME}.env"
|
||||
CHE_COMPOSE_FILE="docker-compose-container.yml"
|
||||
CHE_HOST_COMPOSE_FILE="docker-compose.yml"
|
||||
|
||||
# Keep for backwards compatibility
|
||||
DEFAULT_CHE_SERVER_CONTAINER_NAME="${CHE_MINI_PRODUCT_NAME}"
|
||||
CHE_SERVER_CONTAINER_NAME="${CHE_SERVER_CONTAINER_NAME:-${DEFAULT_CHE_SERVER_CONTAINER_NAME}}"
|
||||
|
||||
DEFAULT_CHE_CONTAINER_NAME="${CHE_SERVER_CONTAINER_NAME}"
|
||||
CHE_CONTAINER_NAME="${CHE_CONTAINER:-${DEFAULT_CHE_CONTAINER_NAME}}"
|
||||
|
||||
DEFAULT_CHE_CONTAINER_PREFIX="${CHE_SERVER_CONTAINER_NAME}"
|
||||
CHE_CONTAINER_PREFIX="${CHE_CONTAINER_PREFIX:-${DEFAULT_CHE_CONTAINER_PREFIX}}"
|
||||
|
||||
CHE_BACKUP_FILE_NAME="${CHE_MINI_PRODUCT_NAME}_backup.tar.gz"
|
||||
CHE_COMPOSE_STOP_TIMEOUT="180"
|
||||
|
||||
DEFAULT_CHE_CLI_ACTION="help"
|
||||
CHE_CLI_ACTION=${CHE_CLI_ACTION:-${DEFAULT_CHE_CLI_ACTION}}
|
||||
|
||||
DEFAULT_CHE_LICENSE=false
|
||||
CHE_LICENSE=${CHE_LICENSE:-${DEFAULT_CHE_LICENSE}}
|
||||
|
||||
if [[ "${CHE_CONTAINER_NAME}" = "${CHE_MINI_PRODUCT_NAME}" ]]; then
|
||||
if [[ "${CHE_PORT}" != "${DEFAULT_CHE_PORT}" ]]; then
|
||||
CHE_CONTAINER_NAME="${CHE_CONTAINER_PREFIX}-${CHE_PORT}"
|
||||
else
|
||||
CHE_CONTAINER_NAME="${CHE_CONTAINER_PREFIX}"
|
||||
fi
|
||||
fi
|
||||
|
||||
DEFAULT_CHE_COMPOSE_PROJECT_NAME="${CHE_CONTAINER_NAME}"
|
||||
CHE_COMPOSE_PROJECT_NAME="${CHE_COMPOSE_PROJECT_NAME:-${DEFAULT_CHE_COMPOSE_PROJECT_NAME}}"
|
||||
|
||||
DEFAULT_CHE_USER="root"
|
||||
CHE_USER="${CHE_USER:-${DEFAULT_CHE_USER}}"
|
||||
|
||||
CHE_USER_GROUPS=""
|
||||
|
||||
UNAME_R=${UNAME_R:-$(uname -r)}
|
||||
|
||||
}
|
||||
|
||||
usage() {
|
||||
# debug $FUNCNAME
|
||||
init_usage
|
||||
printf "%s" "${USAGE}"
|
||||
}
|
||||
|
||||
init_cli_version_check() {
|
||||
if [[ $CHE_BASE_API_VERSION != $CHE_CLI_API_VERSION ]]; then
|
||||
printf "CLI base ($CHE_BASE_API_VERSION) does not match CLI ($CHE_CLI_API_VERSION) version.\n"
|
||||
printf "Recompile the CLI with the latest version of the CLI base.\n"
|
||||
return 1;
|
||||
fi
|
||||
}
|
||||
|
||||
init_usage_check() {
|
||||
# If there are no parameters, immediately display usage
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
usage
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ "$@" == *"--fast"* ]]; then
|
||||
FAST_BOOT=true
|
||||
fi
|
||||
|
||||
if [[ "$@" == *"--debug"* ]]; then
|
||||
CHE_DEBUG=true
|
||||
fi
|
||||
|
||||
if [[ "$@" == *"--offline"* ]]; then
|
||||
CHE_OFFLINE=true
|
||||
fi
|
||||
|
||||
if [[ "$@" == *"--trace"* ]]; then
|
||||
CHE_TRACE=true
|
||||
set -x
|
||||
fi
|
||||
|
||||
if [[ "$@" == *"--skip:nightly"* ]]; then
|
||||
CHE_SKIP_NIGHTLY=true
|
||||
fi
|
||||
|
||||
if [[ "$@" == *"--skip:network"* ]]; then
|
||||
CHE_SKIP_NETWORK=true
|
||||
fi
|
||||
|
||||
if [[ "$@" == *"--skip:pull"* ]]; then
|
||||
CHE_SKIP_PULL=true
|
||||
fi
|
||||
|
||||
if [[ "$@" == *"--help"* ]]; then
|
||||
CHE_COMMAND_HELP=true
|
||||
fi
|
||||
|
||||
if [[ "$@" == *"--skip:scripts"* ]]; then
|
||||
CHE_SKIP_SCRIPTS=true
|
||||
fi
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
RETURN_CODE=$?
|
||||
|
||||
# CLI developers should only return '3' in code after the init() method has completed.
|
||||
# This will check to see if the CLI directory is not mounted and only offer the error
|
||||
# message if it isn't currently mounted.
|
||||
if [ $RETURN_CODE -eq "3" ]; then
|
||||
error ""
|
||||
error "Unexpected exit: Trace output saved to $CHE_HOST_CONFIG/cli.log."
|
||||
fi
|
||||
}
|
||||
|
||||
start() {
|
||||
# pre_init is unique to each CLI assembly. This can be called before networking is established.
|
||||
source "/scripts/pre_init.sh"
|
||||
pre_init
|
||||
|
||||
# Yo, constants
|
||||
init_constants
|
||||
|
||||
# Variables used throughout
|
||||
init_global_vars
|
||||
|
||||
# Check to make sure CLI assembly matches base
|
||||
init_cli_version_check
|
||||
|
||||
# Checks for global parameters
|
||||
init_usage_check "$@"
|
||||
|
||||
# Removes global parameters from the positional arguments
|
||||
ORIGINAL_PARAMETERS=$@
|
||||
set -- "${@/\-\-fast/}"
|
||||
set -- "${@/\-\-debug/}"
|
||||
set -- "${@/\-\-offline/}"
|
||||
set -- "${@/\-\-trace/}"
|
||||
set -- "${@/\-\-skip\:nightly/}"
|
||||
set -- "${@/\-\-skip\:network/}"
|
||||
set -- "${@/\-\-skip\:pull/}"
|
||||
set -- "${@/\-\-help/}"
|
||||
set -- "${@/\-\-skip\:scripts/}"
|
||||
|
||||
source "${CHE_BASE_SCRIPTS_CONTAINER_SOURCE_DIR}"/startup_02_pre_docker.sh
|
||||
|
||||
# Make sure Docker is working and we have /var/run/docker.sock mounted or valid DOCKER_HOST
|
||||
init_check_docker "$@"
|
||||
|
||||
# Check to see if Docker is configured with a proxy and pull values
|
||||
init_check_docker_networking
|
||||
|
||||
# Verify that -i is passed on the command line
|
||||
init_check_interactive "$@"
|
||||
|
||||
# Only verify mounts after Docker is confirmed to be working.
|
||||
init_check_mounts "$@"
|
||||
|
||||
# Extract the value of --user from the docker command line
|
||||
init_check_user "$@"
|
||||
|
||||
# Extract the value of --group-add from the docker command line
|
||||
init_check_groups "$@"
|
||||
|
||||
# Only initialize after mounts have been established so we can write cli.log out to a mount folder
|
||||
init_logging "$@"
|
||||
|
||||
# Determine where the remaining scripts will be sourced from (inside image, or repo?)
|
||||
init_scripts "$@"
|
||||
|
||||
# We now know enough to load scripts from different locations - so source from proper source
|
||||
source "${SCRIPTS_BASE_CONTAINER_SOURCE_DIR}"/startup_03_pre_networking.sh
|
||||
|
||||
# If offline mode, then load dependent images from disk and populate the local Docker cache.
|
||||
# If not in offline mode, verify that we have access to DockerHub.
|
||||
# This is also the first usage of curl
|
||||
init_offline_or_network_mode "$@"
|
||||
|
||||
# Pull the list of images that are necessary. If in offline mode, verifies that the images
|
||||
# are properly loaded into the cache.
|
||||
init_initial_images "$@"
|
||||
|
||||
# Each CLI assembly must provide this cli.sh - loads overridden functions and variables for the CLI
|
||||
source "${SCRIPTS_CONTAINER_SOURCE_DIR}"/post_init.sh
|
||||
|
||||
# The post_init method is unique to each assembly. This method must be provided by
|
||||
# a custom CLI assembly in their container and can set global variables which are
|
||||
# specific to that implementation of the CLI. Place initialization functions that
|
||||
# require networking here.
|
||||
post_init
|
||||
|
||||
# Begin product-specific CLI calls
|
||||
info "cli" "$CHE_VERSION - using docker ${DOCKER_SERVER_VERSION} / $(get_docker_install_type)"
|
||||
|
||||
source "${SCRIPTS_BASE_CONTAINER_SOURCE_DIR}"/startup_04_pre_cli_init.sh
|
||||
|
||||
# Allow CLI assemblies to load variables assuming networking, logging, docker activated
|
||||
cli_pre_init
|
||||
|
||||
# Set CHE_HOST, CHE_PORT, and apply any CLI-specific command-line overrides to variables
|
||||
cli_init "$@"
|
||||
|
||||
# Additional checks for nightly version
|
||||
cli_verify_nightly "$@"
|
||||
|
||||
# Additional checks to verify image matches version installed on disk & upgrade suitability
|
||||
cli_verify_version "$@"
|
||||
|
||||
# Allow CLI assemblies to load variables assuming CLI is finished bootstrapping
|
||||
cli_post_init
|
||||
|
||||
source "${SCRIPTS_BASE_CONTAINER_SOURCE_DIR}"/startup_05_pre_exec.sh
|
||||
|
||||
# Loads the library and associated dependencies
|
||||
cli_load "$@"
|
||||
|
||||
# Parses the command list for validity
|
||||
cli_parse "$@"
|
||||
|
||||
# Executes command lifecycle
|
||||
cli_execute "$@"
|
||||
}
|
||||
|
|
@ -1,717 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2017 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
|
||||
# Sends arguments as a text to CLI log file
|
||||
# Usage:
|
||||
# log <argument> [other arguments]
|
||||
log() {
|
||||
if [[ "$LOG_INITIALIZED" = "true" ]]; then
|
||||
if is_log; then
|
||||
echo "$@" >> "${LOGS}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
warning() {
|
||||
if [ -z ${2+x} ]; then
|
||||
local PRINT_COMMAND=""
|
||||
local PRINT_STATEMENT=$1
|
||||
else
|
||||
local PRINT_COMMAND="($CHE_MINI_PRODUCT_NAME $1): "
|
||||
local PRINT_STATEMENT=$2
|
||||
fi
|
||||
|
||||
if is_warning; then
|
||||
printf "${YELLOW}WARN:${NC} %b%b\n" \
|
||||
"${PRINT_COMMAND}" \
|
||||
"${PRINT_STATEMENT}"
|
||||
fi
|
||||
log $(printf "INFO: %b %b\n" \
|
||||
"${PRINT_COMMAND}" \
|
||||
"${PRINT_STATEMENT}")
|
||||
}
|
||||
|
||||
info() {
|
||||
if [ -z ${2+x} ]; then
|
||||
local PRINT_COMMAND=""
|
||||
local PRINT_STATEMENT=$1
|
||||
else
|
||||
local PRINT_COMMAND="($CHE_MINI_PRODUCT_NAME $1): "
|
||||
local PRINT_STATEMENT=$2
|
||||
fi
|
||||
if is_info; then
|
||||
printf "${GREEN}INFO:${NC} %b%b\n" \
|
||||
"${PRINT_COMMAND}" \
|
||||
"${PRINT_STATEMENT}"
|
||||
fi
|
||||
log $(printf "INFO: %b %b\n" \
|
||||
"${PRINT_COMMAND}" \
|
||||
"${PRINT_STATEMENT}")
|
||||
}
|
||||
|
||||
debug() {
|
||||
if is_debug; then
|
||||
printf "\n${BLUE}DEBUG:${NC} %s" "${1}"
|
||||
fi
|
||||
log $(printf "\nDEBUG: %s" "${1}")
|
||||
}
|
||||
|
||||
error() {
|
||||
printf "${RED}ERROR:${NC} %s\n" "${1}"
|
||||
log $(printf "ERROR: %s\n" "${1}")
|
||||
}
|
||||
|
||||
# Prints message without changes
|
||||
# Usage: has the same syntax as printf command
|
||||
text() {
|
||||
printf "$@"
|
||||
log $(printf "$@")
|
||||
}
|
||||
|
||||
## TODO use that for all native calls to improve logging for support purposes
|
||||
# Executes command with 'eval' command.
|
||||
# Also logs what is being executed and stdout/stderr
|
||||
# Usage:
|
||||
# cli_eval <command to execute>
|
||||
# Examples:
|
||||
# cli_eval "$(which curl) http://localhost:80/api/"
|
||||
cli_eval() {
|
||||
log "$@"
|
||||
tmpfile=$(mktemp)
|
||||
if eval "$@" &>"${tmpfile}"; then
|
||||
# Execution succeeded
|
||||
cat "${tmpfile}" >> "${LOGS}"
|
||||
cat "${tmpfile}"
|
||||
rm "${tmpfile}"
|
||||
else
|
||||
# Execution failed
|
||||
cat "${tmpfile}" >> "${LOGS}"
|
||||
cat "${tmpfile}"
|
||||
rm "${tmpfile}"
|
||||
fail
|
||||
fi
|
||||
}
|
||||
|
||||
# Executes command with 'eval' command and suppress stdout/stderr.
|
||||
# Also logs what is being executed and stdout+stderr
|
||||
# Usage:
|
||||
# cli_silent_eval <command to execute>
|
||||
# Examples:
|
||||
# cli_silent_eval "$(which curl) http://localhost:80/api/"
|
||||
cli_silent_eval() {
|
||||
log "$@"
|
||||
eval "$@" >> "${LOGS}" 2>&1
|
||||
}
|
||||
|
||||
is_log() {
|
||||
if [ "${CHE_CLI_LOG}" = "true" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
is_warning() {
|
||||
if [ "${CHE_CLI_WARN}" = "true" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
is_info() {
|
||||
if [ "${CHE_CLI_INFO}" = "true" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
is_debug() {
|
||||
if [ "${CHE_CLI_DEBUG}" = "true" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
debug_server() {
|
||||
if [ "${CHE_DEBUG}" = "true" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
is_fast() {
|
||||
if [ "${FAST_BOOT}" = "true" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
is_offline() {
|
||||
if [ "${CHE_OFFLINE}" = "true" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
is_trace() {
|
||||
if [ "${CHE_TRACE}" = "true" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
skip_nightly() {
|
||||
if [ "${CHE_SKIP_NIGHTLY}" = "true" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
skip_network() {
|
||||
if [ "${CHE_SKIP_NETWORK}" = "true" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
skip_pull() {
|
||||
if [ "${CHE_SKIP_PULL}" = "true" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
local_repo() {
|
||||
if [ "${CHE_LOCAL_REPO}" = "true" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
local_assembly() {
|
||||
if [ "${CHE_LOCAL_ASSEMBLY}" = "true" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
get_command_help() {
|
||||
if [ "${CHE_COMMAND_HELP}" = "true" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
custom_user() {
|
||||
if [ "${CHE_USER}" != "${DEFAULT_CHE_USER}" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
skip_scripts() {
|
||||
if [ "${CHE_SKIP_SCRIPTS}" = "true" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
cli_init() {
|
||||
CHE_HOST=$(eval "echo \$${CHE_PRODUCT_NAME}_HOST")
|
||||
CHE_PORT=$(eval "echo \$${CHE_PRODUCT_NAME}_PORT")
|
||||
|
||||
if [[ "$(eval "echo \$${CHE_PRODUCT_NAME}_HOST")" = "" ]]; then
|
||||
info "Welcome to $CHE_FORMAL_PRODUCT_NAME!"
|
||||
info ""
|
||||
info "We did not auto-detect a valid HOST or IP address."
|
||||
info "Pass ${CHE_PRODUCT_NAME}_HOST with your hostname or IP address."
|
||||
info ""
|
||||
info "Rerun the CLI:"
|
||||
info " docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock"
|
||||
info " -v <local-path>:${CHE_CONTAINER_ROOT}"
|
||||
info " -e ${CHE_PRODUCT_NAME}_HOST=<your-ip-or-host>"
|
||||
info " $CHE_IMAGE_FULLNAME $*"
|
||||
return 2;
|
||||
fi
|
||||
|
||||
if is_initialized; then
|
||||
CHE_HOST_LOCAL=$(get_value_of_var_from_env_file ${CHE_PRODUCT_NAME}_HOST)
|
||||
if [[ "${CHE_HOST}" != "${CHE_HOST_LOCAL}" ]]; then
|
||||
warning "${CHE_PRODUCT_NAME}_HOST (${CHE_HOST}) overridden by ${CHE_ENVIRONMENT_FILE} (${CHE_HOST_LOCAL})"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Special function to perform special behaviors if you are running nightly version
|
||||
verify_nightly_accuracy
|
||||
|
||||
# Do not perform a version compatibility check if running upgrade command.
|
||||
# The upgrade command has its own internal checks for version compatibility.
|
||||
if [[ "$@" == *"upgrade"* ]]; then
|
||||
verify_version_upgrade_compatibility
|
||||
elif ! is_fast; then
|
||||
verify_version_compatibility
|
||||
fi
|
||||
}
|
||||
|
||||
init_check_docker() {
|
||||
if ! has_docker; then
|
||||
error "Docker not found. Get it at https://docs.docker.com/engine/installation/."
|
||||
return 1;
|
||||
fi
|
||||
|
||||
CHECK_VERSION=$(docker ps 2>&1 || true)
|
||||
if [[ "$CHECK_VERSION" = *"Error response from daemon: client is newer"* ]]; then
|
||||
error "Error - Docker engine 1.11+ required."
|
||||
return 2;
|
||||
fi
|
||||
|
||||
# If DOCKER_HOST is not set, then it should bind mounted
|
||||
if [ -z "${DOCKER_HOST+x}" ]; then
|
||||
if ! docker ps > /dev/null 2>&1; then
|
||||
info "Welcome to ${CHE_FORMAL_PRODUCT_NAME}!"
|
||||
info ""
|
||||
info "You are missing a mandatory parameter:"
|
||||
info " 1. Mount 'docker.sock' for accessing Docker with unix sockets."
|
||||
info " 2. Or, set DOCKER_HOST to Docker's location (unix or tcp)."
|
||||
info ""
|
||||
info "Mount Syntax:"
|
||||
info " Start with 'docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock' ..."
|
||||
info ""
|
||||
info "DOCKER_HOST Syntax:"
|
||||
info " Start with 'docker run -it --rm -e DOCKER_HOST=<daemon-location> ...'"
|
||||
info ""
|
||||
info "Possible root causes:"
|
||||
info " 1. Your admin has not granted permissions to /var/run/docker.sock."
|
||||
info " 2. You passed '--user uid:gid' with bad values."
|
||||
info " 3. Your firewall is blocking TCP ports for accessing Docker daemon."
|
||||
return 2;
|
||||
fi
|
||||
fi
|
||||
|
||||
DOCKER_CLIENT_VERSION=$(docker version --format '{{.Client.Version}}')
|
||||
DOCKER_SERVER_VERSION=$(docker version --format '{{.Server.Version}}')
|
||||
|
||||
# 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))
|
||||
|
||||
# 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
|
||||
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
|
||||
|
||||
CHE_VERSION=$CHE_IMAGE_VERSION
|
||||
}
|
||||
|
||||
init_check_docker_networking() {
|
||||
# Check to see if HTTP_PROXY, HTTPS_PROXY, and NO_PROXY is set within the Docker daemon.
|
||||
OUTPUT=$(docker info)
|
||||
HTTP_PROXY=$(grep "Http Proxy" <<< "$OUTPUT" || true)
|
||||
if [ ! -z "$HTTP_PROXY" ]; then
|
||||
HTTP_PROXY=${HTTP_PROXY#"Http Proxy: "}
|
||||
else
|
||||
HTTP_PROXY=""
|
||||
fi
|
||||
|
||||
HTTPS_PROXY=$(grep "Https Proxy" <<< "$OUTPUT" || true)
|
||||
if [ ! -z "$HTTPS_PROXY" ]; then
|
||||
HTTPS_PROXY=${HTTPS_PROXY#"Https Proxy: "}
|
||||
else
|
||||
HTTPS_PROXY=""
|
||||
fi
|
||||
|
||||
NO_PROXY=$(grep "No Proxy" <<< "$OUTPUT" || true)
|
||||
if [ ! -z "$NO_PROXY" ]; then
|
||||
NO_PROXY=${NO_PROXY#"No Proxy: "}
|
||||
else
|
||||
NO_PROXY=""
|
||||
fi
|
||||
|
||||
if [[ ! ${HTTP_PROXY} = "" ]] ||
|
||||
[[ ! ${HTTPS_PROXY} = "" ]] ||
|
||||
[[ ! ${NO_PROXY} = "" ]]; then
|
||||
info "Proxy: HTTP_PROXY=${HTTP_PROXY}, HTTPS_PROXY=${HTTPS_PROXY}, NO_PROXY=${NO_PROXY}"
|
||||
if [[ ${NO_PROXY} = "" ]]; then
|
||||
warning "Potential networking issue discovered!"
|
||||
warning "We have identified that http and https proxies are set but no_proxy is not. This may cause fatal networking errors. Set no_proxy for your Docker daemon!"
|
||||
fi
|
||||
fi
|
||||
|
||||
export http_proxy=$HTTP_PROXY
|
||||
export https_proxy=$HTTPS_PROXY
|
||||
export no_proxy=$NO_PROXY
|
||||
}
|
||||
|
||||
init_check_interactive() {
|
||||
# Detect and verify that the CLI container was started with -it option.
|
||||
TTY_ACTIVATED=true
|
||||
CHE_CLI_IS_INTERACTIVE=true
|
||||
|
||||
# check if no terminal
|
||||
if [ ! -t 1 ]; then
|
||||
TTY_ACTIVATED=false
|
||||
CHE_CLI_IS_INTERACTIVE=false
|
||||
warning "Did not detect TTY - interactive mode disabled"
|
||||
else
|
||||
# There is a terminal, check if it's in interactive mode
|
||||
CHE_CLI_IS_INTERACTIVE=$(docker inspect --format='{{.Config.AttachStdin}}' $(get_this_container_id))
|
||||
if [[ ${CHE_CLI_IS_INTERACTIVE} == "false" ]]; then
|
||||
CHE_CLI_IS_INTERACTIVE=false
|
||||
warning "Did detect TTY but not in interactive mode"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Add check to see if --user uid:gid passed in.
|
||||
init_check_user() {
|
||||
DOCKER_CHE_USER=$(docker inspect --format='{{.Config.User}}' $(get_this_container_id))
|
||||
if [[ "${DOCKER_CHE_USER}" != "" ]]; then
|
||||
CHE_USER=$DOCKER_CHE_USER
|
||||
fi
|
||||
|
||||
if custom_user; then
|
||||
true
|
||||
fi
|
||||
}
|
||||
|
||||
# Extract groups of the docker run command
|
||||
init_check_groups() {
|
||||
DOCKER_CHE_GROUPS=$(docker inspect --format='{{.HostConfig.GroupAdd}}' $(get_this_container_id) | cut -d '[' -f 2 | cut -d ']' -f 1 | xargs)
|
||||
if [[ "${DOCKER_CHE_GROUPS}" != "" ]]; then
|
||||
CHE_USER_GROUPS=${DOCKER_CHE_GROUPS}
|
||||
fi
|
||||
}
|
||||
|
||||
init_check_mounts() {
|
||||
DATA_MOUNT=$(get_container_folder ":${CHE_CONTAINER_ROOT}")
|
||||
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")
|
||||
DOCKER_MOUNT=$(get_container_folder ":/var/run/docker.sock")
|
||||
|
||||
if [[ "${DATA_MOUNT}" = "not set" ]]; then
|
||||
info "Welcome to $CHE_FORMAL_PRODUCT_NAME!"
|
||||
info ""
|
||||
info "We could not detect a location to save data."
|
||||
info "Volume mount a local directory to ':${CHE_CONTAINER_ROOT}'."
|
||||
info ""
|
||||
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 " ${CHE_IMAGE_FULLNAME} $*"
|
||||
info ""
|
||||
info ""
|
||||
info "Or, run with additional overrides:"
|
||||
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_INSTANCE_PATH>:${CHE_CONTAINER_ROOT}/instance"
|
||||
info " -v <YOUR_BACKUP_PATH>:${CHE_CONTAINER_ROOT}/backup"
|
||||
info " ${CHE_IMAGE_FULLNAME} $*"
|
||||
return 2;
|
||||
fi
|
||||
|
||||
# Verify that we can write to the host file system from the container
|
||||
if ! is_fast; then
|
||||
check_host_volume_mount
|
||||
fi
|
||||
|
||||
DEFAULT_CHE_CONFIG="${DATA_MOUNT}"
|
||||
DEFAULT_CHE_INSTANCE="${DATA_MOUNT}"/instance
|
||||
DEFAULT_CHE_BACKUP="${DATA_MOUNT}"/backup
|
||||
|
||||
if [[ "${INSTANCE_MOUNT}" != "not set" ]]; then
|
||||
DEFAULT_CHE_INSTANCE="${INSTANCE_MOUNT}"
|
||||
fi
|
||||
|
||||
if [[ "${BACKUP_MOUNT}" != "not set" ]]; then
|
||||
DEFAULT_CHE_BACKUP="${BACKUP_MOUNT}"
|
||||
fi
|
||||
|
||||
# DERIVED VARIABLES FROM MOUNTS
|
||||
CHE_HOST_CONFIG=${CHE_CONFIG:-${DEFAULT_CHE_CONFIG}}
|
||||
CHE_CONTAINER_CONFIG="${CHE_CONTAINER_ROOT}"
|
||||
|
||||
CHE_HOST_INSTANCE=${CHE_INSTANCE:-${DEFAULT_CHE_INSTANCE}}
|
||||
CHE_CONTAINER_INSTANCE="${CHE_CONTAINER_ROOT}/instance"
|
||||
|
||||
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 assembly and manifests from your local repository"
|
||||
|
||||
CHE_LOCAL_REPO=true
|
||||
CHE_HOST_DEVELOPMENT_REPO="${REPO_MOUNT}"
|
||||
CHE_CONTAINER_DEVELOPMENT_REPO="/repo"
|
||||
|
||||
# When we build eclipse/che-base, we insert the version of the repo it was built from into the image
|
||||
if [[ -f "/repo/dockerfiles/base/scripts/base/startup_01_init.sh" ]]; then
|
||||
CHE_REPO_BASE_VERSION=$(grep -hn CHE_BASE_API_VERSION= /repo/dockerfiles/base/scripts/base/startup_01_init.sh)
|
||||
CHE_REPO_BASE_VERSION=${CHE_REPO_BASE_VERSION#*=}
|
||||
else
|
||||
CHE_REPO_BASE_VERSION=$CHE_BASE_API_VERSION
|
||||
fi
|
||||
|
||||
if [[ $CHE_BASE_API_VERSION != $CHE_REPO_BASE_VERSION ]]; then
|
||||
warning "The CLI base image version ($CHE_BASE_API_VERSION) does not match your repo ($CHE_REPO_BASE_VERSION)"
|
||||
warning "You have mounted :/repo and your repo branch does not match with the image."
|
||||
fi
|
||||
|
||||
CHE_ASSEMBLY="${CHE_HOST_INSTANCE}/dev/${CHE_MINI_PRODUCT_NAME}-tomcat"
|
||||
|
||||
if [[ ! -d "${CHE_CONTAINER_DEVELOPMENT_REPO}" ]] || [[ ! -d "${CHE_CONTAINER_DEVELOPMENT_REPO}/assembly" ]]; then
|
||||
info "Welcome to $CHE_FORMAL_PRODUCT_NAME!"
|
||||
info ""
|
||||
info "You volume mounted ':/repo', but we did not detect a valid ${CHE_FORMAL_PRODUCT_NAME} source repo."
|
||||
info ""
|
||||
info "Volume mounting ':/repo' activates dev mode, using assembly and CLI files from $CHE_FORMAL_PRODUCT_NAME repo."
|
||||
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 " 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"
|
||||
info " ${CHE_IMAGE_FULLNAME} $*"
|
||||
info ""
|
||||
info ""
|
||||
info "Or run with overrides for instance, and backup (all required):"
|
||||
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_INSTANCE_PATH>:${CHE_CONTAINER_ROOT}/instance"
|
||||
info " -v <YOUR_BACKUP_PATH>:${CHE_CONTAINER_ROOT}/backup"
|
||||
info " -v <YOUR_${CHE_PRODUCT_NAME}_REPO>:/repo"
|
||||
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
|
||||
}
|
||||
|
||||
init_logging() {
|
||||
# Initialize CLI folder
|
||||
CLI_DIR=$CHE_CONTAINER_ROOT
|
||||
test -d "${CLI_DIR}" || mkdir -p "${CLI_DIR}"
|
||||
|
||||
# Ensure logs folder exists
|
||||
LOGS="${CLI_DIR}/cli.log"
|
||||
LOG_INITIALIZED=true
|
||||
|
||||
# Log date of CLI execution
|
||||
log "$(date)"
|
||||
}
|
||||
|
||||
init_scripts() {
|
||||
SCRIPTS_CONTAINER_SOURCE_DIR=""
|
||||
SCRIPTS_BASE_CONTAINER_SOURCE_DIR=""
|
||||
if local_repo && ! skip_scripts; then
|
||||
# Use the CLI that is inside the repository.
|
||||
SCRIPTS_CONTAINER_SOURCE_DIR=${CHE_SCRIPTS_CONTAINER_SOURCE_DIR}
|
||||
|
||||
if [[ -d "/repo/dockerfiles/base/scripts/base" ]]; then
|
||||
SCRIPTS_BASE_CONTAINER_SOURCE_DIR="/repo/dockerfiles/base/scripts/base"
|
||||
else
|
||||
SCRIPTS_BASE_CONTAINER_SOURCE_DIR=${CHE_BASE_SCRIPTS_CONTAINER_SOURCE_DIR}
|
||||
fi
|
||||
|
||||
# Compare scripts inside of the Docker image with those on the repository
|
||||
# Fail if they do not match
|
||||
DIFF_NUM=$(diff -r "/scripts/base" "${SCRIPTS_BASE_CONTAINER_SOURCE_DIR}" | wc -l)
|
||||
if [ $DIFF_NUM -gt 0 ]; then
|
||||
error "The scripts in ${CHE_IMAGE_FULLNAME} do not match those in :/repo."
|
||||
error "Is your repo branch compatible with this image version?"
|
||||
error "Add '--skip:scripts' to skip this check."
|
||||
fi
|
||||
else
|
||||
# Use the CLI that is inside the container.
|
||||
SCRIPTS_CONTAINER_SOURCE_DIR="/scripts"
|
||||
SCRIPTS_BASE_CONTAINER_SOURCE_DIR=${CHE_BASE_SCRIPTS_CONTAINER_SOURCE_DIR}
|
||||
fi
|
||||
}
|
||||
|
||||
has_docker() {
|
||||
hash docker 2>/dev/null && return 0 || return 1
|
||||
}
|
||||
|
||||
get_container_folder() {
|
||||
THIS_CONTAINER_ID=$(get_this_container_id)
|
||||
FOLDER=$(get_container_host_bind_folder "$1" $THIS_CONTAINER_ID)
|
||||
echo "${FOLDER:=not set}"
|
||||
}
|
||||
|
||||
get_this_container_id() {
|
||||
hostname
|
||||
}
|
||||
|
||||
get_container_host_bind_folder() {
|
||||
# BINDS in the format of var/run/docker.sock:/var/run/docker.sock <path>:${CHE_CONTAINER_ROOT}
|
||||
BINDS=$(docker inspect --format="{{.HostConfig.Binds}}" "${2}" | cut -d '[' -f 2 | cut -d ']' -f 1)
|
||||
|
||||
# Remove /var/run/docker.sock:/var/run/docker.sock
|
||||
#VALUE=${BINDS/\/var\/run\/docker\.sock\:\/var\/run\/docker\.sock/}
|
||||
|
||||
# Remove leading and trailing spaces
|
||||
VALUE2=$(echo "${BINDS}" | xargs)
|
||||
|
||||
MOUNT=""
|
||||
IFS=$' '
|
||||
for SINGLE_BIND in $VALUE2; do
|
||||
case $SINGLE_BIND in
|
||||
|
||||
# Fix for CHE-3863 - in case there is :Z after the mount for SELinux, add *
|
||||
*$1*)
|
||||
MOUNT="${MOUNT} ${SINGLE_BIND}"
|
||||
echo "${MOUNT}" | cut -f1 -d":" | xargs
|
||||
;;
|
||||
*)
|
||||
# Super ugly - since we parse by space, if the next parameter is not a colon, then
|
||||
# we know that next parameter is second part of a directory with a space in it.
|
||||
if [[ ${SINGLE_BIND} != *":"* ]]; then
|
||||
MOUNT="${MOUNT} ${SINGLE_BIND}"
|
||||
else
|
||||
MOUNT=""
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
check_host_volume_mount() {
|
||||
if is_boot2docker; then
|
||||
warning "Boot2docker detected - ensure :/data is mounted to %userprofile%"
|
||||
fi
|
||||
|
||||
add_file_system_test "${CHE_CONTAINER_ROOT}/test"
|
||||
|
||||
if ! file_system_writable "${CHE_CONTAINER_ROOT}/test" ||
|
||||
! file_system_executable "${CHE_CONTAINER_ROOT}/test"; then
|
||||
error "Unable to write or execute files on your host."
|
||||
error "Have you enabled Docker to allow mounting host directories?"
|
||||
error "Did you give our CLI rights to create + exec files on your host?"
|
||||
delete_file_system_test "${CHE_CONTAINER_ROOT}/test"
|
||||
return 2;
|
||||
fi
|
||||
|
||||
delete_file_system_test "${CHE_CONTAINER_ROOT}/test"
|
||||
}
|
||||
|
||||
add_file_system_test() {
|
||||
echo '#!/bin/sh' > "${1}"
|
||||
echo 'echo hi' >> "${1}"
|
||||
chmod +x "${1}" > /dev/null
|
||||
}
|
||||
|
||||
file_system_writable() {
|
||||
if [[ -f "${1}" ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
file_system_executable() {
|
||||
EXEC_OUTPUT=$(bash "${1}")
|
||||
if [ $EXEC_OUTPUT = "hi" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
delete_file_system_test() {
|
||||
rm -rf $1 > /dev/null 2>&1
|
||||
}
|
||||
|
||||
is_boot2docker() {
|
||||
if uname -r | grep -q 'boot2docker'; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
skip_config() {
|
||||
if [ "${CHE_SKIP_CONFIG}" = "true" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
|
@ -1,267 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2017 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
|
||||
init_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 is_offline; then
|
||||
info "init" "Importing ${CHE_MINI_PRODUCT_NAME} Docker images from tars..."
|
||||
|
||||
if [ ! -d ${CHE_CONTAINER_OFFLINE_FOLDER} ]; then
|
||||
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
|
||||
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 ! is_fast && ! skip_network; then
|
||||
# Removing this info line as it was appearing before initial CLI output
|
||||
|
||||
local HTTP_STATUS_CODE=$(curl -I -k https://hub.docker.com -s -o /dev/null --write-out '%{http_code}')
|
||||
if [[ ! $HTTP_STATUS_CODE -eq "301" ]] && [[ ! $HTTP_STATUS_CODE -eq "200" ]]; then
|
||||
info "Welcome to $CHE_FORMAL_PRODUCT_NAME!"
|
||||
info ""
|
||||
info "We could not resolve DockerHub using DNS."
|
||||
info "Either we cannot reach the Internet or Docker's DNS resolver needs a modification."
|
||||
info ""
|
||||
info "You can:"
|
||||
info " 1. Modify Docker's DNS settings."
|
||||
info " a. Docker for Windows & Mac have GUIs for this."
|
||||
info " b. Typically setting DNS to 8.8.8.8 fixes resolver issues."
|
||||
info " 2. Does your network require Docker to use a proxy?"
|
||||
info " a. Docker for Windows & Mac have GUIs to set proxies."
|
||||
info " 3. Verify that you have access to DockerHub."
|
||||
info " a. Try 'curl --head hub.docker.com'"
|
||||
info " 4. Skip networking checks."
|
||||
info " a. Add '--fast' to any command"
|
||||
return 2;
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
init_initial_images() {
|
||||
# get list of images
|
||||
get_image_manifest ${CHE_VERSION}
|
||||
|
||||
# grab all bootstrap images
|
||||
IFS=$'\n'
|
||||
for BOOTSTRAP_IMAGE_LINE in ${BOOTSTRAP_IMAGE_LIST}; do
|
||||
local BOOTSTRAP_IMAGE=$(echo ${BOOTSTRAP_IMAGE_LINE} | cut -d'=' -f2)
|
||||
if [ "$(docker images -q ${BOOTSTRAP_IMAGE} 2> /dev/null)" = "" ]; then
|
||||
info "cli" "Pulling image ${BOOTSTRAP_IMAGE}"
|
||||
log "docker pull ${BOOTSTRAP_IMAGE} >> \"${LOGS}\" 2>&1"
|
||||
TEST=""
|
||||
docker pull ${BOOTSTRAP_IMAGE} >> "${LOGS}" > /dev/null 2>&1 || TEST=$?
|
||||
if [ "$TEST" = "1" ]; then
|
||||
error "Image ${BOOTSTRAP_IMAGE} unavailable. Not on dockerhub or built locally."
|
||||
return 2;
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
### Returns the list of ${CHE_FORMAL_PRODUCT_NAME} images for a particular version of ${CHE_FORMAL_PRODUCT_NAME}
|
||||
### Sets the images as environment variables after loading from file
|
||||
get_image_manifest() {
|
||||
log "Checking registry for version '$1' images"
|
||||
if ! has_version_registry $1; then
|
||||
version_error $1
|
||||
return 1;
|
||||
fi
|
||||
|
||||
# Load images from file
|
||||
BOOTSTRAP_IMAGE_LIST=$(cat /version/$1/images-bootstrap)
|
||||
IMAGE_LIST=$(cat /version/$1/images)
|
||||
if [ -z "${CHE_SINGLE_PORT:-}" ]; then
|
||||
IMAGE_LIST=$(echo "${IMAGE_LIST}" | sed '/IMAGE_TRAEFIK/d')
|
||||
fi
|
||||
if [ -z "${CHE_MULTIUSER:-}" ]; then
|
||||
IMAGE_LIST=$(echo "${IMAGE_LIST}" | sed '/IMAGE_KEY*/d; /IMAGE_POSTGRES/d')
|
||||
fi
|
||||
UTILITY_IMAGE_LIST=$(cat /version/$1/images-utilities)
|
||||
|
||||
# set variables
|
||||
set_variables_images_list "${BOOTSTRAP_IMAGE_LIST}"
|
||||
set_variables_images_list "${IMAGE_LIST}"
|
||||
set_variables_images_list "${UTILITY_IMAGE_LIST}"
|
||||
}
|
||||
|
||||
has_version_registry() {
|
||||
if [ -d /version/$1 ]; then
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
fi
|
||||
}
|
||||
|
||||
version_error(){
|
||||
text "\nWe could not find version '$1'. Available versions:\n"
|
||||
list_versions
|
||||
text "\nSet CHE_VERSION=<version> and rerun.\n\n"
|
||||
}
|
||||
|
||||
list_versions(){
|
||||
# List all subdirectories and then print only the file name
|
||||
for version in /version/* ; do
|
||||
text " ${version##*/}\n"
|
||||
done
|
||||
}
|
||||
|
||||
### define variables for all image name in the given list
|
||||
set_variables_images_list() {
|
||||
IFS=$'\n'
|
||||
REPLACEMENT='s/\(.*\)=\(.*\)/\1=${\1:-\2}/g'
|
||||
for SINGLE_IMAGE in $1; do
|
||||
INSTRUCTION="$(echo "${SINGLE_IMAGE}" | sed -e "${REPLACEMENT}")"
|
||||
log "eval ${INSTRUCTION}"
|
||||
eval "${INSTRUCTION}"
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
get_docker_install_type() {
|
||||
# debug $FUNCNAME
|
||||
if is_boot2docker; then
|
||||
echo "boot2docker"
|
||||
elif is_docker_for_windows; then
|
||||
echo "docker4windows"
|
||||
elif is_docker_for_mac; then
|
||||
echo "docker4mac"
|
||||
else
|
||||
echo "native"
|
||||
fi
|
||||
}
|
||||
|
||||
has_docker_for_windows_client(){
|
||||
# debug $FUNCNAME
|
||||
if [[ "${GLOBAL_HOST_IP}" = "10.0.75.2" ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
is_docker_for_windows() {
|
||||
# debug $FUNCNAME
|
||||
if $(echo ${UNAME_R} | grep -q 'linuxkit') && has_docker_for_windows_client; then
|
||||
return 0
|
||||
elif $(echo ${UNAME_R} | grep -q 'moby') && has_docker_for_windows_client; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
is_docker_for_mac() {
|
||||
# debug $FUNCNAME
|
||||
if $(echo ${UNAME_R} | grep -q 'linuxkit') && ! has_docker_for_windows_client; then
|
||||
return 0
|
||||
elif $(echo ${UNAME_R} | grep -q 'moby') && ! has_docker_for_windows_client; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
is_native() {
|
||||
# debug $FUNCNAME
|
||||
if [ $(get_docker_install_type) = "native" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
docker_run() {
|
||||
# debug $FUNCNAME
|
||||
# Setup options for connecting to docker host
|
||||
if [ -z "${DOCKER_HOST+x}" ]; then
|
||||
DOCKER_HOST="/var/run/docker.sock"
|
||||
fi
|
||||
|
||||
echo "" > /tmp/docker_run_vars
|
||||
# Add environment variables for CHE
|
||||
while IFS='=' read -r -d '' key value; do
|
||||
if [[ ${key} == "CHE_"* ]]; then
|
||||
echo ${key}=${value} >> /tmp/docker_run_vars
|
||||
fi
|
||||
done < <(env -0)
|
||||
|
||||
# Add scripts global variables for CHE
|
||||
while read key; do
|
||||
if [[ ${key} == "CHE_"* ]]; then
|
||||
local ENV_VAL="${!key}"
|
||||
echo ${key}=${ENV_VAL} >> /tmp/docker_run_vars
|
||||
fi
|
||||
done < <(compgen -v)
|
||||
|
||||
|
||||
if [ -S "$DOCKER_HOST" ]; then
|
||||
docker run --rm --env-file /tmp/docker_run_vars \
|
||||
-v $DOCKER_HOST:$DOCKER_HOST \
|
||||
-v $HOME:$HOME \
|
||||
-w "$(pwd)" "$@"
|
||||
else
|
||||
docker run --rm --env-file /tmp/docker_run_vars \
|
||||
-e DOCKER_HOST -e DOCKER_TLS_VERIFY -e DOCKER_CERT_PATH \
|
||||
-v $HOME:$HOME \
|
||||
-w "$(pwd)" "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
has_curl() {
|
||||
hash curl 2>/dev/null && return 0 || return 1
|
||||
}
|
||||
|
||||
curl() {
|
||||
|
||||
# In situations where we are performing internal pings using curl, then
|
||||
# we should append the CHE_HOST as a no proxy. It seems that curl does
|
||||
# not respect the NO_PROXY environment variable set on the system.
|
||||
local NO_PROXY_CONFIG_FOR_CURL=("")
|
||||
if [[ ! "${HTTP_PROXY}" = "" ]] ||
|
||||
[[ ! "${HTTPS_PROXY}" = "" ]]; then
|
||||
if is_var_defined "${CHE_PRODUCT_NAME}_HOST"; then
|
||||
NO_PROXY_CONFIG_FOR_CURL=("--noproxy" $(eval "echo \$${CHE_PRODUCT_NAME}_HOST"))
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! has_curl; then
|
||||
log "docker run --rm --net=host appropriate/curl \"$@\""
|
||||
docker run --rm --net=host appropriate/curl ${NO_PROXY_CONFIG_FOR_CURL[@]} "$@"
|
||||
else
|
||||
log "$(which curl) ${NO_PROXY_CONFIG_FOR_CURL[@]} \"$@\""
|
||||
$(which curl) ${NO_PROXY_CONFIG_FOR_CURL[@]} "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
is_var_defined() {
|
||||
if [ $# -ne 1 ]
|
||||
then
|
||||
echo "Expected exactly one argument: variable name as string, e.g., 'my_var'"
|
||||
exit 1
|
||||
fi
|
||||
eval "[ ! -z \${$1:-} ]"
|
||||
return $?
|
||||
}
|
||||
|
|
@ -1,413 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2017 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
|
||||
cli_pre_init() {
|
||||
:
|
||||
}
|
||||
|
||||
cli_post_init() {
|
||||
:
|
||||
}
|
||||
|
||||
cli_init() {
|
||||
CHE_HOST=$(eval "echo \$${CHE_PRODUCT_NAME}_HOST")
|
||||
CHE_PORT=$(eval "echo \$${CHE_PRODUCT_NAME}_PORT")
|
||||
|
||||
if [[ "$(eval "echo \$${CHE_PRODUCT_NAME}_HOST")" = "" ]]; then
|
||||
info "Welcome to $CHE_FORMAL_PRODUCT_NAME!"
|
||||
info ""
|
||||
info "We did not auto-detect a valid HOST or IP address."
|
||||
info "Pass ${CHE_PRODUCT_NAME}_HOST with your hostname or IP address."
|
||||
info ""
|
||||
info "Rerun the CLI:"
|
||||
info " docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock"
|
||||
info " -v <local-path>:${CHE_CONTAINER_ROOT}"
|
||||
info " -e ${CHE_PRODUCT_NAME}_HOST=<your-ip-or-host>"
|
||||
info " $CHE_IMAGE_FULLNAME $*"
|
||||
return 2;
|
||||
fi
|
||||
|
||||
CLI_ENV_ARRAY_LENGTH=$(docker inspect --format='{{json .Config.Env}}' $(get_this_container_id) | jq '. | length')
|
||||
CLI_ENV_ARRAY=()
|
||||
# fill an array
|
||||
che_cli_env_arr_index="0"
|
||||
while [ $che_cli_env_arr_index -lt $CLI_ENV_ARRAY_LENGTH ]; do
|
||||
CLI_ENV_ARRAY[$che_cli_env_arr_index]=$(docker inspect --format='{{json .Config.Env}}' $(get_this_container_id) | jq -r .[$che_cli_env_arr_index])
|
||||
che_cli_env_arr_index=$[$che_cli_env_arr_index+1]
|
||||
done
|
||||
|
||||
CHE_HOST_PROTOCOL="http"
|
||||
if is_initialized; then
|
||||
CHE_HOST_LOCAL=$(get_value_of_var_from_env_file ${CHE_PRODUCT_NAME}_HOST)
|
||||
CHE_HOST_ENV=$(get_value_of_var_from_env ${CHE_PRODUCT_NAME}_HOST)
|
||||
if [[ "${CHE_HOST_ENV}" != "" ]] &&
|
||||
[[ "${CHE_HOST_ENV}" != "${CHE_HOST_LOCAL}" ]]; then
|
||||
warning "cli" "'${CHE_PRODUCT_NAME}_HOST=${CHE_HOST_ENV}' from command line overriding '${CHE_PRODUCT_NAME}_HOST=${CHE_HOST_LOCAL}' from ${CHE_ENVIRONMENT_FILE}"
|
||||
CHE_HOST=$CHE_HOST_ENV
|
||||
fi
|
||||
|
||||
CHE_HOST_PROTOCOL_ENV=$(get_value_of_var_from_env_file ${CHE_PRODUCT_NAME}_HOST_PROTOCOL)
|
||||
if [[ "${CHE_HOST_PROTOCOL_ENV}" != "" ]]; then
|
||||
CHE_HOST_PROTOCOL=${CHE_HOST_PROTOCOL_ENV}
|
||||
fi
|
||||
|
||||
if [[ "${CHE_HOST_ENV}" = "" ]] &&
|
||||
[[ "${CHE_HOST_LOCAL}" != "" ]]; then
|
||||
CHE_HOST=${CHE_HOST_LOCAL}
|
||||
|
||||
if [[ "${CHE_HOST}" != "${GLOBAL_HOST_IP}" ]]; then
|
||||
warning "cli" "'${CHE_PRODUCT_NAME}_HOST=${CHE_HOST_LOCAL}' is != discovered IP '${GLOBAL_HOST_IP}'"
|
||||
fi
|
||||
fi
|
||||
|
||||
CHE_PORT_LOCAL=$(get_value_of_var_from_env_file ${CHE_PRODUCT_NAME}_PORT)
|
||||
CHE_PORT_ENV=$(get_value_of_var_from_env ${CHE_PRODUCT_NAME}_PORT)
|
||||
|
||||
if [[ "${CHE_PORT_ENV}" != "" ]] &&
|
||||
[[ "${CHE_PORT_LOCAL}" != "" ]] &&
|
||||
[[ "${CHE_PORT_ENV}" != "${CHE_PORT_LOCAL}" ]]; then
|
||||
warning "cli" "'${CHE_PRODUCT_NAME}_PORT=${CHE_PORT_ENV}' from command line overriding '${CHE_PRODUCT_NAME}_PORT=${CHE_PORT_LOCAL}' from ${CHE_ENVIRONMENT_FILE}"
|
||||
CHE_PORT=$CHE_PORT_ENV
|
||||
fi
|
||||
|
||||
if [[ "${CHE_PORT_ENV}" = "" ]] &&
|
||||
[[ "${CHE_PORT_LOCAL}" != "" ]]; then
|
||||
CHE_PORT=${CHE_PORT_LOCAL}
|
||||
|
||||
if [[ "${CHE_PORT}" != "${DEFAULT_CHE_PORT}" ]]; then
|
||||
CHE_PORT=${CHE_PORT_LOCAL}
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
cli_verify_nightly() {
|
||||
# Per request of the engineers, check to see if the locally cached nightly version is older
|
||||
# than the one stored on DockerHub.
|
||||
if is_nightly; then
|
||||
|
||||
if ! is_fast && ! skip_nightly; then
|
||||
local CURRENT_DIGEST=$(docker images -q --no-trunc --digests ${CHE_IMAGE_FULLNAME})
|
||||
|
||||
update_image $CHE_IMAGE_FULLNAME
|
||||
|
||||
local NEW_DIGEST=$(docker images -q --no-trunc --digests ${CHE_IMAGE_FULLNAME})
|
||||
if [[ "${CURRENT_DIGEST}" != "${NEW_DIGEST}" ]]; then
|
||||
# Per CODENVY-1773 - removes orphaned nightly image
|
||||
warning "Pulled new 'nightly' image - please rerun CLI"
|
||||
docker rmi -f $(docker images --filter "dangling=true" -q $CHE_IMAGE_NAME) 2>/dev/null
|
||||
return 2;
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
cli_verify_version() {
|
||||
# Do not perform a version compatibility check if running upgrade command.
|
||||
# The upgrade command has its own internal checks for version compatibility.
|
||||
if [[ "$@" == *"upgrade"* ]]; then
|
||||
verify_upgrade
|
||||
elif ! is_fast; then
|
||||
verify_version
|
||||
fi
|
||||
}
|
||||
|
||||
is_nightly() {
|
||||
if [[ $(get_image_version) = "nightly" ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
verify_version() {
|
||||
|
||||
## If ! is_initialized, then the system hasn't been installed
|
||||
## First, compare the CLI image version to what version was initialized in /config/*.ver.donotmodify
|
||||
## - If they match, good
|
||||
## - 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: skip network, offline, nightly.
|
||||
if ! is_offline && ! is_nightly && ! is_fast && ! skip_network; then
|
||||
NEWER=$(compare_versions $CHE_IMAGE_VERSION)
|
||||
if [[ "${NEWER}" == "null" ]]; then
|
||||
warning "Unable to retrieve version list from public Docker Hub for image named ${CHE_IMAGE_NAME}."
|
||||
warning "Diagnose with 'docker run -it appropriate/curl -s https://hub.docker.com/v2/repositories/${CHE_IMAGE_NAME}/tags/'."
|
||||
warning "Use '--skip:network' to ignore this check."
|
||||
elif [[ "${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)
|
||||
case "${COMPARE_CLI_ENV}" in
|
||||
"match")
|
||||
;;
|
||||
"nightly")
|
||||
error ""
|
||||
error "Your CLI version '${CHE_IMAGE_FULLNAME}' does not match your installed version '$INSTALLED_VERSION' in ${DATA_MOUNT}."
|
||||
error ""
|
||||
error "The 'nightly' CLI is only compatible with 'nightly' installed versions."
|
||||
error "You may use 'nightly' with a separate ${CHE_FORMAL_PRODUCT_NAME} installation by providing a different ':/data' volume mount."
|
||||
error "You may not '${CHE_MINI_PRODUCT_NAME} upgrade' from 'nightly' to a numbered (tagged) version."
|
||||
error ""
|
||||
error "Run the CLI as '${CHE_IMAGE_NAME}:<version>' to install a tagged version."
|
||||
return 2
|
||||
;;
|
||||
"install-less-cli")
|
||||
error ""
|
||||
error "Your CLI version '${CHE_IMAGE_FULLNAME}' is newer than your installed version '$INSTALLED_VERSION'."
|
||||
error ""
|
||||
error "Run '${CHE_IMAGE_FULLNAME} upgrade' to migrate your installation to '$CHE_IMAGE_VERSION'."
|
||||
error "Or, run the CLI with '${CHE_IMAGE_NAME}:$INSTALLED_VERSION' to match the CLI with your installed version."
|
||||
return 2
|
||||
;;
|
||||
"cli-less-install")
|
||||
error ""
|
||||
error "Your CLI version '${CHE_IMAGE_FULLNAME}' is older than your installed version '$INSTALLED_VERSION'."
|
||||
error ""
|
||||
error "You cannot use an older CLI with a newer installation."
|
||||
error ""
|
||||
error "Run the CLI with '${CHE_IMAGE_NAME}:$INSTALLED_VERSION' to match the CLI with your existing installed version."
|
||||
return 2
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
verify_upgrade() {
|
||||
## Two levels of checks
|
||||
## First, compare the CLI image version to what the admin has configured in /config/.env file
|
||||
## - If they match, nothing to upgrade
|
||||
## - If they don't match and one is nightly, fail upgrade is not supported for nightly
|
||||
## - If they don't match, then if CLI is older fail with message that we do not support downgrade
|
||||
## - If they don't match, then if CLI is newer then good
|
||||
CHE_IMAGE_VERSION=$(get_image_version)
|
||||
|
||||
if ! is_initialized || ! is_configured; then
|
||||
info "upgrade" "$CHE_MINI_PRODUCT_NAME is not installed or configured. Nothing to upgrade."
|
||||
return 2
|
||||
fi
|
||||
|
||||
if is_initialized; then
|
||||
COMPARE_CLI_ENV=$(compare_cli_version_to_installed_version)
|
||||
CONFIGURED_VERSION=$(get_installed_version)
|
||||
|
||||
case "${COMPARE_CLI_ENV}" in
|
||||
"match")
|
||||
error ""
|
||||
error "Your CLI version '${CHE_IMAGE_FULLNAME}' is identical to your installed version '$CONFIGURED_VERSION'."
|
||||
error ""
|
||||
error "Run '${CHE_IMAGE_NAME}:<version> upgrade' with a newer version to upgrade."
|
||||
error "View available versions with '${CHE_IMAGE_FULLNAME} version'."
|
||||
return 2
|
||||
;;
|
||||
"nightly")
|
||||
error ""
|
||||
error "Your CLI version '${CHE_IMAGE_FULLNAME}' or installed version '$CONFIGURED_VERSION' is nightly."
|
||||
error ""
|
||||
error "You may not '${CHE_IMAGE_NAME} upgrade' from 'nightly' to a numbered (tagged) version."
|
||||
error "You can 'docker pull ${CHE_IMAGE_FULLNAME}' to get a newer nightly version."
|
||||
return 2
|
||||
;;
|
||||
"install-less-cli")
|
||||
;;
|
||||
"cli-less-install")
|
||||
error ""
|
||||
error "Your CLI version '${CHE_IMAGE_FULLNAME}' is older than your installed version '$CONFIGURED_VERSION'."
|
||||
error ""
|
||||
error "You cannot use '${CHE_IMAGE_NAME} upgrade' to downgrade versions."
|
||||
error ""
|
||||
error "Run '${CHE_IMAGE_NAME}:<version> upgrade' with a newer version to upgrade."
|
||||
error "View available versions with '${CHE_IMAGE_FULLNAME} version'."
|
||||
return 2
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
get_installed_version() {
|
||||
if ! is_initialized; then
|
||||
echo "<not-configed>"
|
||||
else
|
||||
cat "${CHE_CONTAINER_INSTANCE}"/$CHE_VERSION_FILE
|
||||
fi
|
||||
}
|
||||
|
||||
get_image_version() {
|
||||
echo "$CHE_IMAGE_VERSION"
|
||||
}
|
||||
|
||||
# Check if a version is < than another version (provide like for example : version_lt 5.0 5.1)
|
||||
version_lt() {
|
||||
test "$(printf '%s\n' "$@" | sort -V | head -n 1)" == "$1";
|
||||
return $?;
|
||||
}
|
||||
|
||||
# return true if the provided version is an intermediate version (like a Milestone or a Release Candidate)
|
||||
is_intermediate_version() {
|
||||
if [[ "$1" =~ .*-M.* ]]; then
|
||||
return 0
|
||||
fi
|
||||
if [[ "$1" =~ .*-RC.* ]]; then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# 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
|
||||
# Does not work with nightly versions - do not use this to compare nightly to another version
|
||||
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')
|
||||
|
||||
if [[ "${NUMBER_OF_VERSIONS}" = "" ]] || [[ "${NUMBER_OF_VERSIONS}" = "null" ]]; then
|
||||
echo "null"
|
||||
return
|
||||
fi
|
||||
|
||||
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" ] && [ "$TAG" != "${BASE_VERSION}" ]; then
|
||||
if version_lt $BASE_VERSION $TAG; then
|
||||
RETURN_VERSION=$TAG
|
||||
break;
|
||||
fi
|
||||
fi
|
||||
let COUNTER=COUNTER+1
|
||||
done
|
||||
|
||||
echo $RETURN_VERSION
|
||||
}
|
||||
|
||||
compare_cli_version_to_installed_version() {
|
||||
IMAGE_VERSION=$(get_image_version)
|
||||
INSTALLED_VERSION=$(get_installed_version)
|
||||
|
||||
# add -ZZ suffix if not intermediate version
|
||||
# So for example 5.0.0 is transformed into 5.0.0-ZZ and is greater than 5.0.0-M8
|
||||
IMAGE_VERSION_SUFFIXED=${IMAGE_VERSION}
|
||||
INSTALLED_VERSION_SUFFIXED=${INSTALLED_VERSION}
|
||||
if ! is_intermediate_version ${IMAGE_VERSION}; then
|
||||
IMAGE_VERSION_SUFFIXED="${IMAGE_VERSION}-ZZ"
|
||||
fi
|
||||
if ! is_intermediate_version ${INSTALLED_VERSION}; then
|
||||
INSTALLED_VERSION_SUFFIXED="${INSTALLED_VERSION}-ZZ"
|
||||
fi
|
||||
|
||||
if [[ "$INSTALLED_VERSION" = "$IMAGE_VERSION" ]]; then
|
||||
echo "match"
|
||||
elif [ "$INSTALLED_VERSION" = "nightly" ] ||
|
||||
[ "$IMAGE_VERSION" = "nightly" ]; then
|
||||
echo "nightly"
|
||||
elif version_lt $INSTALLED_VERSION_SUFFIXED $IMAGE_VERSION_SUFFIXED; then
|
||||
echo "install-less-cli"
|
||||
else
|
||||
echo "cli-less-install"
|
||||
fi
|
||||
}
|
||||
|
||||
is_initialized() {
|
||||
if [[ -d "${CHE_CONTAINER_INSTANCE}" ]] && \
|
||||
[[ -f "${CHE_CONTAINER_INSTANCE}"/$CHE_VERSION_FILE ]] && \
|
||||
[[ -f "${REFERENCE_CONTAINER_ENVIRONMENT_FILE}" ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
is_configured() {
|
||||
if [[ -d "${CHE_CONTAINER_INSTANCE}/config" ]] && \
|
||||
[[ -f "${CHE_CONTAINER_INSTANCE}/${CHE_VERSION_FILE}" ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
update_image() {
|
||||
if [ "${1}" == "--force" ]; then
|
||||
shift
|
||||
info "download" "Removing image $1"
|
||||
log "docker rmi -f $1 >> \"${LOGS}\""
|
||||
docker rmi -f $1 >> "${LOGS}" 2>&1 || true
|
||||
fi
|
||||
|
||||
if [ "${1}" == "--pull" ]; then
|
||||
shift
|
||||
fi
|
||||
|
||||
info "download" "Pulling image $1"
|
||||
text "\n"
|
||||
log "docker pull $1 >> \"${LOGS}\" 2>&1"
|
||||
TEST=""
|
||||
docker pull $1 || TEST=$?
|
||||
if [ "$TEST" = "1" ]; then
|
||||
error "Image $1 unavailable. Not on dockerhub or built locally."
|
||||
return 2;
|
||||
fi
|
||||
text "\n"
|
||||
}
|
||||
|
||||
# Input is a variable that would exist in the che.env file such as CHE_HOST.
|
||||
# We then lookup the vlaue of this variable and return it
|
||||
get_value_of_var_from_env_file() {
|
||||
local LOOKUP_LOCAL=$(docker_run --env-file="${REFERENCE_CONTAINER_ENVIRONMENT_FILE}" \
|
||||
${BOOTSTRAP_IMAGE_ALPINE} sh -c "echo \$$1")
|
||||
echo $LOOKUP_LOCAL
|
||||
}
|
||||
|
||||
# Returns the value of variable from environment array.
|
||||
get_value_of_var_from_env() {
|
||||
for element in "${CLI_ENV_ARRAY[@]}"
|
||||
do
|
||||
var1=$(echo $element | cut -f1 -d=)
|
||||
var2=$(echo $element | cut -f2 -d=)
|
||||
|
||||
if [ $var1 = $1 ]; then
|
||||
echo $var2
|
||||
fi
|
||||
done
|
||||
echo ""
|
||||
}
|
||||
|
||||
# This will compare two same length strings, such as versions
|
||||
less_than() {
|
||||
for (( i=0; i<${#1}; i++ )); do
|
||||
if [[ ${1:$i:1} != ${2:$i:1} ]]; then
|
||||
if [ ${1:$i:1} -lt ${2:$i:1} ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2017 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
|
||||
cli_load() {
|
||||
# Library contains reusable functions
|
||||
source "${SCRIPTS_BASE_CONTAINER_SOURCE_DIR}"/library.sh
|
||||
|
||||
if [ -f "${SCRIPTS_CONTAINER_SOURCE_DIR}"/library.sh ]; then
|
||||
source "${SCRIPTS_CONTAINER_SOURCE_DIR}"/library.sh
|
||||
fi
|
||||
}
|
||||
|
||||
cli_parse () {
|
||||
COMMAND="cmd_$1"
|
||||
|
||||
case $1 in
|
||||
init|config|start|stop|restart|backup|restore|info|offline|destroy|download|\
|
||||
rmi|upgrade|version|ssh|sync|action|test|compile|dir|help|archetype)
|
||||
;;
|
||||
*)
|
||||
error "You passed an unknown command: $1"
|
||||
usage
|
||||
return 2
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
cli_execute() {
|
||||
cmd_lifecycle "$@"
|
||||
}
|
||||
|
||||
cmd_lifecycle() {
|
||||
local PRE_COMMAND="pre_cmd_$1"
|
||||
local POST_COMMAND="post_cmd_$1"
|
||||
local HELP_COMMAND="help_cmd_$1"
|
||||
local COMMAND="cmd_$1"
|
||||
|
||||
if [ -f "${SCRIPTS_BASE_CONTAINER_SOURCE_DIR}"/commands/cmd_$1.sh ]; then
|
||||
source "${SCRIPTS_BASE_CONTAINER_SOURCE_DIR}"/commands/cmd_$1.sh
|
||||
fi
|
||||
|
||||
if [ -f "${SCRIPTS_CONTAINER_SOURCE_DIR}"/cmd_$1.sh ]; then
|
||||
source "${SCRIPTS_CONTAINER_SOURCE_DIR}"/cmd_$1.sh
|
||||
fi
|
||||
|
||||
shift
|
||||
|
||||
if get_command_help; then
|
||||
ANSWER=$(declare -f $HELP_COMMAND > /dev/null)
|
||||
if [ $? = "0" ]; then
|
||||
eval $HELP_COMMAND "$@"
|
||||
return 2
|
||||
else
|
||||
error "No help function found for $1"
|
||||
fi
|
||||
fi
|
||||
|
||||
local PRE_COMMAND_STATUS=0
|
||||
ANSWER=$(declare -f $PRE_COMMAND ) # > /dev/null)
|
||||
if [ $? = "0" ]; then
|
||||
eval $PRE_COMMAND "$@"
|
||||
PRE_COMMAND_STATUS=$?
|
||||
fi
|
||||
|
||||
eval $COMMAND "$@"
|
||||
local COMMAND_STATUS=$?
|
||||
|
||||
|
||||
|
||||
local POST_COMMAND_STATUS=0
|
||||
ANSWER=$(declare -f $POST_COMMAND > /dev/null)
|
||||
if [ $? = "0" ]; then
|
||||
eval $POST_COMMAND "$@"
|
||||
POST_COMMAND_STATUS=$?
|
||||
fi
|
||||
|
||||
if [[ POST_COMMAND_STATUS -ne 0 ]]; then
|
||||
return ${POST_COMMAND_STATUS};
|
||||
else
|
||||
return ${COMMAND_STATUS};
|
||||
fi
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2017 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
|
||||
source /scripts/base/startup.sh
|
||||
start "$@"
|
||||
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Marian Labuda
|
||||
FROM docker:1.11.2
|
||||
|
||||
# ncurses is used to use --pretty option of bats
|
||||
RUN apk add --no-cache bash ncurses
|
||||
|
||||
RUN curl -o /tmp/v0.4.0.tar.gz -L https://github.com/sstephenson/bats/archive/v0.4.0.tar.gz \
|
||||
&& tar -x -z -f /tmp/v0.4.0.tar.gz -C /tmp \
|
||||
&& bash /tmp/bats-0.4.0/install.sh /usr/local \
|
||||
&& rm -rf /tmp/* \
|
||||
&& curl -o /tmp/bats-support-v0.3.0.tar.gz -L https://github.com/ztombol/bats-support/archive/v0.3.0.tar.gz \
|
||||
&& tar -x -z -f /tmp/bats-support-v0.3.0.tar.gz -C /tmp \
|
||||
&& mv /tmp/bats-support-0.3.0/ /bats-support \
|
||||
&& rm -rf /bats-support/test && rm -rf /bats-support/script \
|
||||
&& rm -rf /tmp/* \
|
||||
&& curl -o /tmp/bats-assert-v0.3.0.tar.gz -L https://github.com/ztombol/bats-assert/archive/v0.3.0.tar.gz \
|
||||
&& tar -x -z -f /tmp/bats-assert-v0.3.0.tar.gz -C /tmp \
|
||||
&& mv /tmp/bats-assert-0.3.0 /bats-assert \
|
||||
&& rm -rf /bats-assert/test && rm -rf /bats-assert/script \
|
||||
&& rm -rf /tmp/*
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
|
||||
base_dir=$(cd "$(dirname "$0")"; pwd)
|
||||
. "${base_dir}"/../build.include
|
||||
|
||||
init --name:bats "$@"
|
||||
build
|
||||
|
|
@ -1 +0,0 @@
|
|||
tests
|
||||
|
|
@ -1 +0,0 @@
|
|||
tests/testrun/*
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
base
|
||||
bats
|
||||
che
|
||||
init
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
# Copyright (c) 2017 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# build:
|
||||
# docker build -t eclipse/che-cli .
|
||||
#
|
||||
# use:
|
||||
# docker run -v $(pwd):/che eclipse/che-cli [command]
|
||||
FROM ${BUILD_ORGANIZATION}/${BUILD_PREFIX}-base:${BUILD_TAG}
|
||||
|
||||
COPY scripts /scripts/
|
||||
COPY version /version/
|
||||
|
||||
RUN mkdir /che
|
||||
ENTRYPOINT ["/scripts/entrypoint.sh"]
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2017 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
|
||||
base_dir=$(cd "$(dirname "$0")"; pwd)
|
||||
. "${base_dir}"/../build.include
|
||||
|
||||
init --name:cli "$@"
|
||||
|
||||
# Define space separated list of aliases for the docker image
|
||||
IMAGE_ALIASES="${ORGANIZATION}/${PREFIX}"
|
||||
|
||||
if [[ ! -f "${base_dir}/version/$TAG/images" ]]; then
|
||||
mkdir -p ${base_dir}/version/$TAG/
|
||||
cat ${base_dir}/images.template | sed s/\$\{BUILD_ORGANIZATION\}/${ORGANIZATION}/ | sed s/\$\{BUILD_PREFIX\}/${PREFIX}/ | sed s/\$\{BUILD_TAG\}/${TAG}/ > ${base_dir}/version/$TAG/images
|
||||
fi
|
||||
|
||||
|
||||
build
|
||||
|
||||
if ! skip_tests; then
|
||||
bash "${base_dir}"/test.sh "$@"
|
||||
fi
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
IMAGE_INIT=${BUILD_ORGANIZATION}/${BUILD_PREFIX}-init:${BUILD_TAG}
|
||||
IMAGE_CHE=${BUILD_ORGANIZATION}/${BUILD_PREFIX}-server:${BUILD_TAG}
|
||||
IMAGE_COMPOSE=docker/compose:1.10.1
|
||||
IMAGE_TRAEFIK=traefik:v1.5.0
|
||||
IMAGE_POSTGRES=centos/postgresql-96-centos7
|
||||
IMAGE_KEYCLOACK=jboss/keycloak-openshift:3.4.3.Final
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2017 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
|
||||
post_init() {
|
||||
GLOBAL_HOST_IP=${GLOBAL_HOST_IP:=$(docker_run --net host ${BOOTSTRAP_IMAGE_CHEIP})}
|
||||
DEFAULT_CHE_HOST=$GLOBAL_HOST_IP
|
||||
CHE_HOST=${CHE_HOST:-${DEFAULT_CHE_HOST}}
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2017 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
|
||||
pre_init() {
|
||||
ADDITIONAL_MANDATORY_PARAMETERS=""
|
||||
ADDITIONAL_OPTIONAL_DOCKER_PARAMETERS="
|
||||
-e CHE_HOST=<YOUR_HOST> IP address or hostname where che will serve its users
|
||||
-e CHE_PORT=<YOUR_PORT> Port where che will bind itself to
|
||||
-e CHE_CONTAINER=<YOUR_NAME> Name for the che container
|
||||
-u <name|uid>[:<group|gid>] (Linux Only) Runs che with specific user and group identity"
|
||||
ADDITIONAL_OPTIONAL_DOCKER_MOUNTS=""
|
||||
ADDITIONAL_COMMANDS=""
|
||||
ADDITIONAL_GLOBAL_OPTIONS=""
|
||||
|
||||
# This must be incremented when BASE is incremented by an API developer
|
||||
CHE_CLI_API_VERSION=2
|
||||
|
||||
DEFAULT_CHE_PORT=8080
|
||||
CHE_PORT=${CHE_PORT:-${DEFAULT_CHE_PORT}}
|
||||
CHE_MIN_RAM=1.5
|
||||
CHE_MIN_DISK=100
|
||||
}
|
||||
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Marian Labuda - Initial Implementation
|
||||
|
||||
BATS_BASE_DIR=$(cd "$(dirname "$0")"/..; pwd)
|
||||
. "${BATS_BASE_DIR}"/build.include
|
||||
BATS_BASE_DIR=$(get_mount_path "${BATS_BASE_DIR}")
|
||||
|
||||
init --name:bats "$@"
|
||||
|
||||
DOCKER_RUN_OPTIONS=""
|
||||
BATS_OPTIONS=""
|
||||
# run bats with terminal mode (pretty print) if supported by current shell
|
||||
if [ -t 1 ]; then
|
||||
DOCKER_RUN_OPTIONS="-t"
|
||||
BATS_OPTIONS="--pretty"
|
||||
else
|
||||
BATS_OPTIONS="--tap"
|
||||
fi
|
||||
|
||||
# Runs functional CLI tests in a docker container.
|
||||
# Pass a file name of functional bats tests as an argument.
|
||||
# The file has to be placed in tests folder in directory containing this script
|
||||
# (Optional) second argument is options for a docker run command.
|
||||
run_test_in_docker_container() {
|
||||
docker_exec run --rm ${DOCKER_RUN_OPTIONS} $2 \
|
||||
-v "${BATS_BASE_DIR}":/dockerfiles \
|
||||
-e CLI_IMAGE="$ORGANIZATION/$PREFIX-cli:$TAG" \
|
||||
-e BATS_BASE_DIR="${BATS_BASE_DIR}" \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||
$IMAGE_NAME bats ${BATS_OPTIONS} /dockerfiles/cli/tests/$1
|
||||
}
|
||||
|
||||
echo "Running tests in container from image $IMAGE_NAME"
|
||||
echo "Running functionals bats tests for overriding images"
|
||||
run_test_in_docker_container override_image_tests.bats ""
|
||||
echo "Running functional bats tests for CLI prompts and usage"
|
||||
run_test_in_docker_container cli_prompts_usage_tests.bats ""
|
||||
echo "Running functionals bats tests for config command"
|
||||
run_test_in_docker_container cmd_config_tests.bats ""
|
||||
echo "Running functionals bats tests for info command"
|
||||
run_test_in_docker_container cmd_info_tests.bats ""
|
||||
echo "Running functional bats tests for init and destroy commands"
|
||||
run_test_in_docker_container cmd_init_destroy_tests.bats ""
|
||||
echo "Running functionals bats tests for start, stop, restart command"
|
||||
run_test_in_docker_container cmd_start_stop_restart_tests.bats --net=host
|
||||
echo "Running functionals bats tests for backup / restore commands"
|
||||
run_test_in_docker_container cmd_backup_restore_tests.bats ""
|
||||
echo "Running functionals bats tests for offline command"
|
||||
run_test_in_docker_container cmd_offline_tests.bats ""
|
||||
run_test_in_docker_container startup_03_pre_networking_tests.bats ""
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
#!/usr/bin/env bats
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Marian Labuda - Initial Implementation
|
||||
|
||||
load '/bats-support/load.bash'
|
||||
load '/bats-assert/load.bash'
|
||||
source /dockerfiles/cli/tests/test_base.sh
|
||||
|
||||
@test "test CLI prompt to provide volume for docker sock" {
|
||||
#GIVEN
|
||||
prompt_substring="-v /var/run/docker.sock:/var/run/docker.sock"
|
||||
|
||||
#WHEN
|
||||
run execute_cli_command --che-cli-mount-scripts=false --che-cli-use-docker-sock=false --che-cli-command=start
|
||||
|
||||
#THEN
|
||||
assert_failure
|
||||
assert_output --partial ${prompt_substring}
|
||||
}
|
||||
|
||||
@test "test CLI prompt to provide directory for user data" {
|
||||
#GIVEN
|
||||
prompt_substring="-v <YOUR_LOCAL_PATH>:/data"
|
||||
|
||||
#WHEN
|
||||
run execute_cli_command --che-cli-command=start
|
||||
|
||||
#THEN
|
||||
assert_failure
|
||||
assert_output --partial ${prompt_substring}
|
||||
}
|
||||
|
||||
@test "test CLI 'usage' when running container without command" {
|
||||
#GIVEN
|
||||
expected_output="USAGE:"
|
||||
|
||||
#WHEN
|
||||
result=$(execute_cli_command || true)
|
||||
|
||||
#THEN
|
||||
[[ $result == *${expected_output}* ]]
|
||||
}
|
||||
|
|
@ -1,128 +0,0 @@
|
|||
#!/usr/bin/env bats
|
||||
# Copyright (c) 2017 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Roman Iuvshyn
|
||||
|
||||
source /dockerfiles/cli/tests/test_base.sh
|
||||
|
||||
# Kill running che server instance if there is any to be able to run tests
|
||||
setup() {
|
||||
kill_running_named_container che
|
||||
remove_named_container che
|
||||
}
|
||||
|
||||
teardown() {
|
||||
kill_running_named_container che
|
||||
remove_named_container che
|
||||
}
|
||||
|
||||
@test "test cli 'backup' command: backup fail if che is running" {
|
||||
#GIVEN
|
||||
if [ ! port_is_free 8080 ]; then
|
||||
[ "$status" -eq 1 ]
|
||||
[ "$output" = "Default port 8080 for che server is used. Cannot run this test on default che server port" ]
|
||||
fi
|
||||
tmp_path="${TESTRUN_DIR}"/cli_cmd_backup_fail_if_che_is_running
|
||||
mkdir -p "${tmp_path}"
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=start --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
check_che_state
|
||||
#WHEN
|
||||
result=$(execute_cli_command --che-data-path=${tmp_path} --che-cli-command=backup --che-cli-extra-options="--skip:nightly --skip:pull" || true)
|
||||
|
||||
#THEN
|
||||
[[ $result == *"che is running. Stop before performing a backup."* ]]
|
||||
}
|
||||
|
||||
@test "test cli 'restore' command: restore fail if che is running" {
|
||||
#GIVEN
|
||||
if [ ! port_is_free 8080 ]; then
|
||||
[ "$status" -eq 1 ]
|
||||
[ "$output" = "Default port 8080 for che server is used. Cannot run this test on default che server port" ]
|
||||
fi
|
||||
tmp_path="${TESTRUN_DIR}"/cli_cmd_restore_fail_if_che_is_running
|
||||
mkdir -p "${tmp_path}"
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=start --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
check_che_state
|
||||
#WHEN
|
||||
result=$(execute_cli_command --che-data-path=${tmp_path} --che-cli-command=restore --che-cli-extra-options="--quiet --skip:nightly --skip:pull")
|
||||
|
||||
#THEN
|
||||
[[ $result == *"Eclipse Che is running. Stop before performing a restore."* ]]
|
||||
}
|
||||
|
||||
@test "test cli 'restore' command: restore fail if no backup found" {
|
||||
#GIVEN
|
||||
if [ ! port_is_free 8080 ]; then
|
||||
[ "$status" -eq 1 ]
|
||||
[ "$output" = "Default port 8080 for che server is used. Cannot run this test on default che server port" ]
|
||||
fi
|
||||
tmp_path="${TESTRUN_DIR}"/cli_cmd_restore_fail_if_no_backup_found
|
||||
mkdir -p "${tmp_path}"
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=start --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
check_che_state
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=stop --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
|
||||
#WHEN
|
||||
result=$(execute_cli_command --che-data-path=${tmp_path} --che-cli-command=restore --che-cli-extra-options="--quiet --skip:nightly --skip:pull")
|
||||
|
||||
#THEN
|
||||
[[ $result == *"Backup files not found. To do restore please do backup first."* ]]
|
||||
}
|
||||
|
||||
@test "test cli 'backup / restore' commands" {
|
||||
# TEST BACKUP
|
||||
#GIVEN
|
||||
if [ ! port_is_free 8080 ]; then
|
||||
[ "$status" -eq 1 ]
|
||||
[ "$output" = "Default port 8080 for che server is used. Cannot run this test on default che server port" ]
|
||||
fi
|
||||
tmp_path="${TESTRUN_DIR}"/cli_cmd_backup_do_backup_restore
|
||||
container_tmp_path="${CONTAINER_TESTRUN_DIR}"/cli_cmd_backup_do_backup_restore
|
||||
workspace_name="backup-restore"
|
||||
mkdir -p "${tmp_path}"
|
||||
#start che
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=start --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
check_che_state
|
||||
#create a workspace
|
||||
|
||||
ws_create=$(curl 'http://'${ip_address}':8080/api/workspace?namespace=che&attribute=stackId:java-default' -H 'Content-Type: application/json;charset=UTF-8' -H 'Accept: application/json, text/plain, */*' --data-binary '{"defaultEnv":"wksp-1p0b","environments":{"wksp-1p0b":{"recipe":{"location":"eclipse/ubuntu_jdk8","type":"dockerimage"},"machines":{"dev-machine":{"servers":{},"installers":["org.eclipse.che.exec","org.eclipse.che.terminal","org.eclipse.che.ws-agent","org.eclipse.che.ssh"],"attributes":{"memoryLimitBytes":"2147483648"}}}}},"projects":[],"commands":[{"commandLine":"mvn clean install -f ${current.project.path}","name":"build","type":"mvn","attributes":{"goal":"Build","previewUrl":""}}],"name":"backup-restore","links":[]}' --compressed)
|
||||
[[ "$ws_create" == *"created"* ]]
|
||||
[[ "$ws_create" == *"STOPPED"* ]]
|
||||
#stop che
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=stop --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
|
||||
#WHEN
|
||||
backup=$(execute_cli_command --che-data-path=${tmp_path} --che-cli-command=backup --che-cli-extra-options="--skip:nightly --skip:pull")
|
||||
|
||||
#THEN
|
||||
[[ "$backup" == *"Saving Eclipse Che data..."* ]]
|
||||
[[ "$backup" == *"che data saved in ${tmp_path}/backup/che_backup.tar.gz"* ]]
|
||||
[[ -f "${container_tmp_path}"/backup/che_backup.tar.gz ]]
|
||||
|
||||
# TEST RESTORE
|
||||
#GIVEN
|
||||
#destroy to wipe data
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=destroy --che-cli-extra-options="--quiet --skip:nightly --skip:pull"
|
||||
[[ ! -d "${container_tmp_path}"/instance ]]
|
||||
#WHEN
|
||||
#perform restore from backup
|
||||
restore=$(execute_cli_command --che-data-path=${tmp_path} --che-cli-command=restore --che-cli-extra-options="--quiet --skip:nightly --skip:pull")
|
||||
|
||||
#THEN
|
||||
[[ "$restore" == *"Recovering Eclipse Che data..."* ]]
|
||||
[[ -d "${container_tmp_path}"/instance ]]
|
||||
[[ -d "${container_tmp_path}"/instance/data ]]
|
||||
|
||||
#WHEN
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=start --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
check_che_state
|
||||
|
||||
#THEN
|
||||
[[ "$(curl -fsS http://${ip_address}:8080/api/workspace)" == *"$workspace_name"* ]]
|
||||
}
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
#!/usr/bin/env bats
|
||||
# Copyright (c) 2017 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Roman Iuvshyn
|
||||
|
||||
load '/bats-support/load.bash'
|
||||
load '/bats-assert/load.bash'
|
||||
source /dockerfiles/cli/tests/test_base.sh
|
||||
|
||||
@test "test CLI 'config' command" {
|
||||
#GIVEN
|
||||
tmp_path="${TESTRUN_DIR}"/cli_cmd_config
|
||||
container_tmp_path="${CONTAINER_TESTRUN_DIR}"/cli_cmd_config
|
||||
|
||||
#WHEN
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=config --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
|
||||
#THEN
|
||||
[[ -d "${container_tmp_path}"/docs ]]
|
||||
[[ -e "${container_tmp_path}"/che.env ]]
|
||||
[[ -e "${container_tmp_path}"/cli.log ]]
|
||||
[[ -d "${container_tmp_path}"/instance ]]
|
||||
[[ -d "${container_tmp_path}"/instance/config ]]
|
||||
[[ -d "${container_tmp_path}"/instance/config/che ]]
|
||||
[[ -f "${container_tmp_path}"/instance/config/che/che.env ]]
|
||||
[[ -d "${container_tmp_path}"/instance/config/keycloak/che ]]
|
||||
[[ -f "${container_tmp_path}"/instance/config/keycloak/che-realm.json ]]
|
||||
[[ -f "${container_tmp_path}"/instance/config/postgres/init-che-user.sh ]]
|
||||
[[ -f "${container_tmp_path}"/instance/config/traefik/traefik.toml ]]
|
||||
[[ -d "${container_tmp_path}"/instance/data ]]
|
||||
[[ -d "${container_tmp_path}"/instance/logs ]]
|
||||
[[ -d "${container_tmp_path}"/instance/templates ]]
|
||||
[[ -f "${container_tmp_path}"/instance/docker-compose-container.yml ]]
|
||||
[[ -f "${container_tmp_path}"/instance/che.ver.do_not_modify ]]
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
#!/usr/bin/env bats
|
||||
# Copyright (c) 2017 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Roman Iuvshyn
|
||||
|
||||
load '/bats-support/load.bash'
|
||||
load '/bats-assert/load.bash'
|
||||
source /dockerfiles/cli/tests/test_base.sh
|
||||
|
||||
@test "test CLI 'info' command" {
|
||||
#GIVEN
|
||||
tmp_path="${TESTRUN_DIR}"/cli_cmd_info
|
||||
expected_output_1="CLI:"
|
||||
expected_output_2="Mounts:"
|
||||
expected_output_3="System:"
|
||||
expected_output_4="Internal:"
|
||||
expected_output_5="Image Registry:"
|
||||
|
||||
#WHEN
|
||||
result=$(execute_cli_command --che-data-path=${tmp_path} --che-cli-command=info --che-cli-extra-options="--skip:nightly --skip:pull")
|
||||
|
||||
#THEN
|
||||
[[ $result == *${expected_output_1}* ]]
|
||||
[[ $result == *${expected_output_2}* ]]
|
||||
[[ $result == *${expected_output_3}* ]]
|
||||
[[ $result == *${expected_output_4}* ]]
|
||||
[[ $result == *${expected_output_5}* ]]
|
||||
}
|
||||
|
|
@ -1,123 +0,0 @@
|
|||
#!/usr/bin/env bats
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Marian Labuda - Initial Implementation
|
||||
|
||||
source /dockerfiles/cli/tests/test_base.sh
|
||||
|
||||
@test "test 'init' and 'destroy --quiet' with existing dir" {
|
||||
|
||||
#GIVEN
|
||||
tmp_path="${TESTRUN_DIR}"/init-destroy1
|
||||
container_tmp_path=""${CONTAINER_TESTRUN_DIR}""/init-destroy1
|
||||
mkdir -p "${tmp_path}"
|
||||
|
||||
#WHEN
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=init --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
|
||||
#THEN
|
||||
[[ -d "${container_tmp_path}"/docs ]]
|
||||
[[ -d "${container_tmp_path}"/instance ]]
|
||||
[[ -e "${container_tmp_path}"/che.env ]]
|
||||
[[ -e "${container_tmp_path}"/cli.log ]]
|
||||
|
||||
#WHEN
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=destroy --che-cli-extra-options="--quiet --skip:nightly --skip:pull"
|
||||
|
||||
#THEN
|
||||
[[ ! -d "${container_tmp_path}"/docs ]]
|
||||
[[ ! -d "${container_tmp_path}"/instance ]]
|
||||
[[ ! -e "${container_tmp_path}"/che.env ]]
|
||||
[[ -e "${container_tmp_path}"/cli.log ]]
|
||||
rm -rf "${container_tmp_path}"
|
||||
}
|
||||
|
||||
@test "test 'init' and 'destroy --quiet' with non-existing dir" {
|
||||
|
||||
#GIVEN
|
||||
tmp_path="${TESTRUN_DIR}"/init-destroy2
|
||||
container_tmp_path="${CONTAINER_TESTRUN_DIR}"/init-destroy2
|
||||
|
||||
#WHEN
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=init --che-cli-extra-options="--skip:nightly --skip:pull 1>/dev/null"
|
||||
|
||||
#THEN
|
||||
[[ -e "${container_tmp_path}" ]]
|
||||
[[ -d "${container_tmp_path}"/docs ]]
|
||||
[[ -d "${container_tmp_path}"/instance ]]
|
||||
[[ -e "${container_tmp_path}"/che.env ]]
|
||||
[[ -e "${container_tmp_path}"/cli.log ]]
|
||||
|
||||
#WHEN
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=destroy --che-cli-extra-options="--quiet --skip:nightly --skip:pull 1>/dev/null"
|
||||
|
||||
#THEN
|
||||
[[ ! -d "${container_tmp_path}"/docs ]]
|
||||
[[ ! -d "${container_tmp_path}"/instance ]]
|
||||
[[ ! -e "${container_tmp_path}"/che.env ]]
|
||||
[[ -e "${container_tmp_path}"/cli.log ]]
|
||||
rm -rf "${container_tmp_path}"
|
||||
|
||||
}
|
||||
|
||||
@test "test 'init' and 'destroy --quiet --cli' with existing dir" {
|
||||
#GIVEN
|
||||
tmp_path="${TESTRUN_DIR}"/init-destroy3
|
||||
container_tmp_path="${CONTAINER_TESTRUN_DIR}"/init-destroy3
|
||||
|
||||
mkdir -p "${tmp_path}"
|
||||
|
||||
#WHEN
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=init --che-cli-extra-options="--skip:nightly --skip:pull 1>/dev/null"
|
||||
remove_named_container $CLI_CONTAINER
|
||||
|
||||
#THEN
|
||||
[[ -d "${container_tmp_path}"/docs ]]
|
||||
[[ -d "${container_tmp_path}"/instance ]]
|
||||
[[ -e "${container_tmp_path}"/che.env ]]
|
||||
[[ -e "${container_tmp_path}"/cli.log ]]
|
||||
|
||||
#WHEN
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=destroy --che-cli-extra-options="--quiet --skip:nightly --skip:pull --cli 1>/dev/null"
|
||||
|
||||
#THEN
|
||||
[[ ! -d "${container_tmp_path}"/docs ]]
|
||||
[[ ! -d "${container_tmp_path}"/instance ]]
|
||||
[[ ! -e "${container_tmp_path}"/che.env ]]
|
||||
[[ ! -e "${container_tmp_path}"/cli.log ]]
|
||||
rm -rf "${container_tmp_path}"
|
||||
|
||||
}
|
||||
|
||||
@test "test 'init' and 'destroy --quiet --cli' with non-existing dir" {
|
||||
|
||||
#GIVEN
|
||||
tmp_path="${TESTRUN_DIR}"/init-destroy4
|
||||
container_tmp_path="${CONTAINER_TESTRUN_DIR}"/init-destroy4
|
||||
|
||||
#WHEN
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=init --che-cli-extra-options="--skip:nightly --skip:pull 1>/dev/null"
|
||||
|
||||
#THEN
|
||||
[[ -d "${container_tmp_path}" ]]
|
||||
[[ -d "${container_tmp_path}"/docs ]]
|
||||
[[ -d "${container_tmp_path}"/instance ]]
|
||||
[[ -e "${container_tmp_path}"/che.env ]]
|
||||
[[ -e "${container_tmp_path}"/cli.log ]]
|
||||
|
||||
#WHEN
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=destroy --che-cli-extra-options="--skip:nightly --skip:pull --quiet --cli 1>/dev/null"
|
||||
|
||||
#THEN
|
||||
[[ ! -d "${container_tmp_path}"/docs ]]
|
||||
[[ ! -d "${container_tmp_path}"/instance ]]
|
||||
[[ ! -e "${container_tmp_path}"/che.env ]]
|
||||
[[ ! -e "${container_tmp_path}"/cli.log ]]
|
||||
rm -rf "${container_tmp_path}"
|
||||
}
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
#!/usr/bin/env bats
|
||||
# Copyright (c) 2017 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Roman Iuvshyn
|
||||
|
||||
source /dockerfiles/cli/tests/test_base.sh
|
||||
|
||||
@test "test cli 'offline' command: with default parameters" {
|
||||
#GIVEN
|
||||
tmp_path="${TESTRUN_DIR}"/cli_cmd_offline_with_default_parameters
|
||||
container_tmp_path="${CONTAINER_TESTRUN_DIR}"/cli_cmd_offline_with_default_parameters
|
||||
mkdir -p "${tmp_path}"
|
||||
|
||||
#WHEN
|
||||
result=$(execute_cli_command --che-data-path=${tmp_path} --che-cli-command=offline --che-cli-extra-options="--skip:nightly --skip:pull")
|
||||
|
||||
#THEN
|
||||
[[ $result == *"Saving che cli image..."* ]]
|
||||
[[ $result == *"Saving che bootstrap images..."* ]]
|
||||
[[ $result == *"Saving che system images..."* ]]
|
||||
[[ $result == *"Saving utility images..."* ]]
|
||||
[[ $result == *"Saving che stack images..."* ]]
|
||||
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/alpine*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/docker_compose*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-action*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-cli*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-dir*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-init*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-ip*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-mount*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-test*.tar) ]]
|
||||
}
|
||||
|
||||
@test "test cli 'offline' command: include custom stack images" {
|
||||
#GIVEN
|
||||
tmp_path="${TESTRUN_DIR}"/cli_cmd_offline_with_custom_stack_images
|
||||
container_tmp_path="${CONTAINER_TESTRUN_DIR}"/cli_cmd_offline_with_custom_stack_images
|
||||
mkdir -p "${tmp_path}"
|
||||
|
||||
#WHEN
|
||||
result=$(execute_cli_command --che-data-path=${tmp_path} --che-cli-command=offline --che-cli-extra-options="--image:eclipse/alpine_jdk8 --image:eclipse/debian_jre --skip:nightly --skip:pull")
|
||||
|
||||
#THEN
|
||||
[[ $result == *"Saving che cli image..."* ]]
|
||||
[[ $result == *"Saving che bootstrap images..."* ]]
|
||||
[[ $result == *"Saving che system images..."* ]]
|
||||
[[ $result == *"Saving utility images..."* ]]
|
||||
[[ $result == *"Saving che stack images..."* ]]
|
||||
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/alpine*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/docker_compose*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-action*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-cli*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-dir*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-init*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-ip*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-mount*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-test*.tar) ]]
|
||||
[[ -f "${container_tmp_path}"/backup/eclipse_alpine_jdk8.tar ]]
|
||||
[[ -f "${container_tmp_path}"/backup/eclipse_debian_jre.tar ]]
|
||||
}
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
#!/usr/bin/env bats
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Marian Labuda - Initial Implementation
|
||||
# Roman Iuvshyn
|
||||
|
||||
source /dockerfiles/cli/tests/test_base.sh
|
||||
|
||||
# Kill running che server instance if there is any to be able to run tests
|
||||
setup() {
|
||||
kill_running_named_container chetest
|
||||
remove_named_container chetest
|
||||
}
|
||||
|
||||
teardown() {
|
||||
kill_running_named_container chetest
|
||||
remove_named_container chetest
|
||||
}
|
||||
|
||||
@test "test cli 'start' command with default settings" {
|
||||
#GIVEN
|
||||
if [ ! port_is_free 8080 ]; then
|
||||
[ "$status" -eq 1 ]
|
||||
[ "$output" = "Default port 8080 for che server is used. Cannot run this test on default che server port" ]
|
||||
fi
|
||||
tmp_path="${TESTRUN_DIR}"/cli_cmd_start_with_default_params
|
||||
mkdir -p "${tmp_path}"
|
||||
|
||||
#WHEN
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-container-name=chetest --che-cli-command=start --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
|
||||
#THEN
|
||||
check_che_state --che-container-name="chetest"
|
||||
}
|
||||
|
||||
@test "test cli 'stop' command with default settings" {
|
||||
#GIVEN
|
||||
if [ ! port_is_free 8080 ]; then
|
||||
[ "$status" -eq 1 ]
|
||||
[ "$output" = "Default port 8080 for che server is used. Cannot run this test on default che server port" ]
|
||||
fi
|
||||
tmp_path="${TESTRUN_DIR}"/cli_cmd_stop_with_default_settings
|
||||
mkdir -p "${tmp_path}"
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-container-name=chetest --che-cli-command=start --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
check_che_state --che-container-name="chetest"
|
||||
#WHEN
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-container-name=chetest --che-cli-command=stop --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
|
||||
#THEN
|
||||
#check that container is stopped and removed
|
||||
[[ "$(docker ps -a)" != *"chetest"* ]]
|
||||
}
|
||||
|
||||
@test "test cli 'restart' command with default settings" {
|
||||
#GIVEN
|
||||
if [ ! port_is_free 8080 ]; then
|
||||
[ "$status" -eq 1 ]
|
||||
[ "$output" = "Default port 8080 for che server is used. Cannot run this test on default che server port" ]
|
||||
fi
|
||||
tmp_path="${TESTRUN_DIR}"/cli_cmd_restart_with_default_settings
|
||||
mkdir -p "${tmp_path}"
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-container-name=chetest --che-cli-command=start --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
check_che_state --che-container-name="chetest"
|
||||
che_container_id=$(docker inspect --format="{{.Id}}" chetest)
|
||||
|
||||
#WHEN
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-container-name=chetest --che-cli-command=restart --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
|
||||
#THEN
|
||||
[[ "$(docker inspect --format="{{.Id}}" chetest)" != "$che_container_id" ]]
|
||||
check_che_state --che-container-name="chetest"
|
||||
}
|
||||
|
||||
@test "test cli 'start' with custom port" {
|
||||
#GIVEN
|
||||
tmp_path=${TESTRUN_DIR}/cli_cmd_start_with_custom_port
|
||||
free_port=$(get_free_port)
|
||||
|
||||
#WHEN
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-port=$free_port --che-container-name=chetest --che-cli-command=start --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
#THEN
|
||||
check_che_state --che-container-name="chetest" --che-port="$free_port"
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
#!/usr/bin/env bats
|
||||
# Copyright (c) 2017 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# David Festal
|
||||
|
||||
|
||||
function log() {
|
||||
echo ""
|
||||
}
|
||||
|
||||
load '/bats-support/load.bash'
|
||||
load '/bats-assert/load.bash'
|
||||
source /dockerfiles/cli/tests/test_base.sh
|
||||
source /dockerfiles/base/scripts/base/startup_03_pre_networking.sh
|
||||
|
||||
@test "test overriding the CLI images" {
|
||||
#GIVEN
|
||||
IMAGES="IMAGE_INIT=eclipse/che-init:nightly"
|
||||
IMAGE_INIT="dfestal/che-init:nightly"
|
||||
|
||||
#WHEN
|
||||
set_variables_images_list "${IMAGES}"
|
||||
|
||||
#THEN
|
||||
[[ "${IMAGE_INIT}" == ""dfestal/che-init:nightly"" ]]
|
||||
}
|
||||
|
||||
@test "test not overriding the CLI images" {
|
||||
#GIVEN
|
||||
IMAGES="IMAGE_INIT=eclipse/che-init:nightly"
|
||||
|
||||
#WHEN
|
||||
set_variables_images_list "${IMAGES}"
|
||||
|
||||
#THEN
|
||||
[[ "${IMAGE_INIT}" == ""eclipse/che-init:nightly"" ]]
|
||||
}
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
#!/usr/bin/env bats
|
||||
# Copyright (c) 2017 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Florent Benoit - Initial Implementation
|
||||
#
|
||||
|
||||
|
||||
function log() {
|
||||
echo ""
|
||||
}
|
||||
|
||||
load '/bats-support/load.bash'
|
||||
load '/bats-assert/load.bash'
|
||||
source /dockerfiles/cli/tests/test_base.sh
|
||||
source /dockerfiles/base/scripts/base/startup_03_pre_networking.sh
|
||||
|
||||
|
||||
@test "Check isDocker4Mac is true" {
|
||||
# GIVEN
|
||||
UNAME_R="4.9.4-moby"
|
||||
|
||||
# WHEN
|
||||
run is_docker_for_mac
|
||||
|
||||
# THEN
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "Check isDocker4Mac is true (new docker releases)" {
|
||||
# GIVEN
|
||||
UNAME_R="4.9.44-linuxkit-aufs"
|
||||
|
||||
# WHEN
|
||||
run is_docker_for_mac
|
||||
|
||||
# THEN
|
||||
assert_success
|
||||
}
|
||||
|
||||
|
||||
@test "Check isDocker4Mac is false on Linux kernel" {
|
||||
# GIVEN
|
||||
UNAME_R="4.4.0-21-generic"
|
||||
|
||||
# WHEN
|
||||
run is_docker_for_mac
|
||||
|
||||
# THEN
|
||||
assert_failure
|
||||
}
|
||||
|
||||
|
||||
@test "Check isDocker4Win is false on Linux kernel" {
|
||||
# GIVEN
|
||||
UNAME_R="4.4.0-21-generic"
|
||||
|
||||
# WHEN
|
||||
run is_docker_for_windows
|
||||
|
||||
# THEN
|
||||
assert_failure
|
||||
}
|
||||
|
||||
|
||||
@test "Check isDocker4Win is true" {
|
||||
# GIVEN
|
||||
UNAME_R="4.9.4-moby"
|
||||
GLOBAL_HOST_IP="10.0.75.2"
|
||||
|
||||
# WHEN
|
||||
run is_docker_for_windows
|
||||
|
||||
# THEN
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "Check isDocker4Win is true (new docker releases)" {
|
||||
# GIVEN
|
||||
UNAME_R="4.9.44-linuxkit-aufs"
|
||||
GLOBAL_HOST_IP="10.0.75.2"
|
||||
|
||||
# WHEN
|
||||
run is_docker_for_windows
|
||||
|
||||
# THEN
|
||||
assert_success
|
||||
}
|
||||
|
|
@ -1,157 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012-2019 Red Hat, Inc.
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Marian Labuda - Initial Implementation
|
||||
|
||||
#export CLI_IMAGE=$IMAGE_NAME
|
||||
source /dockerfiles/base/scripts/base/*.sh
|
||||
export SCRIPTS_DIR="${BATS_BASE_DIR}"/base/scripts/base
|
||||
export TESTS_DIR="${BATS_BASE_DIR}"/cli/tests
|
||||
export TESTRUN_DIR="${TESTS_DIR}"/testrun
|
||||
export CONTAINER_TESTRUN_DIR=/dockerfiles/cli/tests/testrun
|
||||
|
||||
if [ -d "${CONTAINER_TESTRUN_DIR}" ]; then
|
||||
rm -rf "${CONTAINER_TESTRUN_DIR}"
|
||||
fi
|
||||
mkdir "${TESTRUN_DIR}" -p
|
||||
|
||||
kill_running_named_container() {
|
||||
if [[ $(docker ps --format '{{.Names}}' | grep $1 | wc -l) -eq 1 ]]; then
|
||||
echo "Stopping named container $1"
|
||||
docker kill $1 1>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
remove_named_container() {
|
||||
if [[ $(docker ps -a --format '{{.Names}}' | grep $1 | wc -l) -eq 1 ]]; then
|
||||
echo "Removing named container $1"
|
||||
docker rm $1 1>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
# Pass a port as an argument to check whether is free or not
|
||||
# Returns 0 if port is free (not listening), 1 otherwise
|
||||
port_is_free() {
|
||||
if [[ $(netstat -lnt | awk -v port=$1 '$6 == "LISTEN" && $4 ~ "."port' | wc -l) -gt 0 ]]; then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
# Get first free port from range of dynamic/private ports
|
||||
get_free_port() {
|
||||
local port=49200
|
||||
while [[ $(port_is_free $port) -eq 1 ]]; do
|
||||
if [[ $port -eq 65535 ]]; then
|
||||
echo ""
|
||||
return 1
|
||||
fi
|
||||
port=$((port+1))
|
||||
done
|
||||
echo $port
|
||||
}
|
||||
|
||||
check_che_state() {
|
||||
local CHE_CONTAINER_NAME="che"
|
||||
local CHE_PORT="8080"
|
||||
local IS_RUNNING="true"
|
||||
for i in "${@}"
|
||||
do
|
||||
case $i in
|
||||
--che-container-name=*)
|
||||
CHE_CONTAINER_NAME="${i#*=}"
|
||||
shift
|
||||
;;
|
||||
--che-port=*)
|
||||
CHE_PORT="${i#*=}"
|
||||
shift
|
||||
;;
|
||||
--is-running=*)
|
||||
IS_RUNNING="${i#*=}"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo "You've passed unknown option"
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
[[ "$(docker inspect --format='{{.State.Running}}' $CHE_CONTAINER_NAME)" == "$IS_RUNNING" ]]
|
||||
ip_address=$(docker inspect -f {{.NetworkSettings.Networks.bridge.IPAddress}} $CHE_CONTAINER_NAME)
|
||||
curl -fsS http://${ip_address}:$CHE_PORT > /dev/null
|
||||
}
|
||||
|
||||
execute_cli_command() {
|
||||
local CHE_CONTAINER_NAME="che"
|
||||
local CHE_DATA_PATH=""
|
||||
local CHE_CLI_COMMAND=""
|
||||
local CHE_CLI_EXTRA_OPTIONS=""
|
||||
local CHE_PORT="8080"
|
||||
local DATA_VOLUME=""
|
||||
local USE_DOCKER_SOCK="true"
|
||||
local MOUNT_SCRIPTS="true"
|
||||
|
||||
for i in "${@}"
|
||||
do
|
||||
case $i in
|
||||
--che-container-name=*)
|
||||
CHE_CONTAINER_NAME="${i#*=}"
|
||||
shift
|
||||
;;
|
||||
--che-port=*)
|
||||
CHE_PORT="${i#*=}"
|
||||
shift
|
||||
;;
|
||||
--che-data-path=*)
|
||||
CHE_DATA_PATH="${i#*=}"
|
||||
shift
|
||||
;;
|
||||
--che-cli-command=*)
|
||||
CHE_CLI_COMMAND="${i#*=}"
|
||||
shift
|
||||
;;
|
||||
--che-cli-extra-options=*)
|
||||
CHE_CLI_EXTRA_OPTIONS="${i#*=}"
|
||||
shift
|
||||
;;
|
||||
--che-cli-use-docker-sock=*)
|
||||
USE_DOCKER_SOCK="${i#*=}"
|
||||
shift
|
||||
;;
|
||||
--che-cli-mount-scripts=*)
|
||||
MOUNT_SCRIPTS="${i#*=}"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo "You've passed unknown option"
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ ! -z $CHE_DATA_PATH ]; then
|
||||
DATA_VOLUME="-v ${CHE_DATA_PATH}:/data"
|
||||
fi
|
||||
if [ $USE_DOCKER_SOCK == "true" ]; then
|
||||
DOCKER_SOCK_VOLUME="-v /var/run/docker.sock:/var/run/docker.sock"
|
||||
fi
|
||||
if [ $MOUNT_SCRIPTS == "true" ]; then
|
||||
SCRIPTS_VOLUME="-v ${SCRIPTS_DIR}:/scripts/base"
|
||||
fi
|
||||
if [ $CHE_PORT -ne 8080 ]; then
|
||||
CLI_CUSTOM_PORT="-e CHE_PORT=${CHE_PORT}"
|
||||
fi
|
||||
if [ $CHE_CONTAINER_NAME != "che" ]; then
|
||||
CLI_CUSTOM_CHE_CONTAINER_NAME="-e CHE_CONTAINER=${CHE_CONTAINER_NAME}"
|
||||
fi
|
||||
|
||||
docker run --rm ${CLI_CUSTOM_PORT} ${SCRIPTS_VOLUME} ${DOCKER_SOCK_VOLUME} ${DATA_VOLUME} ${CLI_CUSTOM_CHE_CONTAINER_NAME} $CLI_IMAGE ${CHE_CLI_COMMAND} ${CHE_CLI_EXTRA_OPTIONS}
|
||||
}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
IMAGE_PUPPET=puppet/puppet-agent-alpine:4.6.2
|
||||
IMAGE_REGISTRY=registry:2.5.0
|
||||
IMAGE_INIT=eclipse/che-init:nightly
|
||||
IMAGE_CHE=eclipse/che-server:4.7.2
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
eclipse/alpine_jdk8
|
||||
eclipse/aspnet
|
||||
eclipse/centos_jdk8
|
||||
eclipse/cpp_gcc
|
||||
eclipse/debian_jdk8
|
||||
eclipse/debian_jdk8_node
|
||||
eclipse/debian_jre
|
||||
eclipse/dotnet_core
|
||||
eclipse/hadoop-dev
|
||||
eclipse/meteor
|
||||
eclipse/node
|
||||
eclipse/php
|
||||
eclipse/platformio
|
||||
eclipse/ruby_rails
|
||||
eclipse/selenium
|
||||
eclipse/ubuntu_android
|
||||
eclipse/ubuntu_go
|
||||
eclipse/ubuntu_gradle
|
||||
eclipse/ubuntu_jdk8
|
||||
eclipse/ubuntu_jre
|
||||
eclipse/ubuntu_python
|
||||
eclipse/ubuntu_wildfly8
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
IMAGE_PUPPET=puppet/puppet-agent-alpine:4.6.2
|
||||
IMAGE_REGISTRY=registry:2.5.0
|
||||
IMAGE_INIT=eclipse/che-init:nightly
|
||||
IMAGE_CHE=eclipse/che-server:5.0.0-M5
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
eclipse/alpine_jdk8
|
||||
eclipse/aspnet
|
||||
eclipse/centos_jdk8
|
||||
eclipse/cpp_gcc
|
||||
eclipse/debian_jdk8
|
||||
eclipse/debian_jdk8_node
|
||||
eclipse/debian_jre
|
||||
eclipse/dotnet_core
|
||||
eclipse/hadoop-dev
|
||||
eclipse/meteor
|
||||
eclipse/node
|
||||
eclipse/php
|
||||
eclipse/platformio
|
||||
eclipse/ruby_rails
|
||||
eclipse/selenium
|
||||
eclipse/ubuntu_android
|
||||
eclipse/ubuntu_go
|
||||
eclipse/ubuntu_gradle
|
||||
eclipse/ubuntu_jdk8
|
||||
eclipse/ubuntu_jre
|
||||
eclipse/ubuntu_python
|
||||
eclipse/ubuntu_wildfly8
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
IMAGE_PUPPET=puppet/puppet-agent-alpine:4.6.2
|
||||
IMAGE_REGISTRY=registry:2.5.0
|
||||
IMAGE_INIT=eclipse/che-init:nightly
|
||||
IMAGE_CHE=eclipse/che-server:5.0.0-M6
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
eclipse/alpine_jdk8
|
||||
eclipse/aspnet
|
||||
eclipse/centos_jdk8
|
||||
eclipse/cpp_gcc
|
||||
eclipse/debian_jdk8
|
||||
eclipse/debian_jdk8_node
|
||||
eclipse/debian_jre
|
||||
eclipse/dotnet_core
|
||||
eclipse/hadoop-dev
|
||||
eclipse/meteor
|
||||
eclipse/node
|
||||
eclipse/php
|
||||
eclipse/platformio
|
||||
eclipse/ruby_rails
|
||||
eclipse/selenium
|
||||
eclipse/ubuntu_android
|
||||
eclipse/ubuntu_go
|
||||
eclipse/ubuntu_gradle
|
||||
eclipse/ubuntu_jdk8
|
||||
eclipse/ubuntu_jre
|
||||
eclipse/ubuntu_python
|
||||
eclipse/ubuntu_wildfly8
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
IMAGE_PUPPET=puppet/puppet-agent-alpine:4.6.2
|
||||
IMAGE_REGISTRY=registry:2.5.0
|
||||
IMAGE_INIT=eclipse/che-init:nightly
|
||||
IMAGE_CHE=eclipse/che-server:5.0.0-M7
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
eclipse/alpine_jdk8
|
||||
eclipse/aspnet
|
||||
eclipse/centos_jdk8
|
||||
eclipse/cpp_gcc
|
||||
eclipse/debian_jdk8
|
||||
eclipse/debian_jdk8_node
|
||||
eclipse/debian_jre
|
||||
eclipse/dotnet_core
|
||||
eclipse/hadoop-dev
|
||||
eclipse/meteor
|
||||
eclipse/node
|
||||
eclipse/php
|
||||
eclipse/platformio
|
||||
eclipse/ruby_rails
|
||||
eclipse/selenium
|
||||
eclipse/ubuntu_android
|
||||
eclipse/ubuntu_go
|
||||
eclipse/ubuntu_gradle
|
||||
eclipse/ubuntu_jdk8
|
||||
eclipse/ubuntu_jre
|
||||
eclipse/ubuntu_python
|
||||
eclipse/ubuntu_wildfly8
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
IMAGE_PUPPET=puppet/puppet-agent-alpine:4.6.2
|
||||
IMAGE_REGISTRY=registry:2.5.0
|
||||
IMAGE_INIT=eclipse/che-init:5.0.0-M8
|
||||
IMAGE_CHE=eclipse/che-server:5.0.0-M8
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
eclipse/alpine_jdk8
|
||||
eclipse/aspnet
|
||||
eclipse/centos_jdk8
|
||||
eclipse/cpp_gcc
|
||||
eclipse/debian_jdk8
|
||||
eclipse/debian_jdk8_node
|
||||
eclipse/debian_jre
|
||||
eclipse/dotnet_core
|
||||
eclipse/hadoop-dev
|
||||
eclipse/meteor
|
||||
eclipse/node
|
||||
eclipse/php
|
||||
eclipse/platformio
|
||||
eclipse/ruby_rails
|
||||
eclipse/selenium
|
||||
eclipse/ubuntu_android
|
||||
eclipse/ubuntu_go
|
||||
eclipse/ubuntu_gradle
|
||||
eclipse/ubuntu_jdk8
|
||||
eclipse/ubuntu_jre
|
||||
eclipse/ubuntu_python
|
||||
eclipse/ubuntu_wildfly8
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
IMAGE_PUPPET=puppet/puppet-agent-alpine:4.6.2
|
||||
IMAGE_REGISTRY=registry:2.5.0
|
||||
IMAGE_INIT=eclipse/che-init:5.0.0
|
||||
IMAGE_CHE=eclipse/che-server:5.0.0
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
eclipse/alpine_jdk8
|
||||
eclipse/aspnet
|
||||
eclipse/centos_jdk8
|
||||
eclipse/cpp_gcc
|
||||
eclipse/debian_jdk8
|
||||
eclipse/debian_jdk8_node
|
||||
eclipse/debian_jre
|
||||
eclipse/dotnet_core
|
||||
eclipse/hadoop-dev
|
||||
eclipse/meteor
|
||||
eclipse/node
|
||||
eclipse/php
|
||||
eclipse/platformio
|
||||
eclipse/ruby_rails
|
||||
eclipse/selenium
|
||||
eclipse/ubuntu_android
|
||||
eclipse/ubuntu_go
|
||||
eclipse/ubuntu_gradle
|
||||
eclipse/ubuntu_jdk8
|
||||
eclipse/ubuntu_jre
|
||||
eclipse/ubuntu_python
|
||||
eclipse/ubuntu_wildfly8
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
IMAGE_PUPPET=puppet/puppet-agent-alpine:4.6.2
|
||||
IMAGE_REGISTRY=registry:2.5.0
|
||||
IMAGE_INIT=eclipse/che-init:5.0.1
|
||||
IMAGE_CHE=eclipse/che-server:5.0.1
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
eclipse/alpine_jdk8
|
||||
eclipse/aspnet
|
||||
eclipse/centos_jdk8
|
||||
eclipse/cpp_gcc
|
||||
eclipse/debian_jdk8
|
||||
eclipse/debian_jdk8_node
|
||||
eclipse/debian_jre
|
||||
eclipse/dotnet_core
|
||||
eclipse/hadoop-dev
|
||||
eclipse/meteor
|
||||
eclipse/node
|
||||
eclipse/php
|
||||
eclipse/platformio
|
||||
eclipse/ruby_rails
|
||||
eclipse/selenium
|
||||
eclipse/ubuntu_android
|
||||
eclipse/ubuntu_go
|
||||
eclipse/ubuntu_gradle
|
||||
eclipse/ubuntu_jdk8
|
||||
eclipse/ubuntu_jre
|
||||
eclipse/ubuntu_python
|
||||
eclipse/ubuntu_wildfly8
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
IMAGE_PUPPET=puppet/puppet-agent-alpine:4.6.2
|
||||
IMAGE_REGISTRY=registry:2.5.0
|
||||
IMAGE_INIT=eclipse/che-init:5.1.0
|
||||
IMAGE_CHE=eclipse/che-server:5.1.0
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
eclipse/alpine_jdk8
|
||||
eclipse/aspnet
|
||||
eclipse/centos_jdk8
|
||||
eclipse/cpp_gcc
|
||||
eclipse/debian_jdk8
|
||||
eclipse/debian_jdk8_node
|
||||
eclipse/debian_jre
|
||||
eclipse/dotnet_core
|
||||
eclipse/hadoop-dev
|
||||
eclipse/meteor
|
||||
eclipse/node
|
||||
eclipse/php
|
||||
eclipse/platformio
|
||||
eclipse/ruby_rails
|
||||
eclipse/selenium
|
||||
eclipse/ubuntu_android
|
||||
eclipse/ubuntu_go
|
||||
eclipse/ubuntu_gradle
|
||||
eclipse/ubuntu_jdk8
|
||||
eclipse/ubuntu_jre
|
||||
eclipse/ubuntu_python
|
||||
eclipse/ubuntu_wildfly8
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
IMAGE_PUPPET=puppet/puppet-agent-alpine:4.6.2
|
||||
IMAGE_REGISTRY=registry:2.5.0
|
||||
IMAGE_INIT=eclipse/che-init:5.1.1
|
||||
IMAGE_CHE=eclipse/che-server:5.1.1
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
eclipse/alpine_jdk8
|
||||
eclipse/aspnet
|
||||
eclipse/centos_jdk8
|
||||
eclipse/cpp_gcc
|
||||
eclipse/debian_jdk8
|
||||
eclipse/debian_jdk8_node
|
||||
eclipse/debian_jre
|
||||
eclipse/dotnet_core
|
||||
eclipse/hadoop-dev
|
||||
eclipse/meteor
|
||||
eclipse/node
|
||||
eclipse/php
|
||||
eclipse/platformio
|
||||
eclipse/ruby_rails
|
||||
eclipse/selenium
|
||||
eclipse/ubuntu_android
|
||||
eclipse/ubuntu_go
|
||||
eclipse/ubuntu_gradle
|
||||
eclipse/ubuntu_jdk8
|
||||
eclipse/ubuntu_jre
|
||||
eclipse/ubuntu_python
|
||||
eclipse/ubuntu_wildfly8
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
IMAGE_INIT=eclipse/che-init:5.10.0
|
||||
IMAGE_CHE=eclipse/che-server:5.10.0
|
||||
IMAGE_COMPOSE=docker/compose:1.8.1
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
eclipse/alpine_jdk8
|
||||
eclipse/aspnet
|
||||
eclipse/centos_jdk8
|
||||
eclipse/cpp_gcc
|
||||
eclipse/debian_jdk8
|
||||
eclipse/debian_jdk8_node
|
||||
eclipse/debian_jre
|
||||
eclipse/dotnet_core
|
||||
eclipse/hadoop-dev
|
||||
eclipse/meteor
|
||||
eclipse/node
|
||||
eclipse/php
|
||||
eclipse/platformio
|
||||
eclipse/ruby_rails
|
||||
eclipse/selenium
|
||||
eclipse/ubuntu_android
|
||||
eclipse/ubuntu_go
|
||||
eclipse/ubuntu_gradle
|
||||
eclipse/ubuntu_jdk8
|
||||
eclipse/ubuntu_jre
|
||||
eclipse/ubuntu_python
|
||||
eclipse/ubuntu_wildfly8
|
||||
registry.centos.org/che-stacks/vertx
|
||||
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
IMAGE_INIT=eclipse/che-init:5.11.0
|
||||
IMAGE_CHE=eclipse/che-server:5.11.0
|
||||
IMAGE_COMPOSE=docker/compose:1.8.1
|
||||
IMAGE_TRAEFIK=traefik:v1.3.0-rc1
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
eclipse/alpine_jdk8
|
||||
eclipse/aspnet
|
||||
eclipse/centos_jdk8
|
||||
eclipse/cpp_gcc
|
||||
eclipse/debian_jdk8
|
||||
eclipse/debian_jdk8_node
|
||||
eclipse/debian_jre
|
||||
eclipse/dotnet_core
|
||||
eclipse/hadoop-dev
|
||||
eclipse/meteor
|
||||
eclipse/node
|
||||
eclipse/php
|
||||
eclipse/platformio
|
||||
eclipse/ruby_rails
|
||||
eclipse/selenium
|
||||
eclipse/ubuntu_android
|
||||
eclipse/ubuntu_go
|
||||
eclipse/ubuntu_gradle
|
||||
eclipse/ubuntu_jdk8
|
||||
eclipse/ubuntu_jre
|
||||
eclipse/ubuntu_python
|
||||
eclipse/ubuntu_wildfly8
|
||||
registry.centos.org/che-stacks/vertx
|
||||
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
IMAGE_INIT=eclipse/che-init:5.11.1
|
||||
IMAGE_CHE=eclipse/che-server:5.11.1
|
||||
IMAGE_COMPOSE=docker/compose:1.8.1
|
||||
IMAGE_TRAEFIK=traefik:v1.3.0-rc1
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
eclipse/alpine_jdk8
|
||||
eclipse/aspnet
|
||||
eclipse/centos_jdk8
|
||||
eclipse/cpp_gcc
|
||||
eclipse/debian_jdk8
|
||||
eclipse/debian_jdk8_node
|
||||
eclipse/debian_jre
|
||||
eclipse/dotnet_core
|
||||
eclipse/hadoop-dev
|
||||
eclipse/meteor
|
||||
eclipse/node
|
||||
eclipse/php
|
||||
eclipse/platformio
|
||||
eclipse/ruby_rails
|
||||
eclipse/selenium
|
||||
eclipse/ubuntu_android
|
||||
eclipse/ubuntu_go
|
||||
eclipse/ubuntu_gradle
|
||||
eclipse/ubuntu_jdk8
|
||||
eclipse/ubuntu_jre
|
||||
eclipse/ubuntu_python
|
||||
eclipse/ubuntu_wildfly8
|
||||
registry.centos.org/che-stacks/vertx
|
||||
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
IMAGE_INIT=eclipse/che-init:5.11.2
|
||||
IMAGE_CHE=eclipse/che-server:5.11.2
|
||||
IMAGE_COMPOSE=docker/compose:1.8.1
|
||||
IMAGE_TRAEFIK=traefik:v1.3.0-rc1
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
eclipse/alpine_jdk8
|
||||
eclipse/aspnet
|
||||
eclipse/centos_jdk8
|
||||
eclipse/cpp_gcc
|
||||
eclipse/debian_jdk8
|
||||
eclipse/debian_jdk8_node
|
||||
eclipse/debian_jre
|
||||
eclipse/dotnet_core
|
||||
eclipse/hadoop-dev
|
||||
eclipse/meteor
|
||||
eclipse/node
|
||||
eclipse/php
|
||||
eclipse/platformio
|
||||
eclipse/ruby_rails
|
||||
eclipse/selenium
|
||||
eclipse/ubuntu_android
|
||||
eclipse/ubuntu_go
|
||||
eclipse/ubuntu_gradle
|
||||
eclipse/ubuntu_jdk8
|
||||
eclipse/ubuntu_jre
|
||||
eclipse/ubuntu_python
|
||||
eclipse/ubuntu_wildfly8
|
||||
registry.centos.org/che-stacks/vertx
|
||||
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
IMAGE_INIT=eclipse/che-init:5.12.0
|
||||
IMAGE_CHE=eclipse/che-server:5.12.0
|
||||
IMAGE_COMPOSE=docker/compose:1.8.1
|
||||
IMAGE_TRAEFIK=traefik:v1.3.0-rc3
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
eclipse/alpine_jdk8
|
||||
eclipse/aspnet
|
||||
eclipse/centos_jdk8
|
||||
eclipse/cpp_gcc
|
||||
eclipse/debian_jdk8
|
||||
eclipse/debian_jdk8_node
|
||||
eclipse/debian_jre
|
||||
eclipse/dotnet_core
|
||||
eclipse/hadoop-dev
|
||||
eclipse/meteor
|
||||
eclipse/node
|
||||
eclipse/php
|
||||
eclipse/platformio
|
||||
eclipse/ruby_rails
|
||||
eclipse/selenium
|
||||
eclipse/ubuntu_android
|
||||
eclipse/ubuntu_go
|
||||
eclipse/ubuntu_gradle
|
||||
eclipse/ubuntu_jdk8
|
||||
eclipse/ubuntu_jre
|
||||
eclipse/ubuntu_python
|
||||
eclipse/ubuntu_wildfly8
|
||||
registry.centos.org/che-stacks/vertx
|
||||
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
IMAGE_INIT=eclipse/che-init:5.13.0
|
||||
IMAGE_CHE=eclipse/che-server:5.13.0
|
||||
IMAGE_COMPOSE=docker/compose:1.8.1
|
||||
IMAGE_TRAEFIK=traefik:v1.3.0-rc3
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
eclipse/alpine_jdk8
|
||||
eclipse/aspnet
|
||||
eclipse/centos_jdk8
|
||||
eclipse/cpp_gcc
|
||||
eclipse/debian_jdk8
|
||||
eclipse/debian_jdk8_node
|
||||
eclipse/debian_jre
|
||||
eclipse/dotnet_core
|
||||
eclipse/hadoop-dev
|
||||
eclipse/meteor
|
||||
eclipse/node
|
||||
eclipse/php
|
||||
eclipse/platformio
|
||||
eclipse/ruby_rails
|
||||
eclipse/selenium
|
||||
eclipse/ubuntu_android
|
||||
eclipse/ubuntu_go
|
||||
eclipse/ubuntu_gradle
|
||||
eclipse/ubuntu_jdk8
|
||||
eclipse/ubuntu_jre
|
||||
eclipse/ubuntu_python
|
||||
eclipse/ubuntu_wildfly8
|
||||
registry.centos.org/che-stacks/vertx
|
||||
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
IMAGE_INIT=eclipse/che-init:5.14.0
|
||||
IMAGE_CHE=eclipse/che-server:5.14.0
|
||||
IMAGE_COMPOSE=docker/compose:1.8.1
|
||||
IMAGE_TRAEFIK=traefik:v1.3.0-rc3
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
eclipse/alpine_jdk8
|
||||
eclipse/aspnet
|
||||
eclipse/centos_jdk8
|
||||
eclipse/cpp_gcc
|
||||
eclipse/debian_jdk8
|
||||
eclipse/debian_jdk8_node
|
||||
eclipse/debian_jre
|
||||
eclipse/dotnet_core
|
||||
eclipse/hadoop-dev
|
||||
eclipse/meteor
|
||||
eclipse/node
|
||||
eclipse/php
|
||||
eclipse/platformio
|
||||
eclipse/ruby_rails
|
||||
eclipse/selenium
|
||||
eclipse/ubuntu_android
|
||||
eclipse/ubuntu_go
|
||||
eclipse/ubuntu_gradle
|
||||
eclipse/ubuntu_jdk8
|
||||
eclipse/ubuntu_jre
|
||||
eclipse/ubuntu_python
|
||||
eclipse/ubuntu_wildfly8
|
||||
registry.centos.org/che-stacks/vertx
|
||||
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
IMAGE_INIT=eclipse/che-init:5.15.0
|
||||
IMAGE_CHE=eclipse/che-server:5.15.0
|
||||
IMAGE_COMPOSE=docker/compose:1.8.1
|
||||
IMAGE_TRAEFIK=traefik:v1.3.0-rc3
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
eclipse/alpine_jdk8
|
||||
eclipse/aspnet
|
||||
eclipse/centos_jdk8
|
||||
eclipse/cpp_gcc
|
||||
eclipse/debian_jdk8
|
||||
eclipse/debian_jdk8_node
|
||||
eclipse/debian_jre
|
||||
eclipse/dotnet_core
|
||||
eclipse/hadoop-dev
|
||||
eclipse/meteor
|
||||
eclipse/node
|
||||
eclipse/php
|
||||
eclipse/platformio
|
||||
eclipse/ruby_rails
|
||||
eclipse/selenium
|
||||
eclipse/ubuntu_android
|
||||
eclipse/ubuntu_go
|
||||
eclipse/ubuntu_gradle
|
||||
eclipse/ubuntu_jdk8
|
||||
eclipse/ubuntu_jre
|
||||
eclipse/ubuntu_python
|
||||
eclipse/ubuntu_wildfly8
|
||||
registry.centos.org/che-stacks/vertx
|
||||
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
IMAGE_INIT=eclipse/che-init:5.16.0
|
||||
IMAGE_CHE=eclipse/che-server:5.16.0
|
||||
IMAGE_COMPOSE=docker/compose:1.8.1
|
||||
IMAGE_TRAEFIK=traefik:v1.3.0-rc3
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
eclipse/alpine_jdk8
|
||||
eclipse/aspnet
|
||||
eclipse/centos_jdk8
|
||||
eclipse/cpp_gcc
|
||||
eclipse/debian_jdk8
|
||||
eclipse/debian_jdk8_node
|
||||
eclipse/debian_jre
|
||||
eclipse/dotnet_core
|
||||
eclipse/hadoop-dev
|
||||
eclipse/meteor
|
||||
eclipse/node
|
||||
eclipse/php
|
||||
eclipse/platformio
|
||||
eclipse/ruby_rails
|
||||
eclipse/selenium
|
||||
eclipse/ubuntu_android
|
||||
eclipse/ubuntu_go
|
||||
eclipse/ubuntu_gradle
|
||||
eclipse/ubuntu_jdk8
|
||||
eclipse/ubuntu_jre
|
||||
eclipse/ubuntu_python
|
||||
eclipse/ubuntu_wildfly8
|
||||
registry.centos.org/che-stacks/vertx
|
||||
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
IMAGE_INIT=eclipse/che-init:5.17.0
|
||||
IMAGE_CHE=eclipse/che-server:5.17.0
|
||||
IMAGE_COMPOSE=docker/compose:1.8.1
|
||||
IMAGE_TRAEFIK=traefik:v1.3.0-rc3
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
eclipse/alpine_jdk8
|
||||
eclipse/aspnet
|
||||
eclipse/centos_jdk8
|
||||
eclipse/cpp_gcc
|
||||
eclipse/debian_jdk8
|
||||
eclipse/debian_jdk8_node
|
||||
eclipse/debian_jre
|
||||
eclipse/dotnet_core
|
||||
eclipse/hadoop-dev
|
||||
eclipse/meteor
|
||||
eclipse/node
|
||||
eclipse/php
|
||||
eclipse/platformio
|
||||
eclipse/ruby_rails
|
||||
eclipse/selenium
|
||||
eclipse/ubuntu_android
|
||||
eclipse/ubuntu_go
|
||||
eclipse/ubuntu_gradle
|
||||
eclipse/ubuntu_jdk8
|
||||
eclipse/ubuntu_jre
|
||||
eclipse/ubuntu_python
|
||||
eclipse/ubuntu_wildfly8
|
||||
registry.centos.org/che-stacks/vertx
|
||||
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
IMAGE_INIT=eclipse/che-init:5.18.0
|
||||
IMAGE_CHE=eclipse/che-server:5.18.0
|
||||
IMAGE_COMPOSE=docker/compose:1.8.1
|
||||
IMAGE_TRAEFIK=traefik:v1.3.0-rc3
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
eclipse/alpine_jdk8
|
||||
eclipse/aspnet
|
||||
eclipse/centos_jdk8
|
||||
eclipse/cpp_gcc
|
||||
eclipse/debian_jdk8
|
||||
eclipse/debian_jdk8_node
|
||||
eclipse/debian_jre
|
||||
eclipse/dotnet_core
|
||||
eclipse/hadoop-dev
|
||||
eclipse/meteor
|
||||
eclipse/node
|
||||
eclipse/php
|
||||
eclipse/platformio
|
||||
eclipse/ruby_rails
|
||||
eclipse/selenium
|
||||
eclipse/ubuntu_android
|
||||
eclipse/ubuntu_go
|
||||
eclipse/ubuntu_gradle
|
||||
eclipse/ubuntu_jdk8
|
||||
eclipse/ubuntu_jre
|
||||
eclipse/ubuntu_python
|
||||
eclipse/ubuntu_wildfly8
|
||||
registry.centos.org/che-stacks/vertx
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue