From f9f48115499d7345827f09a25ac2635a58e0f062 Mon Sep 17 00:00:00 2001 From: Tianyong Qiu Date: Fri, 28 Feb 2025 10:42:39 +0800 Subject: [PATCH] Update for support chat --- devbox/devbox.local/cli/devbox | 96 ++++++++++--------- .../cli/docker-compose.dev.arm64.new.yaml | 5 +- devbox/devbox.local/cli/freeleaps | 1 + 3 files changed, 55 insertions(+), 47 deletions(-) create mode 160000 devbox/devbox.local/cli/freeleaps diff --git a/devbox/devbox.local/cli/devbox b/devbox/devbox.local/cli/devbox index e140fdb..9758f2c 100644 --- a/devbox/devbox.local/cli/devbox +++ b/devbox/devbox.local/cli/devbox @@ -803,7 +803,54 @@ devbox_init_command() { # record container id, DEVBOX_FRONTEND_PORT, DEVBOX_BACKEND_PORT echo "$container_id" > "$WORKING_HOME/.devbox-instance" echo "$DEVBOX_FRONTEND_PORT" > "$WORKING_HOME/.devbox-frontend-port" - echo "$DEVBOX_BACKEND_PORT" > "$WORKING_HOME/.devbox-backend-port" + echo "$DEVBOX_BACKEND_PORT" > "$WORKING_HOME/.devbox-backend-port"] + + # Check if username and password are set + if [[ -z "$FREELEAPS_USERNAME" || -z "$FREELEAPS_PASSWORD" ]]; then + echo "Warining: Username and password are required to pull freeleaps.com code." + echo "==> [INIT] DevBox environment initialization completed." + exit 1 + fi + + # Test if the user can access the freeleaps.com repository + echo "==> Testing access to freeleaps.com repository..." + if ! git ls-remote "https://$FREELEAPS_USERNAME:$FREELEAPS_PASSWORD@freeleaps.com:3443/products/freeleaps.git" &>/dev/null; then + echo "ERROR: Failed to access freeleaps.com repository. Please check your username and password." + echo "==> [INIT] DevBox environment initialization completed successfully, but access to the freeleaps.com repository failed." + exit 1 + fi + + DOVBOX_CLI_DIR=$(pwd) + + FREELEAPS_DIR="$WORKING_HOME/freeleaps" + FRONTEND_GIT_URL="https://$FREELEAPS_USERNAME:$FREELEAPS_PASSWORD@freeleaps.com:3443/products/freeleaps.git" + # Check if freeleaps2-frontend exists, if not git clone it + if [ ! -d "$FREELEAPS_DIR" ]; then + pushd "$WORKING_HOME" > /dev/null + echo "Git cloning freeleaps.com:3443/products/freeleaps.git 1" + git clone --depth 5 $FRONTEND_GIT_URL + else + echo "Git pulling 2" + pushd "$FREELEAPS_DIR" > /dev/null + # Check $WORKING_HOME/freeleaps exists and it is a git repository, if not git clone it + if ! git rev-parse --is-inside-work-tree &>/dev/null; then + popd > /dev/null # Exit from $FREELEAPS_DIR + rm -rf "$FREELEAPS_DIR" # Remove $FREELEAPS_DIR + rmdir "$FREELEAPS_DIR" # Remove $FREELEAPS_DIR + + # Git clone freeleaps.com:3443/products/freeleaps.git + echo "Cloning repository again: $FRONTEND_GIT_URL" + sudo chown -R "$OWNER_GROUP" "$WORKING_HOME" + git clone --depth 5 "$FRONTEND_GIT_URL" + else + echo "Git pulling freeleaps.com:3443/products/freeleaps.git" + git pull + fi + + popd > /dev/null + fi + + pushd $DOVBOX_CLI_DIR > /dev/null # ------------------------------------------------------------------- # 6. linbwang: pull and start other components @@ -824,7 +871,7 @@ if [[ $USE_LOCAL_COMPONENT_VAL == true ]]; then export AUTHENTICATION_IMAGE_TAG="$AUTHENTICATION_TAG" export NOTIFICATION_IMAGE_TAG="$NOTIFICATION_TAG" export CHAT_IMAGE_TAG="$CHAT_TAG" - + # Check if gitea_data_backup.tar.gz exists at current script directory, if not exit if [[ ! -f "gitea_data_backup.tar.gz" ]]; then echo "ERROR: gitea_data_backup.tar.gz not found. Please make sure it exists in the current directory." @@ -866,6 +913,8 @@ if [[ $USE_LOCAL_COMPONENT_VAL == true ]]; then exit 1 fi + + # Start Gitea, MongoDB, RabbitMQ and other components containers echo "===> start Gitea, MongoDB, RabbitMQ and other components containers" docker-compose -f docker-compose.dev.arm64.new.yaml up -d mongodb rabbitmq gitea "${start_components[@]}" @@ -945,49 +994,6 @@ fi IS_START_FRONTEND=true -# Check if username and password are set -if [[ -z "$FREELEAPS_USERNAME" || -z "$FREELEAPS_PASSWORD" ]]; then - echo "Warining: Username and password are required to pull freeleaps.com code." - echo "==> [INIT] DevBox environment initialization completed." - exit 1 -fi - -# Test if the user can access the freeleaps.com repository -echo "==> Testing access to freeleaps.com repository..." -if ! git ls-remote "https://$FREELEAPS_USERNAME:$FREELEAPS_PASSWORD@freeleaps.com:3443/products/freeleaps.git" &>/dev/null; then - echo "ERROR: Failed to access freeleaps.com repository. Please check your username and password." - echo "==> [INIT] DevBox environment initialization completed successfully, but access to the freeleaps.com repository failed." - exit 1 -fi - -FREELEAPS_DIR="$WORKING_HOME/freeleaps" -FRONTEND_GIT_URL="https://$FREELEAPS_USERNAME:$FREELEAPS_PASSWORD@freeleaps.com:3443/products/freeleaps.git" -# Check if freeleaps2-frontend exists, if not git clone it -if [ ! -d "$FREELEAPS_DIR" ]; then - echo "Git cloning freeleaps.com:3443/products/freeleaps.git" - git clone --depth 5 $FRONTEND_GIT_URL -else - pushd "$FREELEAPS_DIR" > /dev/null - # Check $WORKING_HOME/freeleaps exists and it is a git repository, if not git clone it - if ! git rev-parse --is-inside-work-tree &>/dev/null; then - popd > /dev/null # Exit from $FREELEAPS_DIR - rm -rf "$FREELEAPS_DIR" # Remove $FREELEAPS_DIR - ls -la "$WORKING_HOME" - rmdir "$FREELEAPS_DIR" # Remove $FREELEAPS_DIR - ls -la "$WORKING_HOME" - - # Git clone freeleaps.com:3443/products/freeleaps.git - echo "Cloning repository again: $FRONTEND_GIT_URL" - sudo chown -R "$OWNER_GROUP" "$WORKING_HOME" - git clone --depth 5 "$FRONTEND_GIT_URL" - else - echo "Git pulling freeleaps.com:3443/products/freeleaps.git" - git pull - fi - - popd > /dev/null -fi - # Run banckend service and frontend service in the container docker exec -i "$DEVBOX_NAME" bash <