Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Che using different database path in different versions #8073

Merged
merged 16 commits into from
Jan 15, 2018
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 25 additions & 10 deletions dockerfiles/che/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ set_environment_variables () {
# CHE_DOCKER_IP is used internally by Che to set its IP address
if [[ -z "${CHE_DOCKER_IP}" ]]; then
if [[ -n "${CHE_IP}" ]]; then
export CHE_DOCKER_IP="${CHE_IP}"
export CHE_DOCKER_IP="${CHE_IP}"
Copy link
Contributor

@benoitf benoitf Jan 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe you can skip this change from this PR's commit as it's unrelated (it's more a indent fix)

fi
fi

Expand Down Expand Up @@ -199,6 +199,19 @@ launch_docker_registry () {
fi
}

perform_database_migration() {
CHE_DATA=/data
if [ -f ${CHE_DATA}/db/che.mv.db ]; then
echo "!!! Detected Che database, that is stored by an old path: ${CHE_DATA}/db/che.mv.db"
echo "!!! In case if you want to use it, move it manually to the new path ${CHE_DATA}/storage/db/che.mv.db"
echo "!!! It will be moved there automatically, if no database is present by the new path"
if [ ! -f ${CHE_DATA}/db/storage/che.mv.db ]; then
mv ${CHE_DATA}/db/che.mv.db ${CHE_DATA}/storage/db/che.mv.db
echo "Database has been successfully moved to the new path"
fi
fi
}

init() {
### Any variables with export is a value that native Tomcat che.sh startup script requires
export CHE_IP=${CHE_IP}
Expand Down Expand Up @@ -230,12 +243,14 @@ init() {
sudo chown -R ${CHE_USER} ${CHE_LOGS_DIR}
fi

export CHE_DATABASE=/data/storage
export CHE_TEMPLATE_STORAGE=/data/templates
export CHE_WORKSPACE_AGENT_DEV=${CHE_DATA_HOST}/lib/ws-agent.tar.gz
export CHE_WORKSPACE_TERMINAL__LINUX__AMD64=${CHE_DATA_HOST}/lib/linux_amd64/terminal
export CHE_WORKSPACE_TERMINAL__LINUX__ARM7=${CHE_DATA_HOST}/lib/linux_arm7/terminal
export CHE_WORKSPACE_EXEC__LINUX__AMD64=${CHE_DATA_HOST}/lib/linux_amd64/exec
[ -z "$CHE_DATABASE" ] && export CHE_DATABASE=${CHE_DATA}
[ -z "$CHE_TEMPLATE_STORAGE" ] && export CHE_TEMPLATE_STORAGE=${CHE_DATA}/templates
[ -z "$CHE_WORKSPACE_AGENT_DEV" ] && export CHE_WORKSPACE_AGENT_DEV=${CHE_DATA_HOST}/lib/ws-agent.tar.gz
[ -z "$CHE_WORKSPACE_TERMINAL__LINUX__AMD64" ] && export CHE_WORKSPACE_TERMINAL__LINUX__AMD64=${CHE_DATA_HOST}/lib/linux_amd64/terminal
[ -z "$CHE_WORKSPACE_TERMINAL__LINUX__ARM7" ] && export CHE_WORKSPACE_TERMINAL__LINUX__ARM7=${CHE_DATA_HOST}/lib/linux_arm7/terminal
[ -z "$CHE_WORKSPACE_EXEC__LINUX__AMD64" ] && export CHE_WORKSPACE_EXEC__LINUX__AMD64=${CHE_DATA_HOST}/lib/linux_amd64/exec

perform_database_migration

# CHE_DOCKER_IP_EXTERNAL must be set if you are in a VM.
HOSTNAME=${CHE_DOCKER_IP_EXTERNAL:-$(get_docker_external_hostname)}
Expand All @@ -244,9 +259,9 @@ init() {
export CHE_DOCKER_IP_EXTERNAL=${HOSTNAME}
fi
### Necessary to allow the container to write projects to the folder
export CHE_WORKSPACE_STORAGE__MASTER__PATH=/data/workspaces
export CHE_WORKSPACE_STORAGE="${CHE_DATA_HOST}/workspaces"
export CHE_WORKSPACE_STORAGE_CREATE_FOLDERS=false
[ -z "$CHE_WORKSPACE_STORAGE__MASTER__PATH" ] && export CHE_WORKSPACE_STORAGE__MASTER__PATH=${CHE_DATA}/workspaces
[ -z "$CHE_WORKSPACE_STORAGE" ] && export CHE_WORKSPACE_STORAGE="${CHE_DATA_HOST}/workspaces"
[ -z "$CHE_WORKSPACE_STORAGE_CREATE_FOLDERS" ] && export CHE_WORKSPACE_STORAGE_CREATE_FOLDERS=false

# Move files from /lib to /lib-copy. This puts files onto the host.
rm -rf ${CHE_DATA}/lib/*
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/init/modules/che/templates/che.env.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ CHE_DOCKER_NETWORK=che<%= scope.lookupvar('che::che_port') %>_che-network
<% else -%>
CHE_DOCKER_NETWORK=bridge
<% end -%>
CHE_DATABASE=/data
CHE_DATABASE=/data/storage
CHE_WORKSPACE_STORAGE=/data/workspaces
CHE_LOGS_DIR=/logs
CHE_WORKSPACE_LOGS=/logs/machines
Expand Down