Skip to content

Commit 42a8e43

Browse files
author
Michail Kuznetsov
authored
Follow up fixes after configuration property renaming (eclipse-che#2955)
1 parent 2a0081e commit 42a8e43

14 files changed

Lines changed: 72 additions & 40 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ target/
99
bin/
1010
test-output/
1111
maven-eclipse.xml
12+
instance/
13+
config/
1214

1315
# Idea #
1416
##################

Chefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ workspace.commands[0].name="1. Build Che in Che"
66
workspace.commands[0].commandLine="mvn clean install -f /projects/che/assembly/assembly-main"
77

88
workspace.commands[1].name="2. Run Che in Che"
9-
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'
9+
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'
1010
workspace.commands[1].attributes={
1111
"previewUrl": "http://localhost:54321"
1212
}

assembly/assembly-main/src/assembly/bin/che.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ start_che_server () {
271271
stop_che_server () {
272272
echo -e "Stopping Che server running on localhost:${CHE_PORT}"
273273
call_catalina >/dev/null 2>&1
274-
return 1;
275274
}
276275

277276
call_catalina () {

assembly/assembly-main/src/assembly/bin/docker.sh

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ pid=0
1717
check_docker() {
1818
if [ ! -S /var/run/docker.sock ]; then
1919
echo "Docker socket (/var/run/docker.sock) hasn't been mounted. Verify your \"docker run\" syntax."
20-
return 1;
20+
return 2;
2121
fi
2222

2323
if ! docker ps > /dev/null 2>&1; then
2424
output=$(docker ps)
25-
error_exit "Error when running \"docker ps\": ${output}"
25+
echo "Error when running \"docker ps\": ${output}"
26+
return 2;
2627
fi
2728
}
2829

@@ -51,9 +52,17 @@ init() {
5152
export CHE_IN_CONTAINER="true"
5253
export CHE_SKIP_JAVA_VERSION_CHECK="true"
5354

55+
if [ -f "/assembly/bin/che.sh" ]; then
56+
echo "Found custom assembly..."
57+
export CHE_HOME="/assembly"
58+
else
59+
echo "Using embedded assembly..."
60+
export CHE_HOME="/home/user/che"
61+
fi
62+
5463
### Are we using the included assembly or did user provide their own?
55-
DEFAULT_CHE_HOME="/home/user/che"
56-
export CHE_HOME=${CHE_ASSEMBLY:-${DEFAULT_CHE_HOME}}
64+
# DEFAULT_CHE_HOME="/assembly"
65+
# export CHE_HOME=${CHE_ASSEMBLY:-${DEFAULT_CHE_HOME}}
5766

5867
if [ ! -f $CHE_HOME/bin/che.sh ]; then
5968
echo "!!!"
@@ -64,27 +73,36 @@ init() {
6473
fi
6574

6675
### We need to discover the host mount provided by the user for `/data`
67-
DEFAULT_CHE_DATA="/data"
68-
export CHE_DATA=${CHE_DATA:-${DEFAULT_CHE_DATA}}
76+
# DEFAULT_CHE_DATA="/data"
77+
# export CHE_DATA=${CHE_DATA:-${DEFAULT_CHE_DATA}}
78+
export CHE_DATA="/data"
6979
CHE_DATA_HOST=$(get_che_data_from_host)
7080

7181
### Are we going to use the embedded che.properties or one provided by user?`
7282
### CHE_LOCAL_CONF_DIR is internal Che variable that sets where to load
73-
DEFAULT_CHE_CONF_DIR="${CHE_DATA}/conf"
74-
export CHE_LOCAL_CONF_DIR=${CHE_LOCAL_CONF_DIR:-${DEFAULT_CHE_CONF_DIR}}
83+
# DEFAULT_CHE_CONF_DIR="/conf"
84+
# export CHE_LOCAL_CONF_DIR="${CHE_DATA}/conf"
85+
# export CHE_LOCAL_CONF_DIR=${CHE_LOCAL_CONF_DIR:-${DEFAULT_CHE_CONF_DIR}}
7586

76-
if [ ! -f "${CHE_LOCAL_CONF_DIR}/che.properties" ]; then
77-
echo "Did not discover che.properties file. Copying properties template to ${CHE_DATA_HOST}/conf."
87+
if [ -f "/conf/che.properties" ]; then
88+
echo "Found custom che.properties..."
89+
export CHE_LOCAL_CONF_DIR="/conf"
90+
else
91+
echo "Using embedded che.properties... Copying template to ${CHE_DATA_HOST}/conf."
7892
mkdir -p /data/conf
7993
cp -rf "${CHE_HOME}/conf/che.properties" /data/conf/che.properties
94+
export CHE_LOCAL_CONF_DIR="/data/conf"
8095
fi
8196

8297
# Update the provided che.properties with the location of the /data mounts
83-
sed -i "/che.workspace.storage/c\che.workspace.storage=${CHE_DATA_HOST}/workspaces" $CHE_LOCAL_CONF_DIR/che.properties
84-
sed -i "/che.conf.storage/c\che.conf.storage=/data/storage" $CHE_LOCAL_CONF_DIR/che.properties
85-
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
86-
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
87-
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
98+
sed -i "/che.workspace.storage=/c\che.workspace.storage=/data/workspaces" $CHE_LOCAL_CONF_DIR/che.properties
99+
sed -i "/che.database=/c\che.database=/data/storage" $CHE_LOCAL_CONF_DIR/che.properties
100+
sed -i "/che.template.storage=/c\che.template.storage=/data/templates" $CHE_LOCAL_CONF_DIR/che.properties
101+
sed -i "/che.stacks.storage=/c\che.stacks.storage=/data/stacks/stacks.json" $CHE_LOCAL_CONF_DIR/che.properties
102+
sed -i "/che.stacks.images=/c\che.stacks.images=/data/stacks/images" $CHE_LOCAL_CONF_DIR/che.properties
103+
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
104+
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
105+
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
88106

89107
### If this container is inside of a VM like boot2docker, then additional internal mods required
90108
DEFAULT_CHE_IN_VM=$(is_in_vm)
@@ -109,8 +127,20 @@ init() {
109127

110128
# Move files from /lib to /lib-copy. This puts files onto the host.
111129
rm -rf ${CHE_DATA}/lib/*
112-
mkdir -p ${CHE_DATA}/lib
113-
cp -rf ${CHE_HOME}/lib/* ${CHE_DATA}/lib
130+
mkdir -p ${CHE_DATA}/lib
131+
cp -rf ${CHE_HOME}/lib/* "${CHE_DATA}"/lib
132+
133+
if [[ ! -f "${CHE_DATA}"/stacks/stacks.json ]];then
134+
rm -rf "${CHE_DATA}"/stacks/*
135+
mkdir -p "${CHE_DATA}"/stacks
136+
cp -rf "${CHE_HOME}"/stacks/* "${CHE_DATA}"/stacks
137+
fi
138+
139+
if [[ ! -f "${CHE_DATA}"/templates/samples.json ]];then
140+
rm -rf "${CHE_DATA}"/templates/*
141+
mkdir -p "${CHE_DATA}"/templates
142+
cp -rf "${CHE_HOME}"/templates/* "${CHE_DATA}"/templates
143+
fi
114144

115145
# A che property, which names the Docker network used for che + ws to communicate
116146
export JAVA_OPTS="${JAVA_OPTS} -Dche.docker.network=bridge"
@@ -212,6 +242,7 @@ responsible_shutdown() {
212242
echo ""
213243
echo "Received SIGTERM"
214244
"${CHE_HOME}"/bin/che.sh stop
245+
exit;
215246
}
216247

217248
# setup handlers

assembly/assembly-main/src/assembly/stack/che-in-che.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"type": "custom"
6666
},
6767
{
68-
"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",
68+
"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",
6969
"name": "3. Run Che in Che",
7070
"type": "custom",
7171
"attributes": {

cli.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ init_global_variables() {
2424
DEFAULT_CHE_CLI_ACTION="help"
2525
DEFAULT_IS_INTERACTIVE="true"
2626
DEFAULT_IS_PSEUDO_TTY="true"
27-
DEFAULT_CHE_DATA_FOLDER="/home/user/che"
27+
DEFAULT_CHE_DATA="/home/user/che"
2828

2929
CHE_PRODUCT_NAME=${CHE_PRODUCT_NAME:-${DEFAULT_CHE_PRODUCT_NAME}}
3030
CHE_LAUNCHER_IMAGE_NAME=${CHE_LAUNCHER_IMAGE_NAME:-${DEFAULT_CHE_LAUNCHER_IMAGE_NAME}}
@@ -40,17 +40,17 @@ init_global_variables() {
4040
CHE_CLI_ACTION=${CHE_CLI_ACTION:-${DEFAULT_CHE_CLI_ACTION}}
4141
CHE_IS_INTERACTIVE=${CHE_IS_INTERACTIVE:-${DEFAULT_IS_INTERACTIVE}}
4242
CHE_IS_PSEUDO_TTY=${CHE_IS_PSEUDO_TTY:-${DEFAULT_IS_PSEUDO_TTY}}
43-
CHE_DATA_FOLDER=${CHE_DATA_FOLDER:-${DEFAULT_CHE_DATA_FOLDER}}
43+
CHE_DATA=${CHE_DATA:-${DEFAULT_CHE_DATA}}
4444

4545
GLOBAL_NAME_MAP=$(docker info | grep "Name:" | cut -d" " -f2)
4646
GLOBAL_HOST_ARCH=$(docker version --format {{.Client}} | cut -d" " -f5)
4747
GLOBAL_UNAME=$(docker run --rm alpine sh -c "uname -r")
4848
GLOBAL_GET_DOCKER_HOST_IP=$(get_docker_host_ip)
4949

5050
if is_boot2docker && has_docker_for_windows_client; then
51-
if [[ "${CHE_DATA_FOLDER,,}" != *"${USERPROFILE,,}"* ]]; then
52-
CHE_DATA_FOLDER=$(get_mount_path "${USERPROFILE}/.${CHE_MINI_PRODUCT_NAME}/")
53-
warning "Boot2docker for Windows - CHE_DATA_FOLDER set to $CHE_DATA_FOLDER"
51+
if [[ "${CHE_DATA,,}" != *"${USERPROFILE,,}"* ]]; then
52+
CHE_DATA=$(get_mount_path "${USERPROFILE}/.${CHE_MINI_PRODUCT_NAME}/")
53+
warning "Boot2docker for Windows - CHE_DATA set to $CHE_DATA"
5454
fi
5555
fi
5656

@@ -88,12 +88,12 @@ Variables:
8888
CHE_VERSION Version of Che to run
8989
CHE_PORT External port of Che server
9090
CHE_HOST_IP IP address Che server binds to - must set for external users
91-
CHE_DATA_FOLDER Where workspaces and Che prefs are stored
91+
CHE_DATA Where workspaces and Che prefs are stored
9292
CHE_HOSTNAME External hostname of Che server
93-
CHE_CONF_FOLDER Folder for custom che.properties file
93+
CHE_CONF Folder for custom che.properties file
9494
CHE_RESTART_POLICY Che server Docker restart policy if container exited
9595
CHE_USER User ID of the Che server inside its container
96-
CHE_LOCAL_BINARY Path to a Che assembly to use instead of binary in container
96+
CHE_ASSEMBLY Path to a Che assembly to use instead of binary in container
9797
CHE_LOG_LEVEL Logging level for Che server - either debug or info
9898
CHE_EXTRA_VOLUME_MOUNT Folders to mount from host into Che workspaces
9999
CHE_PROPERTY_<> One time use properties passed to Che - see docs
@@ -242,15 +242,15 @@ docker_run_with_interactive() {
242242

243243
docker_run_with_che_properties() {
244244
debug $FUNCNAME
245-
if [ ! -z ${CHE_CONF_FOLDER+x} ]; then
245+
if [ ! -z ${CHE_CONF+x} ]; then
246246

247247
# Configuration directory set by user - this has precedence.
248-
docker_run_with_interactive -e "CHE_CONF_FOLDER=${CHE_CONF_FOLDER}" "$@"
248+
docker_run_with_interactive -e "CHE_CONF=${CHE_CONF}" "$@"
249249
else
250250
if has_che_properties; then
251251
# No user configuration directory, but CHE_PROPERTY_ values set
252252
generate_temporary_che_properties_file
253-
docker_run_with_interactive -e "CHE_CONF_FOLDER=$(get_mount_path ~/.${CHE_MINI_PRODUCT_NAME}/conf)" "$@"
253+
docker_run_with_interactive -e "CHE_CONF=$(get_mount_path ~/.${CHE_MINI_PRODUCT_NAME}/conf)" "$@"
254254
rm -rf ~/."${CHE_MINI_PRODUCT_NAME}"/conf/che.properties > /dev/null
255255
else
256256
docker_run_with_interactive "$@"
@@ -457,7 +457,7 @@ get_list_of_che_system_environment_variables() {
457457
echo "CHE_VERSION=${CHE_VERSION}" >> "${TMP_FILE}"
458458
echo "CHE_CLI_INFO=${CHE_CLI_INFO}" >> "${TMP_FILE}"
459459
echo "CHE_CLI_DEBUG=${CHE_CLI_DEBUG}" >> "${TMP_FILE}"
460-
echo "CHE_DATA_FOLDER=${CHE_DATA_FOLDER}" >> "${TMP_FILE}"
460+
echo "CHE_DATA=${CHE_DATA}" >> "${TMP_FILE}"
461461

462462
CHE_VARIABLES=$(env | grep CHE_)
463463

samples/sample-plugin-actions/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ mvn clean install
5454
```Shell
5555
# Start Che using the CLI with your new assembly
5656
# Replace <version> with the actual directory name
57-
export CHE_LOCAL_BINARY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-<version>/eclipse-che-<version>
57+
export CHE_ASSEMBLY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-<version>/eclipse-che-<version>
5858
che start
5959
```
6060

samples/sample-plugin-embedjs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ mvn clean install
5555
```Shell
5656
# Start Che using the CLI with your new assembly
5757
# Replace <version> with the actual directory name
58-
export CHE_LOCAL_BINARY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-<version>/eclipse-che-<version>
58+
export CHE_ASSEMBLY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-<version>/eclipse-che-<version>
5959
che start
6060
```
6161

samples/sample-plugin-filetype/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ mvn clean install
5252
```Shell
5353
# Start Che using the CLI with your new assembly
5454
# Replace <version> with the actual directory name
55-
export CHE_LOCAL_BINARY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-<version>/eclipse-che-<version>
55+
export CHE_ASSEMBLY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-<version>/eclipse-che-<version>
5656
che start
5757
```
5858

samples/sample-plugin-json/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ mvn clean install
9191
```Shell
9292
# Start Che using the CLI with your new assembly
9393
# Replace <version> with the actual directory name
94-
export CHE_LOCAL_BINARY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-<version>/eclipse-che-<version>
94+
export CHE_ASSEMBLY=path_to_che_sources/assembly/assembly-main/target/eclipse-che-<version>/eclipse-che-<version>
9595
che start
9696
```
9797

0 commit comments

Comments
 (0)