diff --git a/dockerfiles/base/scripts/base/commands/cmd_start.sh b/dockerfiles/base/scripts/base/commands/cmd_start.sh index c0b512c9e34..884c63fc096 100644 --- a/dockerfiles/base/scripts/base/commands/cmd_start.sh +++ b/dockerfiles/base/scripts/base/commands/cmd_start.sh @@ -16,6 +16,7 @@ help_cmd_start() { 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" @@ -29,6 +30,7 @@ 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 @@ -42,6 +44,9 @@ pre_cmd_start() { --skip:postflight) CHE_SKIP_POSTFLIGHT=true shift ;; + --follow) + CHE_FOLLOW_LOGS=true + shift ;; --force) FORCE_UPDATE="--force" shift ;; @@ -226,8 +231,14 @@ wait_until_booted() { # 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; then - docker logs -f ${CHE_CONTAINER_NAME} & + 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}\"" @@ -309,3 +320,11 @@ skip_postflight() { return 1 fi } + +follow_logs() { + if [ "${CHE_FOLLOW_LOGS}" = "true" ]; then + return 0 + else + return 1 + fi +} diff --git a/dockerfiles/base/scripts/base/startup_02_pre_docker.sh b/dockerfiles/base/scripts/base/startup_02_pre_docker.sh index 53ff7df3528..10c2bb9f1a6 100644 --- a/dockerfiles/base/scripts/base/startup_02_pre_docker.sh +++ b/dockerfiles/base/scripts/base/startup_02_pre_docker.sh @@ -428,7 +428,9 @@ init_check_mounts() { fi # Verify that we can write to the host file system from the container - check_host_volume_mount + if ! is_fast; then + check_host_volume_mount + fi DEFAULT_CHE_CONFIG="${DATA_MOUNT}" DEFAULT_CHE_INSTANCE="${DATA_MOUNT}"/instance @@ -642,19 +644,27 @@ check_host_volume_mount() { warning "Boot2docker detected - ensure :/data is mounted to %userprofile%" fi - if file_system_writable "${CHE_CONTAINER_ROOT}/test"; then - delete_file_system_test "${CHE_CONTAINER_ROOT}/test" - else - error "Unable to write files to your host" + 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 files on your host?" + 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" } -file_system_writable() { - echo 'test' > "${1}" +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 @@ -662,12 +672,20 @@ file_system_writable() { 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() { -# debug $FUNCNAME if uname -r | grep -q 'boot2docker'; then return 0 else diff --git a/dockerfiles/base/scripts/base/startup_05_pre_exec.sh b/dockerfiles/base/scripts/base/startup_05_pre_exec.sh index ce0c9f106db..2781aa3e709 100644 --- a/dockerfiles/base/scripts/base/startup_05_pre_exec.sh +++ b/dockerfiles/base/scripts/base/startup_05_pre_exec.sh @@ -23,7 +23,7 @@ cli_parse () { rmi|upgrade|version|ssh|sync|action|test|compile|dir|help) ;; *) - error "You passed an unknown command." + error "You passed an unknown command: $1" usage return 2 ;;