diff --git a/.gitignore b/.gitignore index d48899072c0..ebad3a75fe5 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,8 @@ target/ bin/ test-output/ maven-eclipse.xml +instance/ +config/ # Idea # ################## diff --git a/Chefile b/Chefile index 05fab76e58e..e5a67de8602 100644 --- a/Chefile +++ b/Chefile @@ -6,7 +6,7 @@ workspace.commands[0].name="1. Build Che in Che" workspace.commands[0].commandLine="mvn clean install -f /projects/che/assembly/assembly-main" workspace.commands[1].name="2. Run Che in Che" -workspace.commands[1].commandLine='export CHE_VERSION="nightly" && export CHE_BIN_PATH=$(ls -d /projects/che/assembly/assembly-main/target/eclipse-che-*/eclipse-che-*); sudo docker run --rm -t -v /var/run/docker.sock:/var/run/docker.sock --env CHE_LOCAL_BINARY=${CHE_BIN_PATH/\'/projects/che\'/$(sudo docker inspect --format \'{{ range .Mounts }}{{ if eq .Destination "/projects/che" }}{{ .Source }}{{ end }}{{ end }}\' $(hostname))} --env CHE_PORT=54321 --env CHE_SERVER_CONTAINER_NAME="che-in-che-server" codenvy/che-launcher:nightly start' +workspace.commands[1].commandLine='export CHE_VERSION="nightly" && export CHE_BIN_PATH=$(ls -d /projects/che/assembly/assembly-main/target/eclipse-che-*/eclipse-che-*); sudo docker run --rm -t -v /var/run/docker.sock:/var/run/docker.sock --env CHE_ASSEMBY=${CHE_BIN_PATH/\'/projects/che\'/$(sudo docker inspect --format \'{{ range .Mounts }}{{ if eq .Destination "/projects/che" }}{{ .Source }}{{ end }}{{ end }}\' $(hostname))} --env CHE_PORT=54321 --env CHE_SERVER_CONTAINER_NAME="che-in-che-server" codenvy/che-launcher:nightly start' workspace.commands[1].attributes={ "previewUrl": "http://localhost:54321" } diff --git a/assembly/assembly-main/src/assembly/bin/che.sh b/assembly/assembly-main/src/assembly/bin/che.sh index cc10d77c1ca..c48cdc885f9 100644 --- a/assembly/assembly-main/src/assembly/bin/che.sh +++ b/assembly/assembly-main/src/assembly/bin/che.sh @@ -271,7 +271,6 @@ start_che_server () { stop_che_server () { echo -e "Stopping Che server running on localhost:${CHE_PORT}" call_catalina >/dev/null 2>&1 - return 1; } call_catalina () { diff --git a/assembly/assembly-main/src/assembly/bin/docker.sh b/assembly/assembly-main/src/assembly/bin/docker.sh index 431687bef4e..f50492b5dc3 100644 --- a/assembly/assembly-main/src/assembly/bin/docker.sh +++ b/assembly/assembly-main/src/assembly/bin/docker.sh @@ -17,12 +17,13 @@ pid=0 check_docker() { if [ ! -S /var/run/docker.sock ]; then echo "Docker socket (/var/run/docker.sock) hasn't been mounted. Verify your \"docker run\" syntax." - return 1; + return 2; fi if ! docker ps > /dev/null 2>&1; then output=$(docker ps) - error_exit "Error when running \"docker ps\": ${output}" + echo "Error when running \"docker ps\": ${output}" + return 2; fi } @@ -51,9 +52,17 @@ init() { export CHE_IN_CONTAINER="true" export CHE_SKIP_JAVA_VERSION_CHECK="true" + if [ -f "/assembly/bin/che.sh" ]; then + echo "Found custom assembly..." + export CHE_HOME="/assembly" + else + echo "Using embedded assembly..." + export CHE_HOME="/home/user/che" + fi + ### Are we using the included assembly or did user provide their own? - DEFAULT_CHE_HOME="/home/user/che" - export CHE_HOME=${CHE_ASSEMBLY:-${DEFAULT_CHE_HOME}} +# DEFAULT_CHE_HOME="/assembly" +# export CHE_HOME=${CHE_ASSEMBLY:-${DEFAULT_CHE_HOME}} if [ ! -f $CHE_HOME/bin/che.sh ]; then echo "!!!" @@ -64,27 +73,36 @@ init() { fi ### We need to discover the host mount provided by the user for `/data` - DEFAULT_CHE_DATA="/data" - export CHE_DATA=${CHE_DATA:-${DEFAULT_CHE_DATA}} + # DEFAULT_CHE_DATA="/data" + # export CHE_DATA=${CHE_DATA:-${DEFAULT_CHE_DATA}} + export CHE_DATA="/data" CHE_DATA_HOST=$(get_che_data_from_host) ### Are we going to use the embedded che.properties or one provided by user?` ### CHE_LOCAL_CONF_DIR is internal Che variable that sets where to load - DEFAULT_CHE_CONF_DIR="${CHE_DATA}/conf" - export CHE_LOCAL_CONF_DIR=${CHE_LOCAL_CONF_DIR:-${DEFAULT_CHE_CONF_DIR}} +# DEFAULT_CHE_CONF_DIR="/conf" +# export CHE_LOCAL_CONF_DIR="${CHE_DATA}/conf" +# export CHE_LOCAL_CONF_DIR=${CHE_LOCAL_CONF_DIR:-${DEFAULT_CHE_CONF_DIR}} - if [ ! -f "${CHE_LOCAL_CONF_DIR}/che.properties" ]; then - echo "Did not discover che.properties file. Copying properties template to ${CHE_DATA_HOST}/conf." + if [ -f "/conf/che.properties" ]; then + echo "Found custom che.properties..." + export CHE_LOCAL_CONF_DIR="/conf" + else + echo "Using embedded che.properties... Copying template to ${CHE_DATA_HOST}/conf." mkdir -p /data/conf cp -rf "${CHE_HOME}/conf/che.properties" /data/conf/che.properties + export CHE_LOCAL_CONF_DIR="/data/conf" fi # Update the provided che.properties with the location of the /data mounts - sed -i "/che.workspace.storage/c\che.workspace.storage=${CHE_DATA_HOST}/workspaces" $CHE_LOCAL_CONF_DIR/che.properties - sed -i "/che.conf.storage/c\che.conf.storage=/data/storage" $CHE_LOCAL_CONF_DIR/che.properties - sed -i "/machine.server.ext.archive/c\machine.server.ext.archive=${CHE_DATA_HOST}/lib/ws-agent.tar.gz" $CHE_LOCAL_CONF_DIR/che.properties - sed -i "/machine.server.terminal.path_to_archive.linux_amd64/c\machine.server.terminal.path_to_archive.linux_amd64=${CHE_DATA_HOST}/lib/linux_amd64/terminal" $CHE_LOCAL_CONF_DIR/che.properties - sed -i "/machine.server.terminal.path_to_archive.linux_arm7/c\machine.server.terminal.path_to_archive.linux_arm7=${CHE_DATA_HOST}/lib/linux_arm7/terminal" $CHE_LOCAL_CONF_DIR/che.properties + sed -i "/che.workspace.storage=/c\che.workspace.storage=/data/workspaces" $CHE_LOCAL_CONF_DIR/che.properties + sed -i "/che.database=/c\che.database=/data/storage" $CHE_LOCAL_CONF_DIR/che.properties + sed -i "/che.template.storage=/c\che.template.storage=/data/templates" $CHE_LOCAL_CONF_DIR/che.properties + sed -i "/che.stacks.storage=/c\che.stacks.storage=/data/stacks/stacks.json" $CHE_LOCAL_CONF_DIR/che.properties + sed -i "/che.stacks.images=/c\che.stacks.images=/data/stacks/images" $CHE_LOCAL_CONF_DIR/che.properties + sed -i "/che.workspace.agent.dev=/c\che.workspace.agent.dev=${CHE_DATA_HOST}/lib/ws-agent.tar.gz" $CHE_LOCAL_CONF_DIR/che.properties + sed -i "/che.workspace.terminal_linux_amd64=/c\che.workspace.terminal_linux_amd64=${CHE_DATA_HOST}/lib/linux_amd64/terminal" $CHE_LOCAL_CONF_DIR/che.properties + sed -i "/che.workspace.terminal_linux_arm7=/c\che.workspace.terminal_linux_arm7=${CHE_DATA_HOST}/lib/linux_arm7/terminal" $CHE_LOCAL_CONF_DIR/che.properties ### If this container is inside of a VM like boot2docker, then additional internal mods required DEFAULT_CHE_IN_VM=$(is_in_vm) @@ -109,8 +127,20 @@ init() { # Move files from /lib to /lib-copy. This puts files onto the host. rm -rf ${CHE_DATA}/lib/* - mkdir -p ${CHE_DATA}/lib - cp -rf ${CHE_HOME}/lib/* ${CHE_DATA}/lib + mkdir -p ${CHE_DATA}/lib + cp -rf ${CHE_HOME}/lib/* "${CHE_DATA}"/lib + + if [[ ! -f "${CHE_DATA}"/stacks/stacks.json ]];then + rm -rf "${CHE_DATA}"/stacks/* + mkdir -p "${CHE_DATA}"/stacks + cp -rf "${CHE_HOME}"/stacks/* "${CHE_DATA}"/stacks + fi + + if [[ ! -f "${CHE_DATA}"/templates/samples.json ]];then + rm -rf "${CHE_DATA}"/templates/* + mkdir -p "${CHE_DATA}"/templates + cp -rf "${CHE_HOME}"/templates/* "${CHE_DATA}"/templates + fi # A che property, which names the Docker network used for che + ws to communicate export JAVA_OPTS="${JAVA_OPTS} -Dche.docker.network=bridge" @@ -212,6 +242,7 @@ responsible_shutdown() { echo "" echo "Received SIGTERM" "${CHE_HOME}"/bin/che.sh stop + exit; } # setup handlers diff --git a/assembly/assembly-main/src/assembly/stack/che-in-che.json b/assembly/assembly-main/src/assembly/stack/che-in-che.json index 194a2d67037..3ecd7345f11 100644 --- a/assembly/assembly-main/src/assembly/stack/che-in-che.json +++ b/assembly/assembly-main/src/assembly/stack/che-in-che.json @@ -65,7 +65,7 @@ "type": "custom" }, { - "commandLine": "export CHE_BIN_PATH=$(ls -d /projects/che/assembly/assembly-main/target/eclipse-che-*/eclipse-che-*); sudo docker run -t -v /var/run/docker.sock:/var/run/docker.sock --env CHE_LOCAL_BINARY=${CHE_BIN_PATH//projects/'home/user/che/workspaces/che'} --env CHE_HOST_IP=$HOST_IP --env CHE_PORT=54321 codenvy/che-launcher start", + "commandLine": "export CHE_BIN_PATH=$(ls -d /projects/che/assembly/assembly-main/target/eclipse-che-*/eclipse-che-*); sudo docker run -t -v /var/run/docker.sock:/var/run/docker.sock --env CHE_ASSEMBLY=${CHE_BIN_PATH//projects/'home/user/che/workspaces/che'} --env CHE_HOST_IP=$HOST_IP --env CHE_PORT=54321 codenvy/che-launcher start", "name": "3. Run Che in Che", "type": "custom", "attributes": { diff --git a/cli.sh b/cli.sh index dcc054cb61e..663e4c778a0 100755 --- a/cli.sh +++ b/cli.sh @@ -24,7 +24,7 @@ init_global_variables() { DEFAULT_CHE_CLI_ACTION="help" DEFAULT_IS_INTERACTIVE="true" DEFAULT_IS_PSEUDO_TTY="true" - DEFAULT_CHE_DATA_FOLDER="/home/user/che" + DEFAULT_CHE_DATA="/home/user/che" CHE_PRODUCT_NAME=${CHE_PRODUCT_NAME:-${DEFAULT_CHE_PRODUCT_NAME}} CHE_LAUNCHER_IMAGE_NAME=${CHE_LAUNCHER_IMAGE_NAME:-${DEFAULT_CHE_LAUNCHER_IMAGE_NAME}} @@ -40,7 +40,7 @@ init_global_variables() { CHE_CLI_ACTION=${CHE_CLI_ACTION:-${DEFAULT_CHE_CLI_ACTION}} CHE_IS_INTERACTIVE=${CHE_IS_INTERACTIVE:-${DEFAULT_IS_INTERACTIVE}} CHE_IS_PSEUDO_TTY=${CHE_IS_PSEUDO_TTY:-${DEFAULT_IS_PSEUDO_TTY}} - CHE_DATA_FOLDER=${CHE_DATA_FOLDER:-${DEFAULT_CHE_DATA_FOLDER}} + CHE_DATA=${CHE_DATA:-${DEFAULT_CHE_DATA}} GLOBAL_NAME_MAP=$(docker info | grep "Name:" | cut -d" " -f2) GLOBAL_HOST_ARCH=$(docker version --format {{.Client}} | cut -d" " -f5) @@ -48,9 +48,9 @@ init_global_variables() { GLOBAL_GET_DOCKER_HOST_IP=$(get_docker_host_ip) if is_boot2docker && has_docker_for_windows_client; then - if [[ "${CHE_DATA_FOLDER,,}" != *"${USERPROFILE,,}"* ]]; then - CHE_DATA_FOLDER=$(get_mount_path "${USERPROFILE}/.${CHE_MINI_PRODUCT_NAME}/") - warning "Boot2docker for Windows - CHE_DATA_FOLDER set to $CHE_DATA_FOLDER" + if [[ "${CHE_DATA,,}" != *"${USERPROFILE,,}"* ]]; then + CHE_DATA=$(get_mount_path "${USERPROFILE}/.${CHE_MINI_PRODUCT_NAME}/") + warning "Boot2docker for Windows - CHE_DATA set to $CHE_DATA" fi fi @@ -88,12 +88,12 @@ Variables: CHE_VERSION Version of Che to run CHE_PORT External port of Che server CHE_HOST_IP IP address Che server binds to - must set for external users - CHE_DATA_FOLDER Where workspaces and Che prefs are stored + CHE_DATA Where workspaces and Che prefs are stored CHE_HOSTNAME External hostname of Che server - CHE_CONF_FOLDER Folder for custom che.properties file + CHE_CONF Folder for custom che.properties file CHE_RESTART_POLICY Che server Docker restart policy if container exited CHE_USER User ID of the Che server inside its container - CHE_LOCAL_BINARY Path to a Che assembly to use instead of binary in container + CHE_ASSEMBLY Path to a Che assembly to use instead of binary in container CHE_LOG_LEVEL Logging level for Che server - either debug or info CHE_EXTRA_VOLUME_MOUNT Folders to mount from host into Che workspaces CHE_PROPERTY_<> One time use properties passed to Che - see docs @@ -242,15 +242,15 @@ docker_run_with_interactive() { docker_run_with_che_properties() { debug $FUNCNAME - if [ ! -z ${CHE_CONF_FOLDER+x} ]; then + if [ ! -z ${CHE_CONF+x} ]; then # Configuration directory set by user - this has precedence. - docker_run_with_interactive -e "CHE_CONF_FOLDER=${CHE_CONF_FOLDER}" "$@" + docker_run_with_interactive -e "CHE_CONF=${CHE_CONF}" "$@" else if has_che_properties; then # No user configuration directory, but CHE_PROPERTY_ values set generate_temporary_che_properties_file - docker_run_with_interactive -e "CHE_CONF_FOLDER=$(get_mount_path ~/.${CHE_MINI_PRODUCT_NAME}/conf)" "$@" + docker_run_with_interactive -e "CHE_CONF=$(get_mount_path ~/.${CHE_MINI_PRODUCT_NAME}/conf)" "$@" rm -rf ~/."${CHE_MINI_PRODUCT_NAME}"/conf/che.properties > /dev/null else docker_run_with_interactive "$@" @@ -457,7 +457,7 @@ get_list_of_che_system_environment_variables() { echo "CHE_VERSION=${CHE_VERSION}" >> "${TMP_FILE}" echo "CHE_CLI_INFO=${CHE_CLI_INFO}" >> "${TMP_FILE}" echo "CHE_CLI_DEBUG=${CHE_CLI_DEBUG}" >> "${TMP_FILE}" - echo "CHE_DATA_FOLDER=${CHE_DATA_FOLDER}" >> "${TMP_FILE}" + echo "CHE_DATA=${CHE_DATA}" >> "${TMP_FILE}" CHE_VARIABLES=$(env | grep CHE_) diff --git a/samples/sample-plugin-actions/README.md b/samples/sample-plugin-actions/README.md index a89bff2ed43..a883d1e571c 100644 --- a/samples/sample-plugin-actions/README.md +++ b/samples/sample-plugin-actions/README.md @@ -54,7 +54,7 @@ mvn clean install ```Shell # Start Che using the CLI with your new assembly # Replace with the actual directory name -export CHE_LOCAL_BINARY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-/eclipse-che- +export CHE_ASSEMBLY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-/eclipse-che- che start ``` diff --git a/samples/sample-plugin-embedjs/README.md b/samples/sample-plugin-embedjs/README.md index dba6fb7d9e6..79c05f03874 100644 --- a/samples/sample-plugin-embedjs/README.md +++ b/samples/sample-plugin-embedjs/README.md @@ -55,7 +55,7 @@ mvn clean install ```Shell # Start Che using the CLI with your new assembly # Replace with the actual directory name -export CHE_LOCAL_BINARY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-/eclipse-che- +export CHE_ASSEMBLY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-/eclipse-che- che start ``` diff --git a/samples/sample-plugin-filetype/README.md b/samples/sample-plugin-filetype/README.md index 5cd10146377..b20dcdbd739 100644 --- a/samples/sample-plugin-filetype/README.md +++ b/samples/sample-plugin-filetype/README.md @@ -52,7 +52,7 @@ mvn clean install ```Shell # Start Che using the CLI with your new assembly # Replace with the actual directory name -export CHE_LOCAL_BINARY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-/eclipse-che- +export CHE_ASSEMBLY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-/eclipse-che- che start ``` diff --git a/samples/sample-plugin-json/README.md b/samples/sample-plugin-json/README.md index f3bc46b3587..616398cfc5d 100644 --- a/samples/sample-plugin-json/README.md +++ b/samples/sample-plugin-json/README.md @@ -91,7 +91,7 @@ mvn clean install ```Shell # Start Che using the CLI with your new assembly # Replace with the actual directory name -export CHE_LOCAL_BINARY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-/eclipse-che- +export CHE_ASSEMBLY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-/eclipse-che- che start ``` diff --git a/samples/sample-plugin-nativeaccess/README.md b/samples/sample-plugin-nativeaccess/README.md index 17978721afe..3798dae2acf 100644 --- a/samples/sample-plugin-nativeaccess/README.md +++ b/samples/sample-plugin-nativeaccess/README.md @@ -57,7 +57,7 @@ mvn clean install ```Shell # Start Che using the CLI with your new assembly # Replace with the actual directory name -export CHE_LOCAL_BINARY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-/eclipse-che- +export CHE_ASSEMBLY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-/eclipse-che- che start ``` diff --git a/samples/sample-plugin-parts/README.md b/samples/sample-plugin-parts/README.md index 30670ab9a73..1eb8face69c 100644 --- a/samples/sample-plugin-parts/README.md +++ b/samples/sample-plugin-parts/README.md @@ -55,7 +55,7 @@ mvn clean install ```Shell # Start Che using the CLI with your new assembly # Replace with the actual directory name -export CHE_LOCAL_BINARY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-/eclipse-che- +export CHE_ASSEMBLY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-/eclipse-che- che start ``` diff --git a/samples/sample-plugin-serverservice/README.md b/samples/sample-plugin-serverservice/README.md index ed4fbf027d3..85755a1201a 100644 --- a/samples/sample-plugin-serverservice/README.md +++ b/samples/sample-plugin-serverservice/README.md @@ -74,7 +74,7 @@ mvn clean install ```Shell # Start Che using the CLI with your new assembly # Replace with the actual directory name -export CHE_LOCAL_BINARY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-/eclipse-che- +export CHE_ASSEMBLY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-/eclipse-che- che start ``` diff --git a/samples/sample-plugin-wizard/README.md b/samples/sample-plugin-wizard/README.md index 274659fc816..1883d0637fd 100644 --- a/samples/sample-plugin-wizard/README.md +++ b/samples/sample-plugin-wizard/README.md @@ -140,7 +140,7 @@ mvn clean install ```Shell # Start Che using the CLI with your new assembly # Replace with the actual directory name -export CHE_LOCAL_BINARY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-/eclipse-che- +export CHE_ASSEMBLY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-/eclipse-che- che start ```