Skip to content

Commit

Permalink
Follow up fixes after configuration property renaming (eclipse-che#2955)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michail Kuznetsov authored Nov 2, 2016
1 parent 2a0081e commit 42a8e43
Show file tree
Hide file tree
Showing 14 changed files with 72 additions and 40 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ target/
bin/
test-output/
maven-eclipse.xml
instance/
config/

# Idea #
##################
Expand Down
2 changes: 1 addition & 1 deletion Chefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
1 change: 0 additions & 1 deletion assembly/assembly-main/src/assembly/bin/che.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
65 changes: 48 additions & 17 deletions assembly/assembly-main/src/assembly/bin/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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 "!!!"
Expand All @@ -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)
Expand All @@ -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"
Expand Down Expand Up @@ -212,6 +242,7 @@ responsible_shutdown() {
echo ""
echo "Received SIGTERM"
"${CHE_HOME}"/bin/che.sh stop
exit;
}

# setup handlers
Expand Down
2 changes: 1 addition & 1 deletion assembly/assembly-main/src/assembly/stack/che-in-che.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
24 changes: 12 additions & 12 deletions cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand All @@ -40,17 +40,17 @@ 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)
GLOBAL_UNAME=$(docker run --rm alpine sh -c "uname -r")
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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 "$@"
Expand Down Expand Up @@ -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_)

Expand Down
2 changes: 1 addition & 1 deletion samples/sample-plugin-actions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ mvn clean install
```Shell
# Start Che using the CLI with your new assembly
# Replace <version> with the actual directory name
export CHE_LOCAL_BINARY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-<version>/eclipse-che-<version>
export CHE_ASSEMBLY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-<version>/eclipse-che-<version>
che start
```

Expand Down
2 changes: 1 addition & 1 deletion samples/sample-plugin-embedjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ mvn clean install
```Shell
# Start Che using the CLI with your new assembly
# Replace <version> with the actual directory name
export CHE_LOCAL_BINARY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-<version>/eclipse-che-<version>
export CHE_ASSEMBLY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-<version>/eclipse-che-<version>
che start
```

Expand Down
2 changes: 1 addition & 1 deletion samples/sample-plugin-filetype/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ mvn clean install
```Shell
# Start Che using the CLI with your new assembly
# Replace <version> with the actual directory name
export CHE_LOCAL_BINARY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-<version>/eclipse-che-<version>
export CHE_ASSEMBLY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-<version>/eclipse-che-<version>
che start
```

Expand Down
2 changes: 1 addition & 1 deletion samples/sample-plugin-json/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ mvn clean install
```Shell
# Start Che using the CLI with your new assembly
# Replace <version> with the actual directory name
export CHE_LOCAL_BINARY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-<version>/eclipse-che-<version>
export CHE_ASSEMBLY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-<version>/eclipse-che-<version>
che start
```

Expand Down
2 changes: 1 addition & 1 deletion samples/sample-plugin-nativeaccess/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ mvn clean install
```Shell
# Start Che using the CLI with your new assembly
# Replace <version> with the actual directory name
export CHE_LOCAL_BINARY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-<version>/eclipse-che-<version>
export CHE_ASSEMBLY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-<version>/eclipse-che-<version>
che start
```

Expand Down
2 changes: 1 addition & 1 deletion samples/sample-plugin-parts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ mvn clean install
```Shell
# Start Che using the CLI with your new assembly
# Replace <version> with the actual directory name
export CHE_LOCAL_BINARY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-<version>/eclipse-che-<version>
export CHE_ASSEMBLY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-<version>/eclipse-che-<version>
che start
```

Expand Down
2 changes: 1 addition & 1 deletion samples/sample-plugin-serverservice/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ mvn clean install
```Shell
# Start Che using the CLI with your new assembly
# Replace <version> with the actual directory name
export CHE_LOCAL_BINARY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-<version>/eclipse-che-<version>
export CHE_ASSEMBLY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-<version>/eclipse-che-<version>
che start
```

Expand Down
2 changes: 1 addition & 1 deletion samples/sample-plugin-wizard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ mvn clean install
```Shell
# Start Che using the CLI with your new assembly
# Replace <version> with the actual directory name
export CHE_LOCAL_BINARY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-<version>/eclipse-che-<version>
export CHE_ASSEMBLY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-<version>/eclipse-che-<version>
che start
```

Expand Down

0 comments on commit 42a8e43

Please sign in to comment.