forked from freeleaps/freeleaps-pub
Update for echo output optimize
This commit is contained in:
parent
876a74364b
commit
e982d81d69
@ -461,11 +461,11 @@ inspect_args() {
|
|||||||
|
|
||||||
|
|
||||||
install_docker() {
|
install_docker() {
|
||||||
log_info "==> Installing Docker..."
|
log_info "Installing Docker..."
|
||||||
|
|
||||||
# Check if Docker is already installed
|
# Check if Docker is already installed
|
||||||
if command -v docker &>/dev/null; then
|
if command -v docker &>/dev/null; then
|
||||||
log_info "==> Docker is already installed."
|
log_info "Docker is already installed."
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -541,11 +541,11 @@ install_docker() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
check_docker_running() {
|
check_docker_running() {
|
||||||
log_info "==> Checking if Docker service is running..."
|
log_info "Checking if Docker service is running..."
|
||||||
|
|
||||||
# if Docker CLI is installed and Docker daemon is running
|
# if Docker CLI is installed and Docker daemon is running
|
||||||
if docker info >/dev/null 2>&1; then
|
if docker info >/dev/null 2>&1; then
|
||||||
log_info "==> Docker is running."
|
log_info "Docker is running."
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -553,7 +553,7 @@ check_docker_running() {
|
|||||||
if grep -qi microsoft /proc/version; then
|
if grep -qi microsoft /proc/version; then
|
||||||
log_info "Detected WSL environment. Verifying /var/run/docker.sock..."
|
log_info "Detected WSL environment. Verifying /var/run/docker.sock..."
|
||||||
if [ -S /var/run/docker.sock ]; then
|
if [ -S /var/run/docker.sock ]; then
|
||||||
log_info "==> Docker socket found. Docker should be available via Docker Desktop."
|
log_info "Docker socket found. Docker should be available via Docker Desktop."
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
log_error "Docker socket not found in WSL environment."
|
log_error "Docker socket not found in WSL environment."
|
||||||
@ -561,26 +561,26 @@ check_docker_running() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log_info "==> Docker is not running. Attempting to start it..."
|
log_info "Docker is not running. Attempting to start it..."
|
||||||
|
|
||||||
# Start Docker service using systemctl or service command
|
# Start Docker service using systemctl or service command
|
||||||
if command -v systemctl &>/dev/null; then
|
if command -v systemctl &>/dev/null; then
|
||||||
if systemctl list-units --type=service | grep -q "docker.service"; then
|
if systemctl list-units --type=service | grep -q "docker.service"; then
|
||||||
log_info "==> Starting Docker with systemctl..."
|
log_info "Starting Docker with systemctl..."
|
||||||
sudo systemctl start docker && log_info "==> Docker started successfully." && return 0
|
sudo systemctl start docker && log_info "Docker started successfully." && return 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if command -v service &>/dev/null; then
|
if command -v service &>/dev/null; then
|
||||||
if service --status-all | grep -q "docker"; then
|
if service --status-all | grep -q "docker"; then
|
||||||
log_info "==> Starting Docker with service..."
|
log_info "Starting Docker with service..."
|
||||||
sudo service docker start && log_info "==> Docker started successfully." && return 0
|
sudo service docker start && log_info "Docker started successfully." && return 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if command -v snap &>/dev/null && snap list | grep -q "docker"; then
|
if command -v snap &>/dev/null && snap list | grep -q "docker"; then
|
||||||
log_info "==> Starting Docker with snap..."
|
log_info "Starting Docker with snap..."
|
||||||
sudo snap start docker && log_info "==> Docker started successfully." && return 0
|
sudo snap start docker && log_info "Docker started successfully." && return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log_error "Unable to start Docker automatically. Please start it manually."
|
log_error "Unable to start Docker automatically. Please start it manually."
|
||||||
@ -589,7 +589,7 @@ check_docker_running() {
|
|||||||
|
|
||||||
build_local_image() {
|
build_local_image() {
|
||||||
local dockerfile_path="$1"
|
local dockerfile_path="$1"
|
||||||
log_info "==> [Build] use Dockerfile: $(grep '^FROM' "$dockerfile_path")"
|
log_info "[Build] use Dockerfile: $(grep '^FROM' "$dockerfile_path")"
|
||||||
|
|
||||||
# Check if the image already exists
|
# Check if the image already exists
|
||||||
docker rmi -f $devbox_full_image 2>/dev/null || true
|
docker rmi -f $devbox_full_image 2>/dev/null || true
|
||||||
@ -637,7 +637,7 @@ get_port() {
|
|||||||
# Build the local image
|
# Build the local image
|
||||||
build_local_image() {
|
build_local_image() {
|
||||||
local dockerfile_path="$1"
|
local dockerfile_path="$1"
|
||||||
log_info "==> [BUILD] Building local image..."
|
log_info "[BUILD] Building local image..."
|
||||||
docker buildx build \
|
docker buildx build \
|
||||||
--platform linux/amd64 \
|
--platform linux/amd64 \
|
||||||
--build-arg BUILDARCH="x86-64-v3" \
|
--build-arg BUILDARCH="x86-64-v3" \
|
||||||
@ -805,7 +805,7 @@ if true ; then
|
|||||||
# 4️⃣ Build the frontend
|
# 4️⃣ Build the frontend
|
||||||
pnpm run build
|
pnpm run build
|
||||||
|
|
||||||
echo "==> [INIT] Backend and frontend environment initialization completed."
|
echo "[INIT] \$(date '+%Y-%m-%d %H:%M:%S') Backend and frontend environment initialization completed."
|
||||||
|
|
||||||
fi
|
fi
|
||||||
EOF
|
EOF
|
||||||
@ -876,7 +876,7 @@ docker exec -i "$DEVBOX_NAME" bash <<EOF
|
|||||||
echo
|
echo
|
||||||
echo "============================================================================================"
|
echo "============================================================================================"
|
||||||
echo
|
echo
|
||||||
echo "[BACKEND] \$(date '+%Y-%m-%d %H:%M:%S') [WARNING] Backend service is running with PID: \$backend_pid, if you want to restart, please stop it first or run devbox restart -e backend."
|
echo "[BACKEND] [WARNING] Backend service is running with PID: \$backend_pid, if you want to restart, please stop it first or run devbox restart -e backend."
|
||||||
echo
|
echo
|
||||||
echo "============================================================================================"
|
echo "============================================================================================"
|
||||||
echo
|
echo
|
||||||
@ -1386,8 +1386,8 @@ devbox_init_command() {
|
|||||||
# If is_pull_all_components is true, then pull all components
|
# If is_pull_all_components is true, then pull all components
|
||||||
if [[ "$is_pull_all_components" == true ]]; then
|
if [[ "$is_pull_all_components" == true ]]; then
|
||||||
start_components=("${components[@]}")
|
start_components=("${components[@]}")
|
||||||
log_info "==> Pulling all components..."
|
log_info "Pulling all components..."
|
||||||
log_info "==> start components: ${start_components[@]}"
|
log_info "start components: ${start_components[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove duplicated components
|
# Remove duplicated components
|
||||||
@ -1422,9 +1422,9 @@ devbox_init_command() {
|
|||||||
|
|
||||||
# Auto detected $OS
|
# Auto detected $OS
|
||||||
if [[ "$OS" == "auto" ]]; then
|
if [[ "$OS" == "auto" ]]; then
|
||||||
log_info "==> Auto detecting OS..."
|
log_info "Auto detecting OS..."
|
||||||
OS="$(detect_os)"
|
OS="$(detect_os)"
|
||||||
log_info "==> Detected OS: $OS"
|
log_info "Detected OS: $OS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$ARCH" != "auto" && "$ARCH" != "amd64" && "$ARCH" != "arm64" ]]; then
|
if [[ "$ARCH" != "auto" && "$ARCH" != "amd64" && "$ARCH" != "arm64" ]]; then
|
||||||
@ -1440,7 +1440,7 @@ devbox_init_command() {
|
|||||||
if grep -q avx2 /proc/cpuinfo; then
|
if grep -q avx2 /proc/cpuinfo; then
|
||||||
ARCH="amd64"
|
ARCH="amd64"
|
||||||
ARCH_MICRO="v3"
|
ARCH_MICRO="v3"
|
||||||
log_info "==> Detected AMD64 architecture."
|
log_info "Detected AMD64 architecture."
|
||||||
else
|
else
|
||||||
ARCH="amd64"
|
ARCH="amd64"
|
||||||
fi
|
fi
|
||||||
@ -1540,7 +1540,7 @@ devbox_init_command() {
|
|||||||
# Check if Installed the net-tools netstat under MacOS, WSL2 and Linux OS
|
# Check if Installed the net-tools netstat under MacOS, WSL2 and Linux OS
|
||||||
if [[ "$OS" == "darwin" || "$OS" == "wsl2" || "$OS" == "linux" ]]; then
|
if [[ "$OS" == "darwin" || "$OS" == "wsl2" || "$OS" == "linux" ]]; then
|
||||||
if ! command -v netstat &>/dev/null; then
|
if ! command -v netstat &>/dev/null; then
|
||||||
log_info "==> Installing net-tools package..."
|
log_info "Installing net-tools package..."
|
||||||
if [[ "$OS" == "darwin" ]]; then
|
if [[ "$OS" == "darwin" ]]; then
|
||||||
brew install net-tools
|
brew install net-tools
|
||||||
elif [[ "$OS" == "wsl2" ]]; then
|
elif [[ "$OS" == "wsl2" ]]; then
|
||||||
@ -1553,11 +1553,11 @@ devbox_init_command() {
|
|||||||
exit_with_message " Failed install net-tools package on OS: $OS, please install it manually." 1
|
exit_with_message " Failed install net-tools package on OS: $OS, please install it manually." 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
log_info "==> net-tools package already installed."
|
log_info "net-tools package already installed."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log_info "==> Checking if the ports are in use..."
|
log_info "Checking if the ports are in use..."
|
||||||
# Check if the gittea, mongodb, rabbitmq, redis ports are in use
|
# Check if the gittea, mongodb, rabbitmq, redis ports are in use
|
||||||
if netstat -tuln | grep -q ":3000"; then
|
if netstat -tuln | grep -q ":3000"; then
|
||||||
exit_with_message " gitea port 3000 is already in use, please stop the service." 1
|
exit_with_message " gitea port 3000 is already in use, please stop the service." 1
|
||||||
@ -1579,16 +1579,16 @@ devbox_init_command() {
|
|||||||
exit_with_message " redis port 6379 is already in use, please stop the service." 1
|
exit_with_message " redis port 6379 is already in use, please stop the service." 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log_info "==> Checking if the ports are in use... Done."
|
log_info "Checking if the ports are in use... Done."
|
||||||
|
|
||||||
local devbox_full_image="${DEVBOX_REPO}/${DEVBOX_IMAGE}:${DEVBOX_TAG}"
|
local devbox_full_image="${DEVBOX_REPO}/${DEVBOX_IMAGE}:${DEVBOX_TAG}"
|
||||||
|
|
||||||
# Check local and remote version. User doesn’t need to rebuild devbox if local version is consistent with remote version
|
# Check local and remote version. User doesn’t need to rebuild devbox if local version is consistent with remote version
|
||||||
if [[ -n "$DEVBOX_REPO" && -n "$DEVBOX_IMAGE" && -n "$DEVBOX_TAG" ]]; then
|
if [[ -n "$DEVBOX_REPO" && -n "$DEVBOX_IMAGE" && -n "$DEVBOX_TAG" ]]; then
|
||||||
if docker images --format '{{.Repository}}:{{.Tag}}' | grep -q "^${DEVBOX_REPO}/${DEVBOX_IMAGE}:${DEVBOX_TAG}\$"; then
|
if docker images --format '{{.Repository}}:{{.Tag}}' | grep -q "^${DEVBOX_REPO}/${DEVBOX_IMAGE}:${DEVBOX_TAG}\$"; then
|
||||||
log_info "==> DevBox image $devbox_full_image already exists."
|
log_info "DevBox image $devbox_full_image already exists."
|
||||||
else
|
else
|
||||||
log_info "==> Pulling DevBox image $devbox_full_image..."
|
log_info "Pulling DevBox image $devbox_full_image..."
|
||||||
docker pull "$devbox_full_image"
|
docker pull "$devbox_full_image"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@ -1598,7 +1598,7 @@ devbox_init_command() {
|
|||||||
# If container with same name exists, remove it
|
# If container with same name exists, remove it
|
||||||
if docker ps -a --format '{{.Names}}' | grep -q "^${DEVBOX_NAME}\$"; then
|
if docker ps -a --format '{{.Names}}' | grep -q "^${DEVBOX_NAME}\$"; then
|
||||||
if [[ -n "$FORCE_INIT" ]]; then
|
if [[ -n "$FORCE_INIT" ]]; then
|
||||||
log_info "==> Removing existing container named $DEVBOX_NAME ..."
|
log_info "Removing existing container named $DEVBOX_NAME ..."
|
||||||
docker stop "$DEVBOX_NAME" &>/dev/null || true
|
docker stop "$DEVBOX_NAME" &>/dev/null || true
|
||||||
docker rm "$DEVBOX_NAME" &>/dev/null || true
|
docker rm "$DEVBOX_NAME" &>/dev/null || true
|
||||||
|
|
||||||
@ -1619,10 +1619,10 @@ devbox_init_command() {
|
|||||||
log_info ' Starting DevBox environment initialization...'
|
log_info ' Starting DevBox environment initialization...'
|
||||||
# Check if docker network create devbox_freeleaps2-network
|
# Check if docker network create devbox_freeleaps2-network
|
||||||
if ! docker network ls | grep -q "$DEVBOX_FREELEAPS2_NETWORK"; then
|
if ! docker network ls | grep -q "$DEVBOX_FREELEAPS2_NETWORK"; then
|
||||||
log_info "==> Creating Docker network: $DEVBOX_FREELEAPS2_NETWORK"
|
log_info "Creating Docker network: $DEVBOX_FREELEAPS2_NETWORK"
|
||||||
docker network create "$DEVBOX_FREELEAPS2_NETWORK"
|
docker network create "$DEVBOX_FREELEAPS2_NETWORK"
|
||||||
else
|
else
|
||||||
log_info "==> Docker network devbox_freeleaps2-network already exists."
|
log_info "Docker network devbox_freeleaps2-network already exists."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if use custom repository
|
# Check if use custom repository
|
||||||
@ -1666,7 +1666,7 @@ devbox_init_command() {
|
|||||||
ENCODEING_FREELEAPS_USERNAME=$(url_encode "$FREELEAPS_USERNAME")
|
ENCODEING_FREELEAPS_USERNAME=$(url_encode "$FREELEAPS_USERNAME")
|
||||||
ENCODEING_FREELEAPS_PASSWORD=$(url_encode "$FREELEAPS_PASSWORD")
|
ENCODEING_FREELEAPS_PASSWORD=$(url_encode "$FREELEAPS_PASSWORD")
|
||||||
# Test if the user can access the freeleaps.com repository
|
# Test if the user can access the freeleaps.com repository
|
||||||
log_info "==> Testing access to freeleaps.com repository..."
|
log_info "Testing access to freeleaps.com repository..."
|
||||||
if ! git ls-remote "https://$ENCODEING_FREELEAPS_USERNAME:$ENCODEING_FREELEAPS_PASSWORD@freeleaps.com:3443/products/freeleaps.git" &>/dev/null; then
|
if ! git ls-remote "https://$ENCODEING_FREELEAPS_USERNAME:$ENCODEING_FREELEAPS_PASSWORD@freeleaps.com:3443/products/freeleaps.git" &>/dev/null; then
|
||||||
exit_with_message " Failed to access freeleaps.com repository. Please check your username and password." 1
|
exit_with_message " Failed to access freeleaps.com repository. Please check your username and password." 1
|
||||||
fi
|
fi
|
||||||
@ -1708,7 +1708,7 @@ devbox_init_command() {
|
|||||||
|
|
||||||
# Check if the custom repository is a git repository
|
# Check if the custom repository is a git repository
|
||||||
# Test if the user can access the custom repository
|
# Test if the user can access the custom repository
|
||||||
log_info "==> Testing access to custom repository..."
|
log_info "Testing access to custom repository..."
|
||||||
if ! git ls-remote "$USE_CUSTOM_REPOSITORY" &>/dev/null; then
|
if ! git ls-remote "$USE_CUSTOM_REPOSITORY" &>/dev/null; then
|
||||||
exit_with_message " Failed to access custom repository. Please check the repository URL." 1
|
exit_with_message " Failed to access custom repository. Please check the repository URL." 1
|
||||||
fi
|
fi
|
||||||
@ -1751,7 +1751,7 @@ devbox_init_command() {
|
|||||||
# 6. linbwang: pull and start other components
|
# 6. linbwang: pull and start other components
|
||||||
# -------------------------------------------------------------------
|
# -------------------------------------------------------------------
|
||||||
|
|
||||||
log_info "==> [INIT] Starting Freeleaps services... Use Local component $USE_LOCAL_COMPONENT_VAL"
|
log_info "[INIT] Starting Freeleaps services... Use Local component $USE_LOCAL_COMPONENT_VAL"
|
||||||
|
|
||||||
export ARCH="$ARCH"
|
export ARCH="$ARCH"
|
||||||
export WORKING_HOME="$WORKING_HOME"
|
export WORKING_HOME="$WORKING_HOME"
|
||||||
@ -1768,10 +1768,10 @@ if [[ -n "$USE_CUSTOM_REPOSITORY" ]]; then
|
|||||||
echo
|
echo
|
||||||
echo "==========================================================="
|
echo "==========================================================="
|
||||||
echo
|
echo
|
||||||
log_info "==> [INIT] Custom repository initialization completed."
|
log_info "[INIT] Custom repository initialization completed."
|
||||||
log_info "==> Custom repository is located at: ${WORKING_HOME}/${CUSTOM_FOLDER_NAME}"
|
log_info "Custom repository is located at: ${WORKING_HOME}/${CUSTOM_FOLDER_NAME}"
|
||||||
log_info "==> Custom repository URL: $ECHO_USE_CUSTOM_REPOSITORY"
|
log_info "Custom repository URL: $ECHO_USE_CUSTOM_REPOSITORY"
|
||||||
log_info "==> Custom repository is ready for use."
|
log_info "Custom repository is ready for use."
|
||||||
echo
|
echo
|
||||||
echo "==========================================================="
|
echo "==========================================================="
|
||||||
echo
|
echo
|
||||||
@ -1780,7 +1780,7 @@ if [[ -n "$USE_CUSTOM_REPOSITORY" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if docker-compose command exists
|
# Check if docker-compose command exists
|
||||||
log_info "==> Cehck if docker-compose command exists"
|
log_info "Cehck if docker-compose command exists"
|
||||||
# Check if docker-compose is installed
|
# Check if docker-compose is installed
|
||||||
local DC_CMD
|
local DC_CMD
|
||||||
if command -v docker-compose >/dev/null 2>&1; then
|
if command -v docker-compose >/dev/null 2>&1; then
|
||||||
@ -1798,7 +1798,7 @@ fi
|
|||||||
|
|
||||||
# If USE_LOCAL_COMPONENT is true, then use local components
|
# If USE_LOCAL_COMPONENT is true, then use local components
|
||||||
if [[ $USE_LOCAL_COMPONENT_VAL == true ]]; then
|
if [[ $USE_LOCAL_COMPONENT_VAL == true ]]; then
|
||||||
log_info ' ===> Using local components for Freeleaps services.'
|
log_info ' = Using local components for Freeleaps services.'
|
||||||
|
|
||||||
export DEVSVC_IMAGE_TAG="$component_tag"
|
export DEVSVC_IMAGE_TAG="$component_tag"
|
||||||
export CONTENT_IMAGE_TAG="$component_tag"
|
export CONTENT_IMAGE_TAG="$component_tag"
|
||||||
@ -1856,7 +1856,7 @@ if [[ $USE_LOCAL_COMPONENT_VAL == true ]]; then
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Start Gitea, MongoDB, RabbitMQ and other components containers
|
# Start Gitea, MongoDB, RabbitMQ and other components containers
|
||||||
log_info "===> start Gitea, MongoDB, RabbitMQ and other components containers"
|
log_info "start Gitea, MongoDB, RabbitMQ and other components containers"
|
||||||
$DC_CMD -f docker-compose.yaml up -d mongodb rabbitmq gitea redis "${start_components[@]}"
|
$DC_CMD -f docker-compose.yaml up -d mongodb rabbitmq gitea redis "${start_components[@]}"
|
||||||
|
|
||||||
gitea_container_id=$(docker ps --no-trunc -a --filter "name=^freeleaps2-gitea$" --format "{{.ID}}")
|
gitea_container_id=$(docker ps --no-trunc -a --filter "name=^freeleaps2-gitea$" --format "{{.ID}}")
|
||||||
@ -1887,9 +1887,9 @@ if [[ $USE_LOCAL_COMPONENT_VAL == true ]]; then
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
echo '============================================'
|
echo '============================================================'
|
||||||
log_info ' ===> Using online components for Freeleaps services.'
|
log_info 'Using online components for Freeleaps services.'
|
||||||
echo '============================================'
|
echo '============================================================'
|
||||||
# Start Gitea, MongoDB, RabbitMQ containers
|
# Start Gitea, MongoDB, RabbitMQ containers
|
||||||
$DC_CMD -f docker-compose.yaml up -d mongodb rabbitmq redis
|
$DC_CMD -f docker-compose.yaml up -d mongodb rabbitmq redis
|
||||||
|
|
||||||
@ -1979,20 +1979,20 @@ devbox_deinit_command() {
|
|||||||
local CLEAR_ALL="$(get_arg '--clear-all')"
|
local CLEAR_ALL="$(get_arg '--clear-all')"
|
||||||
|
|
||||||
# print the parameters
|
# print the parameters
|
||||||
log_info "==> Deinitialization parameters:"
|
log_info "Deinitialization parameters:"
|
||||||
log_info " WORKING_HOME = $WORKING_HOME"
|
log_info " WORKING_HOME = $WORKING_HOME"
|
||||||
log_info " CLEAR_LOGS = $CLEAR_LOGS"
|
log_info " CLEAR_LOGS = $CLEAR_LOGS"
|
||||||
log_info " CLEAR_REPO = $CLEAR_REPO"
|
log_info " CLEAR_REPO = $CLEAR_REPO"
|
||||||
log_info " CLEAR_ALL = $CLEAR_ALL"
|
log_info " CLEAR_ALL = $CLEAR_ALL"
|
||||||
|
|
||||||
log_info "==> Starting DevBox deinitialization..."
|
log_info "Starting DevBox deinitialization..."
|
||||||
|
|
||||||
# Stop and remove DevBox container
|
# Stop and remove DevBox container
|
||||||
|
|
||||||
if [[ -f "$WORKING_HOME/.devbox-instance" ]]; then
|
if [[ -f "$WORKING_HOME/.devbox-instance" ]]; then
|
||||||
local container_id
|
local container_id
|
||||||
container_id=$(cat "$WORKING_HOME/.devbox-instance")
|
container_id=$(cat "$WORKING_HOME/.devbox-instance")
|
||||||
log_info "==> Stopping and removing DevBox container: $container_id"
|
log_info "Stopping and removing DevBox container: $container_id"
|
||||||
docker stop "$container_id" &>/dev/null || true
|
docker stop "$container_id" &>/dev/null || true
|
||||||
docker rm "$container_id" &>/dev/null || true
|
docker rm "$container_id" &>/dev/null || true
|
||||||
|
|
||||||
@ -2006,14 +2006,14 @@ devbox_deinit_command() {
|
|||||||
rm -f "$WORKING_HOME/.backend.pid"
|
rm -f "$WORKING_HOME/.backend.pid"
|
||||||
rm -f "$WORKING_HOME/.frontend.pid"
|
rm -f "$WORKING_HOME/.frontend.pid"
|
||||||
else
|
else
|
||||||
echo "==> DevBox container is not running."
|
log_info "DevBox container is not running."
|
||||||
if [[ -n "$(docker ps -a --format '{{.Names}}' | grep "^devbox\$")" ]]; then
|
if [[ -n "$(docker ps -a --format '{{.Names}}' | grep "^devbox\$")" ]]; then
|
||||||
# Get the container ID of the DevBox container
|
# Get the container ID of the DevBox container
|
||||||
echo "==> DevBox container is stopped."
|
log_info "DevBox container is stopped."
|
||||||
local container_id
|
local container_id
|
||||||
container_id=$(docker ps -a --format '{{.Names}}' | grep "^devbox\$")
|
container_id=$(docker ps -a --format '{{.Names}}' | grep "^devbox\$")
|
||||||
|
|
||||||
log_info "==> Stopping and removing DevBox container: $container_id"
|
log_info "Stopping and removing DevBox container: $container_id"
|
||||||
docker stop "$container_id" &>/dev/null || true
|
docker stop "$container_id" &>/dev/null || true
|
||||||
docker rm "$container_id" &>/dev/null || true
|
docker rm "$container_id" &>/dev/null || true
|
||||||
fi
|
fi
|
||||||
@ -2022,13 +2022,13 @@ devbox_deinit_command() {
|
|||||||
if [[ -f "$WORKING_HOME/.gitea-instance" ]]; then
|
if [[ -f "$WORKING_HOME/.gitea-instance" ]]; then
|
||||||
local gitea_container_id
|
local gitea_container_id
|
||||||
gitea_container_id=$(cat "$WORKING_HOME/.gitea-instance")
|
gitea_container_id=$(cat "$WORKING_HOME/.gitea-instance")
|
||||||
log_info "==> Stopping and removing Gitea container: $gitea_container_id"
|
log_info "Stopping and removing Gitea container: $gitea_container_id"
|
||||||
docker stop "$gitea_container_id" &>/dev/null || true
|
docker stop "$gitea_container_id" &>/dev/null || true
|
||||||
docker rm "$gitea_container_id" &>/dev/null || true
|
docker rm "$gitea_container_id" &>/dev/null || true
|
||||||
|
|
||||||
# Check if the Gitea container is still running, then use docker compose down to stop and remove the container
|
# Check if the Gitea container is still running, then use docker compose down to stop and remove the container
|
||||||
if [[ -n "$(docker ps -a --format '{{.Names}}' | grep "^freeleaps2-gitea\$")" ]]; then
|
if [[ -n "$(docker ps -a --format '{{.Names}}' | grep "^freeleaps2-gitea\$")" ]]; then
|
||||||
log_info "==> Using docker-compose down to stop and remove Gitea container."
|
log_info "Using docker-compose down to stop and remove Gitea container."
|
||||||
$DC_CMD -f docker-compose.yaml down gitea
|
$DC_CMD -f docker-compose.yaml down gitea
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -2039,13 +2039,13 @@ devbox_deinit_command() {
|
|||||||
if [[ -f "$WORKING_HOME/.mongodb-instance" ]]; then
|
if [[ -f "$WORKING_HOME/.mongodb-instance" ]]; then
|
||||||
local mongodb_container_id
|
local mongodb_container_id
|
||||||
mongodb_container_id=$(cat "$WORKING_HOME/.mongodb-instance")
|
mongodb_container_id=$(cat "$WORKING_HOME/.mongodb-instance")
|
||||||
log_info "==> Stopping and removing MongoDB container: $mongodb_container_id"
|
log_info "Stopping and removing MongoDB container: $mongodb_container_id"
|
||||||
docker stop "$mongodb_container_id" &>/dev/null || true
|
docker stop "$mongodb_container_id" &>/dev/null || true
|
||||||
docker rm "$mongodb_container_id" &>/dev/null || true
|
docker rm "$mongodb_container_id" &>/dev/null || true
|
||||||
|
|
||||||
# Check if the MongoDB container is still running, then use docker compose down to stop and remove the container
|
# Check if the MongoDB container is still running, then use docker compose down to stop and remove the container
|
||||||
if [[ -n "$(docker ps -a --format '{{.Names}}' | grep "^freeleaps2-mongodb\$")" ]]; then
|
if [[ -n "$(docker ps -a --format '{{.Names}}' | grep "^freeleaps2-mongodb\$")" ]]; then
|
||||||
log_info "==> Using docker-compose down to stop and remove MongoDB container."
|
log_info "Using docker-compose down to stop and remove MongoDB container."
|
||||||
$DC_CMD -f docker-compose.yaml down mongodb
|
$DC_CMD -f docker-compose.yaml down mongodb
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -2055,13 +2055,13 @@ devbox_deinit_command() {
|
|||||||
if [[ -f "$WORKING_HOME/.redis-instance" ]]; then
|
if [[ -f "$WORKING_HOME/.redis-instance" ]]; then
|
||||||
local redis_container_id
|
local redis_container_id
|
||||||
redis_container_id=$(cat "$WORKING_HOME/.redis-instance")
|
redis_container_id=$(cat "$WORKING_HOME/.redis-instance")
|
||||||
log_info "==> Stopping and removing Redis container: $redis_container_id"
|
log_info "Stopping and removing Redis container: $redis_container_id"
|
||||||
docker stop "$redis_container_id" &>/dev/null || true
|
docker stop "$redis_container_id" &>/dev/null || true
|
||||||
docker rm "$redis_container_id" &>/dev/null || true
|
docker rm "$redis_container_id" &>/dev/null || true
|
||||||
|
|
||||||
# Check if the Redis container is still running, then use docker compose down to stop and remove the container
|
# Check if the Redis container is still running, then use docker compose down to stop and remove the container
|
||||||
if [[ -n "$(docker ps -a --format '{{.Names}}' | grep "^freeleaps2-redis\$")" ]]; then
|
if [[ -n "$(docker ps -a --format '{{.Names}}' | grep "^freeleaps2-redis\$")" ]]; then
|
||||||
log_info "==> Using docker-compose down to stop and remove Redis container."
|
log_info "Using docker-compose down to stop and remove Redis container."
|
||||||
$DC_CMD -f docker-compose.yaml down redis
|
$DC_CMD -f docker-compose.yaml down redis
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -2072,13 +2072,13 @@ devbox_deinit_command() {
|
|||||||
if [[ -f "$WORKING_HOME/.rabbitmq-instance" ]]; then
|
if [[ -f "$WORKING_HOME/.rabbitmq-instance" ]]; then
|
||||||
local rabbitmq_container_id
|
local rabbitmq_container_id
|
||||||
rabbitmq_container_id=$(cat "$WORKING_HOME/.rabbitmq-instance")
|
rabbitmq_container_id=$(cat "$WORKING_HOME/.rabbitmq-instance")
|
||||||
log_info "==> Stopping and removing RabbitMQ container: $rabbitmq_container_id"
|
log_info "Stopping and removing RabbitMQ container: $rabbitmq_container_id"
|
||||||
docker stop "$rabbitmq_container_id" &>/dev/null || true
|
docker stop "$rabbitmq_container_id" &>/dev/null || true
|
||||||
docker rm "$rabbitmq_container_id" &>/dev/null || true
|
docker rm "$rabbitmq_container_id" &>/dev/null || true
|
||||||
|
|
||||||
# Check if the RabbitMQ container is still running, then use docker compose down to stop and remove the container
|
# Check if the RabbitMQ container is still running, then use docker compose down to stop and remove the container
|
||||||
if [[ -n "$(docker ps -a --format '{{.Names}}' | grep "^freeleaps2-rabbitmq\$")" ]]; then
|
if [[ -n "$(docker ps -a --format '{{.Names}}' | grep "^freeleaps2-rabbitmq\$")" ]]; then
|
||||||
log_info "==> Using docker-compose down to stop and remove RabbitMQ container."
|
log_info "Using docker-compose down to stop and remove RabbitMQ container."
|
||||||
$DC_CMD -f docker-compose.yaml down rabbitmq
|
$DC_CMD -f docker-compose.yaml down rabbitmq
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -2091,13 +2091,13 @@ devbox_deinit_command() {
|
|||||||
if [[ -f "$WORKING_HOME/.${component}-instance" ]]; then
|
if [[ -f "$WORKING_HOME/.${component}-instance" ]]; then
|
||||||
local component_container_id
|
local component_container_id
|
||||||
component_container_id=$(cat "$WORKING_HOME/.${component}-instance")
|
component_container_id=$(cat "$WORKING_HOME/.${component}-instance")
|
||||||
log_info "==> Stopping and removing ${component} container: $component_container_id"
|
log_info "Stopping and removing ${component} container: $component_container_id"
|
||||||
docker stop "$component_container_id" &>/dev/null || true
|
docker stop "$component_container_id" &>/dev/null || true
|
||||||
docker rm "$component_container_id" &>/dev/null || true
|
docker rm "$component_container_id" &>/dev/null || true
|
||||||
|
|
||||||
# Check if the component is still running, then use docker compose down to stop and remove the container
|
# Check if the component is still running, then use docker compose down to stop and remove the container
|
||||||
if [[ -n "$(docker ps -a --format '{{.Names}}' | grep "^$component\$")" ]]; then
|
if [[ -n "$(docker ps -a --format '{{.Names}}' | grep "^$component\$")" ]]; then
|
||||||
log_info "==> Using docker-compose down to stop and remove $component container."
|
log_info "Using docker-compose down to stop and remove $component container."
|
||||||
$DC_CMD -f docker-compose.yaml down "$component"
|
$DC_CMD -f docker-compose.yaml down "$component"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -2108,7 +2108,7 @@ devbox_deinit_command() {
|
|||||||
|
|
||||||
# Clear the DevBox container logs
|
# Clear the DevBox container logs
|
||||||
if [[ "$CLEAR_LOGS" == "true" ]]; then
|
if [[ "$CLEAR_LOGS" == "true" ]]; then
|
||||||
log_info "==> Clearing logs in $WORKING_HOME/logs..."
|
log_info "Clearing logs in $WORKING_HOME/logs..."
|
||||||
if [[ -d "$WORKING_HOME/logs" ]]; then
|
if [[ -d "$WORKING_HOME/logs" ]]; then
|
||||||
uid=$(id -u)
|
uid=$(id -u)
|
||||||
gid=$(id -g)
|
gid=$(id -g)
|
||||||
@ -2117,19 +2117,19 @@ devbox_deinit_command() {
|
|||||||
mkdir -p "$WORKING_HOME/logs" 2>/dev/null || true
|
mkdir -p "$WORKING_HOME/logs" 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
log_info "==> Skipping log clearing."
|
log_info "Skipping log clearing."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Clear the source repository
|
# Clear the source repository
|
||||||
if [[ "$CLEAR_REPO" == "true" && -d "$WORKING_HOME/freeleaps" ]]; then
|
if [[ "$CLEAR_REPO" == "true" && -d "$WORKING_HOME/freeleaps" ]]; then
|
||||||
log_info "==> Deleting source repository at $WORKING_HOME/freeleaps"
|
log_info "Deleting source repository at $WORKING_HOME/freeleaps"
|
||||||
uid=$(id -u)
|
uid=$(id -u)
|
||||||
gid=$(id -g)
|
gid=$(id -g)
|
||||||
sudo chown -R ${uid}:${gid} "$WORKING_HOME/freeleaps"
|
sudo chown -R ${uid}:${gid} "$WORKING_HOME/freeleaps"
|
||||||
rm -rf "$WORKING_HOME/freeleaps" 2>/dev/null || true
|
rm -rf "$WORKING_HOME/freeleaps" 2>/dev/null || true
|
||||||
rmdir "$WORKING_HOME/freeleaps" 2>/dev/null || true
|
rmdir "$WORKING_HOME/freeleaps" 2>/dev/null || true
|
||||||
else
|
else
|
||||||
log_info "==> Skipping repository deletion."
|
log_info "Skipping repository deletion."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$CLEAR_LOGS" == "true" ]]; then
|
if [[ "$CLEAR_LOGS" == "true" ]]; then
|
||||||
@ -2138,7 +2138,7 @@ devbox_deinit_command() {
|
|||||||
log_warn " $WORKING_HOME/logs still exists after removal."
|
log_warn " $WORKING_HOME/logs still exists after removal."
|
||||||
rm -rf "$WORKING_HOME/logs"
|
rm -rf "$WORKING_HOME/logs"
|
||||||
else
|
else
|
||||||
log_info "==> Logs directory removed successfully."
|
log_info "Logs directory removed successfully."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -2151,7 +2151,7 @@ devbox_deinit_command() {
|
|||||||
REMOVE_WORKING_HOME=true
|
REMOVE_WORKING_HOME=true
|
||||||
|
|
||||||
# Remove the working home directory
|
# Remove the working home directory
|
||||||
log_info "==> Removing working home directory: $WORKING_HOME"
|
log_info "Removing working home directory: $WORKING_HOME"
|
||||||
if [[ -d "$WORKING_HOME" ]]; then
|
if [[ -d "$WORKING_HOME" ]]; then
|
||||||
uid=$(id -u)
|
uid=$(id -u)
|
||||||
gid=$(id -g)
|
gid=$(id -g)
|
||||||
@ -2159,10 +2159,10 @@ devbox_deinit_command() {
|
|||||||
rm -rf "$WORKING_HOME" 2>/dev/null || true
|
rm -rf "$WORKING_HOME" 2>/dev/null || true
|
||||||
rmdir "$WORKING_HOME" 2>/dev/null || true
|
rmdir "$WORKING_HOME" 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
log_info "==> Working home directory removed successfully."
|
log_info "Working home directory removed successfully."
|
||||||
else
|
else
|
||||||
REMOVE_WORKING_HOME=false
|
REMOVE_WORKING_HOME=false
|
||||||
log_info "==> Skipping working home directory removal."
|
log_info "Skipping working home directory removal."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -2177,7 +2177,7 @@ devbox_deinit_command() {
|
|||||||
# Remove the use-local-component file
|
# Remove the use-local-component file
|
||||||
rm -f "$WORKING_HOME/.use-local-component"
|
rm -f "$WORKING_HOME/.use-local-component"
|
||||||
|
|
||||||
log_info "==> DevBox deinitialization completed."
|
log_info "DevBox deinitialization completed."
|
||||||
}
|
}
|
||||||
|
|
||||||
# :command.function
|
# :command.function
|
||||||
@ -2217,10 +2217,10 @@ devbox_start_command() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$(lower "$USE_LOCAL_COMPONENT")" == "true" ]]; then
|
if [[ "$(lower "$USE_LOCAL_COMPONENT")" == "true" ]]; then
|
||||||
log_info "==> Using local components for Freeleaps services."
|
log_info "Using local components for Freeleaps services."
|
||||||
USE_LOCAL_COMPONENT="true"
|
USE_LOCAL_COMPONENT="true"
|
||||||
else
|
else
|
||||||
log_info "==> Using online components for Freeleaps services."
|
log_info "Using online components for Freeleaps services."
|
||||||
USE_LOCAL_COMPONENT="false"
|
USE_LOCAL_COMPONENT="false"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -2237,7 +2237,7 @@ devbox_start_command() {
|
|||||||
COMPONENTS=("mongodb" "rabbitmq" "devbox")
|
COMPONENTS=("mongodb" "rabbitmq" "devbox")
|
||||||
else
|
else
|
||||||
if [[ "$COMPONENT" == "devsvc" || "$COMPONENT" == "notification" || "$COMPONENT" == "content" || "$COMPONENT" == "central_storage" || "$COMPONENT" == "chat" || "$COMPONENT" == "authentication" ]]; then
|
if [[ "$COMPONENT" == "devsvc" || "$COMPONENT" == "notification" || "$COMPONENT" == "content" || "$COMPONENT" == "central_storage" || "$COMPONENT" == "chat" || "$COMPONENT" == "authentication" ]]; then
|
||||||
exit_with_message "ERROR: Remote component $COMPONENT cannot be restarted, please use local components." 1
|
exit_with_message "Remote component $COMPONENT cannot be restarted, please use local components." 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
COMPONENTS=("$COMPONENT")
|
COMPONENTS=("$COMPONENT")
|
||||||
@ -2248,7 +2248,7 @@ devbox_start_command() {
|
|||||||
for comp in "${COMPONENTS[@]}"; do
|
for comp in "${COMPONENTS[@]}"; do
|
||||||
case "$comp" in
|
case "$comp" in
|
||||||
"gitea" | "mongodb" | "rabbitmq" | "devbox" | "devsvc" | "notification" | "content" | "central_storage" | "chat" | "authentication")
|
"gitea" | "mongodb" | "rabbitmq" | "devbox" | "devsvc" | "notification" | "content" | "central_storage" | "chat" | "authentication")
|
||||||
log_info "==> Starting $comp service..."
|
log_info "Starting $comp service..."
|
||||||
# Check if the component container file exists
|
# Check if the component container file exists
|
||||||
local component_container_id_file_path="${WORKING_HOME}/.${comp}-instance"
|
local component_container_id_file_path="${WORKING_HOME}/.${comp}-instance"
|
||||||
if [[ ! -f "$component_container_id_file_path" ]]; then
|
if [[ ! -f "$component_container_id_file_path" ]]; then
|
||||||
@ -2256,15 +2256,15 @@ devbox_start_command() {
|
|||||||
else
|
else
|
||||||
local component_container_id=$(cat "$component_container_id_file_path")
|
local component_container_id=$(cat "$component_container_id_file_path")
|
||||||
if ! docker ps --no-trunc --format '{{.ID}}' | grep -q "^${component_container_id}\$"; then
|
if ! docker ps --no-trunc --format '{{.ID}}' | grep -q "^${component_container_id}\$"; then
|
||||||
log_info "==> $comp container is not running, starting container..."
|
log_info "$comp container is not running, starting container..."
|
||||||
# Start the container
|
# Start the container
|
||||||
if ! docker start "${component_container_id}"; then
|
if ! docker start "${component_container_id}"; then
|
||||||
log_error "Failed to start $comp container."
|
log_error "Failed to start $comp container."
|
||||||
else
|
else
|
||||||
log_info "==> $comp container started successfully."
|
log_info "$comp container started successfully."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
log_info "==> $comp container is already running."
|
log_info "$comp container is already running."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
@ -2287,7 +2287,7 @@ devbox_start_command() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
if docker ps --no-trunc --format '{{.ID}}' | grep -q "^${devbox_container_id}\$"; then
|
if docker ps --no-trunc --format '{{.ID}}' | grep -q "^${devbox_container_id}\$"; then
|
||||||
log_info "==> Starting Freeleaps frontend and backend services..."
|
log_info "Starting Freeleaps frontend and backend services..."
|
||||||
# Check if start backend service
|
# Check if start backend service
|
||||||
if [[ "${START_BACKEND}" == "true" ]]; then
|
if [[ "${START_BACKEND}" == "true" ]]; then
|
||||||
compile_backend_service
|
compile_backend_service
|
||||||
@ -2302,7 +2302,7 @@ devbox_start_command() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
success_message="==> Freeleaps services started successfully. "
|
success_message=" Freeleaps services started successfully. "
|
||||||
|
|
||||||
frontend_port=$(cat "${WORKING_HOME}/.devbox-frontend-port")
|
frontend_port=$(cat "${WORKING_HOME}/.devbox-frontend-port")
|
||||||
if [[ "${START_FRONTEND}" == "true" && "${START_BACKEND}" == "true" ]]; then
|
if [[ "${START_FRONTEND}" == "true" && "${START_BACKEND}" == "true" ]]; then
|
||||||
@ -2352,7 +2352,7 @@ devbox_stop_command() {
|
|||||||
if [[ -f "${WORKING_HOME}/.backend.pid" ]]; then
|
if [[ -f "${WORKING_HOME}/.backend.pid" ]]; then
|
||||||
stop_backend_service
|
stop_backend_service
|
||||||
else
|
else
|
||||||
log_info "==> Backend service is not running."
|
log_info "Backend service is not running."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -2361,7 +2361,7 @@ devbox_stop_command() {
|
|||||||
if [[ -f "${WORKING_HOME}/.frontend.pid" ]]; then
|
if [[ -f "${WORKING_HOME}/.frontend.pid" ]]; then
|
||||||
stop_frontend_service
|
stop_frontend_service
|
||||||
else
|
else
|
||||||
log_info "==> Frontend service is not running."
|
log_info "Frontend service is not running."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -2407,16 +2407,16 @@ devbox_stop_command() {
|
|||||||
local container_id
|
local container_id
|
||||||
container_id=$(cat "${WORKING_HOME}/.devbox-instance")
|
container_id=$(cat "${WORKING_HOME}/.devbox-instance")
|
||||||
if docker ps --no-trunc --format '{{.ID}}' | grep -q "^${container_id}\$"; then
|
if docker ps --no-trunc --format '{{.ID}}' | grep -q "^${container_id}\$"; then
|
||||||
log_info "==> Stopping devbox..."
|
log_info "Stopping devbox..."
|
||||||
docker stop "$container_id" &>/dev/null || true
|
docker stop "$container_id" &>/dev/null || true
|
||||||
# Remove the frontend and backend pid files
|
# Remove the frontend and backend pid files
|
||||||
rm -f "${WORKING_HOME}/.backend.pid"
|
rm -f "${WORKING_HOME}/.backend.pid"
|
||||||
rm -f "${WORKING_HOME}/.frontend.pid"
|
rm -f "${WORKING_HOME}/.frontend.pid"
|
||||||
else
|
else
|
||||||
log_info "==> DevBox container is not running."
|
log_info "DevBox container is not running."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
log_info "==> Backend service is not running."
|
log_info "Backend service is not running."
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@ -2425,13 +2425,13 @@ devbox_stop_command() {
|
|||||||
local container_id
|
local container_id
|
||||||
container_id=$(cat "${WORKING_HOME}/.${comp}-instance")
|
container_id=$(cat "${WORKING_HOME}/.${comp}-instance")
|
||||||
if docker ps --no-trunc --format '{{.ID}}' | grep -q "^${container_id}\$"; then
|
if docker ps --no-trunc --format '{{.ID}}' | grep -q "^${container_id}\$"; then
|
||||||
log_info "==> Stopping $comp service..."
|
log_info "Stopping $comp service..."
|
||||||
docker stop "$container_id" &>/dev/null || true
|
docker stop "$container_id" &>/dev/null || true
|
||||||
else
|
else
|
||||||
log_info "==> $comp service is not running."
|
log_info "$comp service is not running."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
log_info "==> $comp service is not running."
|
log_info "$comp service is not running."
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
@ -2440,14 +2440,14 @@ devbox_stop_command() {
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
exit_with_message "[INFO] Stopped Freeleaps services successfully. " 0
|
exit_with_message "Stopped Freeleaps services successfully. " 0
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# :command.function
|
# :command.function
|
||||||
devbox_status_command() {
|
devbox_status_command() {
|
||||||
|
|
||||||
log_info "==> Checking DevBox services status..."
|
log_info "Checking DevBox services status..."
|
||||||
local COMPONENT="$(get_arg '--component')"
|
local COMPONENT="$(get_arg '--component')"
|
||||||
local WORKING_HOME="$(get_arg '--working-home' "${HOME}/devbox")"
|
local WORKING_HOME="$(get_arg '--working-home' "${HOME}/devbox")"
|
||||||
|
|
||||||
@ -2474,7 +2474,7 @@ devbox_status_command() {
|
|||||||
for comp in "${COMPONENTS[@]}"; do
|
for comp in "${COMPONENTS[@]}"; do
|
||||||
case "$comp" in
|
case "$comp" in
|
||||||
"mongodb")
|
"mongodb")
|
||||||
log_info "==> Checking MongoDB status..."
|
log_info "Checking MongoDB status..."
|
||||||
if [[ -f "${WORKING_HOME}/.mongodb-instance" ]]; then
|
if [[ -f "${WORKING_HOME}/.mongodb-instance" ]]; then
|
||||||
local container_id
|
local container_id
|
||||||
container_id=$(cat "${WORKING_HOME}/.mongodb-instance")
|
container_id=$(cat "${WORKING_HOME}/.mongodb-instance")
|
||||||
@ -2489,7 +2489,7 @@ devbox_status_command() {
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
"rabbitmq")
|
"rabbitmq")
|
||||||
log_info "==> Checking RabbitMQ status..."
|
log_info "Checking RabbitMQ status..."
|
||||||
if [[ -f "${WORKING_HOME}/.rabbitmq-instance" ]]; then
|
if [[ -f "${WORKING_HOME}/.rabbitmq-instance" ]]; then
|
||||||
local container_id
|
local container_id
|
||||||
container_id=$(cat "${WORKING_HOME}/.rabbitmq-instance")
|
container_id=$(cat "${WORKING_HOME}/.rabbitmq-instance")
|
||||||
@ -2504,7 +2504,7 @@ devbox_status_command() {
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
"devbox")
|
"devbox")
|
||||||
log_info "==> Checking devbox service status..."
|
log_info "Checking devbox service status..."
|
||||||
if [[ -f "${WORKING_HOME}/.devbox-instance" ]]; then
|
if [[ -f "${WORKING_HOME}/.devbox-instance" ]]; then
|
||||||
local container_id
|
local container_id
|
||||||
container_id=$(cat "${WORKING_HOME}/.devbox-instance")
|
container_id=$(cat "${WORKING_HOME}/.devbox-instance")
|
||||||
@ -2519,7 +2519,7 @@ devbox_status_command() {
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
"devsvc" | "notification" | "content" | "central_storage" | "chat" | "authentication")
|
"devsvc" | "notification" | "content" | "central_storage" | "chat" | "authentication")
|
||||||
log_info "==> Checking $comp service status..."
|
log_info "Checking $comp service status..."
|
||||||
if [[ -f "${WORKING_HOME}/.${comp}-instance" ]]; then
|
if [[ -f "${WORKING_HOME}/.${comp}-instance" ]]; then
|
||||||
local container_id
|
local container_id
|
||||||
container_id=$(cat "${WORKING_HOME}/.${comp}-instance")
|
container_id=$(cat "${WORKING_HOME}/.${comp}-instance")
|
||||||
@ -2538,12 +2538,12 @@ devbox_status_command() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
exit_with_message "==> DevBox services status checked successfully." 0
|
exit_with_message " DevBox services status checked successfully." 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# :command.function
|
# :command.function
|
||||||
devbox_restart_command() {
|
devbox_restart_command() {
|
||||||
log_info "==> Restarting DevBox services..."
|
log_info "Restarting DevBox services..."
|
||||||
local COMPONENT="$(get_arg '--component')"
|
local COMPONENT="$(get_arg '--component')"
|
||||||
local WORKING_HOME="$(get_arg '--working-home' "${HOME}/devbox")"
|
local WORKING_HOME="$(get_arg '--working-home' "${HOME}/devbox")"
|
||||||
local FREELEAPS_ENDPOINT="$(get_arg '--freeleaps-endpoint')"
|
local FREELEAPS_ENDPOINT="$(get_arg '--freeleaps-endpoint')"
|
||||||
@ -2574,7 +2574,7 @@ devbox_restart_command() {
|
|||||||
devbox_container_id=$(cat "${WORKING_HOME}/.devbox-instance")
|
devbox_container_id=$(cat "${WORKING_HOME}/.devbox-instance")
|
||||||
log_info "docker ps --no-trunc --format ${devbox_container_id} "
|
log_info "docker ps --no-trunc --format ${devbox_container_id} "
|
||||||
if docker ps --no-trunc --format '{{.ID}}' | grep -q "${devbox_container_id}\$"; then
|
if docker ps --no-trunc --format '{{.ID}}' | grep -q "${devbox_container_id}\$"; then
|
||||||
log_info "==> Starting Freeleaps frontend and backend services..."
|
log_info "Starting Freeleaps frontend and backend services..."
|
||||||
# Check if start backend service
|
# Check if start backend service
|
||||||
if [[ "${START_BACKEND}" == "true" ]]; then
|
if [[ "${START_BACKEND}" == "true" ]]; then
|
||||||
stop_backend_service
|
stop_backend_service
|
||||||
@ -2609,14 +2609,14 @@ devbox_restart_command() {
|
|||||||
# Check if current environment is using local components
|
# Check if current environment is using local components
|
||||||
USE_LOCAL_COMPONENT=$(cat "${WORKING_HOME}/.use-local-component" 2>/dev/null || true)
|
USE_LOCAL_COMPONENT=$(cat "${WORKING_HOME}/.use-local-component" 2>/dev/null || true)
|
||||||
if [[ "$USE_LOCAL_COMPONENT" == "true" ]]; then
|
if [[ "$USE_LOCAL_COMPONENT" == "true" ]]; then
|
||||||
log_info "==> Using local components..."
|
log_info "Using local components..."
|
||||||
if [[ -z "$COMPONENT" ]]; then
|
if [[ -z "$COMPONENT" ]]; then
|
||||||
COMPONENTS=("gitea" "mongodb" "rabbitmq" "devbox" "devsvc" "notification" "content" "central_storage" "chat" "authentication")
|
COMPONENTS=("gitea" "mongodb" "rabbitmq" "devbox" "devsvc" "notification" "content" "central_storage" "chat" "authentication")
|
||||||
else
|
else
|
||||||
COMPONENTS=("$COMPONENT")
|
COMPONENTS=("$COMPONENT")
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
log_info "==> Using remote components..."
|
log_info "Using remote components..."
|
||||||
if [[ -z "$COMPONENT" ]]; then
|
if [[ -z "$COMPONENT" ]]; then
|
||||||
COMPONENTS=("mongodb" "rabbitmq" "devbox")
|
COMPONENTS=("mongodb" "rabbitmq" "devbox")
|
||||||
else
|
else
|
||||||
@ -2635,14 +2635,14 @@ devbox_restart_command() {
|
|||||||
if [[ -f "${WORKING_HOME}/.devbox-instance" ]]; then
|
if [[ -f "${WORKING_HOME}/.devbox-instance" ]]; then
|
||||||
local container_id
|
local container_id
|
||||||
container_id=$(cat "${WORKING_HOME}/.devbox-instance")
|
container_id=$(cat "${WORKING_HOME}/.devbox-instance")
|
||||||
log_info "==> Stopping devbox service..."
|
log_info "Stopping devbox service..."
|
||||||
docker stop "$container_id" &>/dev/null || true
|
docker stop "$container_id" &>/dev/null || true
|
||||||
|
|
||||||
# Remove the frontend and backend pid files
|
# Remove the frontend and backend pid files
|
||||||
rm -f "${WORKING_HOME}/.backend.pid"
|
rm -f "${WORKING_HOME}/.backend.pid"
|
||||||
rm -f "${WORKING_HOME}/.frontend.pid"
|
rm -f "${WORKING_HOME}/.frontend.pid"
|
||||||
else
|
else
|
||||||
log_info "==> Devbox is not running."
|
log_info "Devbox is not running."
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@ -2651,10 +2651,10 @@ devbox_restart_command() {
|
|||||||
if [[ -f "${WORKING_HOME}/.${comp}-instance" ]]; then
|
if [[ -f "${WORKING_HOME}/.${comp}-instance" ]]; then
|
||||||
local container_id
|
local container_id
|
||||||
container_id=$(cat "${WORKING_HOME}/.${comp}-instance")
|
container_id=$(cat "${WORKING_HOME}/.${comp}-instance")
|
||||||
log_info "==> Stopping $comp service..."
|
log_info "Stopping $comp service..."
|
||||||
docker stop "$container_id" &>/dev/null || true
|
docker stop "$container_id" &>/dev/null || true
|
||||||
else
|
else
|
||||||
log_info "==> $comp service is not running."
|
log_info "$comp service is not running."
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
@ -2667,13 +2667,13 @@ devbox_restart_command() {
|
|||||||
for comp in "${COMPONENTS[@]}"; do
|
for comp in "${COMPONENTS[@]}"; do
|
||||||
case "$comp" in
|
case "$comp" in
|
||||||
"gitea" | "mongodb" | "rabbitmq" | "devbox" | "devsvc" | "notification" | "content" | "central_storage" | "chat" | "authentication")
|
"gitea" | "mongodb" | "rabbitmq" | "devbox" | "devsvc" | "notification" | "content" | "central_storage" | "chat" | "authentication")
|
||||||
log_info "==> Restarting $comp service..."
|
log_info "Restarting $comp service..."
|
||||||
if [[ -f "${WORKING_HOME}/.${comp}-instance" ]]; then
|
if [[ -f "${WORKING_HOME}/.${comp}-instance" ]]; then
|
||||||
local container_id
|
local container_id
|
||||||
container_id=$(cat "${WORKING_HOME}/.${comp}-instance")
|
container_id=$(cat "${WORKING_HOME}/.${comp}-instance")
|
||||||
docker start "$container_id" &>/dev/null || true
|
docker start "$container_id" &>/dev/null || true
|
||||||
else
|
else
|
||||||
log_info "==> $comp service is not running."
|
log_info "$comp service is not running."
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
@ -2682,7 +2682,7 @@ devbox_restart_command() {
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
exit_with_message "==> DevBox services restarted successfully." 0
|
exit_with_message " DevBox services restarted successfully." 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# :command.parse_requirements
|
# :command.parse_requirements
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user