diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 1d05f838b..c4ff78d6a 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -26,8 +26,10 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/install/common.sh" -if grep -q docker /proc/1/cgroup; then +if openim::util::is_running_in_container; then exec > ${DOCKER_LOG_FILE} 2>&1 +else + echo "host!!!!" fi diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index d84562c1d..e9908ae66 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -2866,6 +2866,15 @@ function openim::util::gen_os_arch() { +function openim::util::is_running_in_container() { + if grep -qE 'docker|kubepods' /proc/1/cgroup || [ -f /.dockerenv ]; then + return 0 + else + return 1 + fi +} + + function openim::util::check_process_names_for_stop() { local all_stopped=true for service in "${OPENIM_ALL_SERVICE_LIBRARIES[@]}"; do diff --git a/scripts/start-all.sh b/scripts/start-all.sh index fcf9496cc..009125466 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -62,8 +62,10 @@ function execute_start_scripts() { -if grep -q docker /proc/1/cgroup; then +if openim::util::is_running_in_container; then exec > ${DOCKER_LOG_FILE} 2>&1 +else + echo "host!!!!" fi