forked from freeleaps/freeleaps-pub
Update for change script to support bash 3
This commit is contained in:
parent
59dafb8f87
commit
a711c42483
@ -3,8 +3,8 @@
|
|||||||
# Modifying it manually is not recommended
|
# Modifying it manually is not recommended
|
||||||
|
|
||||||
# :wrapper.bash3_bouncer
|
# :wrapper.bash3_bouncer
|
||||||
if [[ "${BASH_VERSINFO:-0}" -lt 4 ]]; then
|
if [[ "${BASH_VERSINFO:-0}" -lt 3 ]]; then
|
||||||
printf "bash version 4 or higher is required\n" >&2
|
printf "bash version 3 or higher is required\n" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -15,6 +15,40 @@ version_command() {
|
|||||||
echo "$version"
|
echo "$version"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
upper() {
|
||||||
|
echo "$1" | tr '[:lower:]' '[:upper:]'
|
||||||
|
}
|
||||||
|
|
||||||
|
lower() {
|
||||||
|
echo "$1" | tr '[:upper:]' '[:lower:]'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Add a key-value pair to the args array
|
||||||
|
add_arg() {
|
||||||
|
local key="$1"
|
||||||
|
local value="$2"
|
||||||
|
args_keys+=("$key")
|
||||||
|
args_values+=("$value")
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get the value of a key from the args array
|
||||||
|
|
||||||
|
get_arg() {
|
||||||
|
local key="$1"
|
||||||
|
local default="${2:-}"
|
||||||
|
local i
|
||||||
|
for i in "${!args_keys[@]}"; do
|
||||||
|
if [ "${args_keys[$i]}" = "$key" ]; then
|
||||||
|
echo "${args_values[$i]}"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "$default"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# :command.usage
|
# :command.usage
|
||||||
devbox_usage() {
|
devbox_usage() {
|
||||||
printf "devbox - DevBox Command Line Tool\n\n"
|
printf "devbox - DevBox Command Line Tool\n\n"
|
||||||
@ -492,35 +526,56 @@ normalize_input() {
|
|||||||
|
|
||||||
# :command.inspect_args
|
# :command.inspect_args
|
||||||
inspect_args() {
|
inspect_args() {
|
||||||
if ((${#args[@]})); then
|
# Check and output the simulated args associative array (using args_keys and args_values)
|
||||||
readarray -t sorted_keys < <(printf '%s\n' "${!args[@]}" | sort)
|
if [ ${#args_keys[@]} -gt 0 ]; then
|
||||||
echo args:
|
# 利用 printf 和 sort 对键进行排序
|
||||||
for k in "${sorted_keys[@]}"; do
|
sorted_keys=$(printf "%s\n" "${args_keys[@]}" | sort)
|
||||||
echo "- \${args[$k]} = ${args[$k]}"
|
echo "args:"
|
||||||
|
for key in $sorted_keys; do
|
||||||
|
value=""
|
||||||
|
# Find the value based on the key
|
||||||
|
for i in `seq 0 $((${#args_keys[@]} - 1))`; do
|
||||||
|
if [ "${args_keys[$i]}" = "$key" ]; then
|
||||||
|
value="${args_values[$i]}"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
echo args: none
|
echo "args: none"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ((${#deps[@]})); then
|
# Check and output the simulated deps associative array (using deps_keys and deps_values)
|
||||||
readarray -t sorted_keys < <(printf '%s\n' "${!deps[@]}" | sort)
|
if [ ${#deps_keys[@]} -gt 0 ]; then
|
||||||
|
sorted_keys=$(printf "%s\n" "${deps_keys[@]}" | sort)
|
||||||
echo
|
echo
|
||||||
echo deps:
|
echo "deps:"
|
||||||
for k in "${sorted_keys[@]}"; do
|
for key in $sorted_keys; do
|
||||||
echo "- \${deps[$k]} = ${deps[$k]}"
|
value=""
|
||||||
|
for i in `seq 0 $((${#deps_keys[@]} - 1))`; do
|
||||||
|
if [ "${deps_keys[$i]}" = "$key" ]; then
|
||||||
|
value="${deps_values[$i]}"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "- \$deps[$key] = $value"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ((${#env_var_names[@]})); then
|
# Check and output the simulated env_vars associative array (using env_var_names)
|
||||||
readarray -t sorted_names < <(printf '%s\n' "${env_var_names[@]}" | sort)
|
if [ ${#env_var_names[@]} -gt 0 ]; then
|
||||||
|
sorted_names=$(printf "%s\n" "${env_var_names[@]}" | sort)
|
||||||
echo
|
echo
|
||||||
echo "environment variables:"
|
echo "environment variables:"
|
||||||
for k in "${sorted_names[@]}"; do
|
for name in $sorted_names; do
|
||||||
echo "- \$$k = ${!k:-}"
|
# Look up the value based on the name
|
||||||
|
echo "- \$${name} = ${!name:-}"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
install_docker() {
|
install_docker() {
|
||||||
echo "[INFO] Checking Docker installation..."
|
echo "[INFO] Checking Docker installation..."
|
||||||
|
|
||||||
@ -730,6 +785,23 @@ start_local_rabbitMQ(){
|
|||||||
echo "[INFO] Completed RabbitMQ container..."
|
echo "[INFO] Completed RabbitMQ container..."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 定义键和值数组
|
||||||
|
local_components_ports_keys=("devsvc" "payment" "content" "central_storage" "authentication")
|
||||||
|
local_components_ports_values=("8007" "8006" "8013" "8005" "8004")
|
||||||
|
|
||||||
|
# 根据组件名查找对应的端口
|
||||||
|
get_port() {
|
||||||
|
local comp="$1"
|
||||||
|
local port=""
|
||||||
|
for i in "${!local_components_ports_keys[@]}"; do
|
||||||
|
if [ "${local_components_ports_keys[i]}" = "$comp" ]; then
|
||||||
|
port="${local_components_ports_values[i]}"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "$port"
|
||||||
|
}
|
||||||
|
|
||||||
# :command.command_functions
|
# :command.command_functions
|
||||||
# :command.function
|
# :command.function
|
||||||
devbox_init_command() {
|
devbox_init_command() {
|
||||||
@ -779,45 +851,46 @@ devbox_init_command() {
|
|||||||
|
|
||||||
# --force flag to overwrite existing resources
|
# --force flag to overwrite existing resources
|
||||||
local FORCE_INIT="${args_force}"
|
local FORCE_INIT="${args_force}"
|
||||||
local OS="${args['--os']}"
|
|
||||||
local ARCH="${args['--arch']}"
|
|
||||||
local DEVBOX_NAME="${args['--devbox-container-name']}"
|
|
||||||
local DEVBOX_PORT="${args['--devbox-container-port']}"
|
|
||||||
local DEVBOX_FRONTEND_PORT="${args['--devbox-frontend-port']}"
|
|
||||||
local DEVBOX_BACKEND_PORT="${args['--devbox-backend-port']}"
|
|
||||||
local DEVBOX_REPO="${args['--devbox-image-repo']}"
|
|
||||||
local DEVBOX_IMAGE="${args['--devbox-image-name']}"
|
|
||||||
local DEVBOX_TAG="${args['--devbox-image-tag']}"
|
|
||||||
local WORKING_HOME="${args['--working-home']:-${WORKING_HOME:-${HOME}/.devbox}}"
|
|
||||||
local FREELEAPS_USERNAME="${args['--freeleaps-username']}"
|
|
||||||
local FREELEAPS_PASSWORD="${args['--freeleaps-password']}"
|
|
||||||
local USE_LOCAL_COMPONENT="${args['--use-local-component']}"
|
|
||||||
local DEVSVC_REPO="${args['--devsvc-image-repo']}"
|
|
||||||
local DEVSVC_IMAGE="${args['--devsvc-image-name']}"
|
|
||||||
local DEVSVC_TAG="${args['--devsvc-image-tag']}"
|
|
||||||
local PAYMENT_REPO="${args['--payment-image-repo']}"
|
|
||||||
local PAYMENT_IMAGE="${args['--payment-image-name']}"
|
|
||||||
local PAYMENT_TAG="${args['--payment-image-tag']}"
|
|
||||||
local CONTENT_REPO="${args['--content-image-repo']}"
|
|
||||||
local CONTENT_IMAGE="${args['--content-image-name']}"
|
|
||||||
local CONTENT_TAG="${args['--content-image-tag']}"
|
|
||||||
local CENTRAL_STORAGE_REPO="${args['--central_storage-image-repo']}"
|
|
||||||
local CENTRAL_STORAGE_IMAGE="${args['--central_storage-image-name']}"
|
|
||||||
local CENTRAL_STORAGE_TAG="${args['--central_storage-image-tag']}"
|
|
||||||
local AUTHENTICATION_REPO="${args['--authentication-image-repo']}"
|
|
||||||
local AUTHENTICATION_IMAGE="${args['--authentication-image-name']}"
|
|
||||||
local AUTHENTICATION_TAG="${args['--authentication-image-tag']}"
|
|
||||||
|
|
||||||
local FORCE_INIT="${args['--force']}"
|
local OS="$(get_arg '--os')"
|
||||||
|
local ARCH="$(get_arg '--arch')"
|
||||||
|
local DEVBOX_NAME="$(get_arg '--devbox-container-name')"
|
||||||
|
local DEVBOX_PORT="$(get_arg '--devbox-container-port')"
|
||||||
|
local DEVBOX_FRONTEND_PORT="$(get_arg '--devbox-frontend-port')"
|
||||||
|
local DEVBOX_BACKEND_PORT="$(get_arg '--devbox-backend-port')"
|
||||||
|
local DEVBOX_REPO="$(get_arg '--devbox-image-repo')"
|
||||||
|
local DEVBOX_IMAGE="$(get_arg '--devbox-image-name')"
|
||||||
|
local DEVBOX_TAG="$(get_arg '--devbox-image-tag')"
|
||||||
|
local WORKING_HOME="$(get_arg '--working-home' "${WORKING_HOME:-${HOME}/.devbox}")"
|
||||||
|
local FREELEAPS_USERNAME="$(get_arg '--freeleaps-username')"
|
||||||
|
local FREELEAPS_PASSWORD="$(get_arg '--freeleaps-password')"
|
||||||
|
local USE_LOCAL_COMPONENT="$(get_arg '--use-local-component')"
|
||||||
|
local DEVSVC_REPO="$(get_arg '--devsvc-image-repo')"
|
||||||
|
local DEVSVC_IMAGE="$(get_arg '--devsvc-image-name')"
|
||||||
|
local DEVSVC_TAG="$(get_arg '--devsvc-image-tag')"
|
||||||
|
local PAYMENT_REPO="$(get_arg '--payment-image-repo')"
|
||||||
|
local PAYMENT_IMAGE="$(get_arg '--payment-image-name')"
|
||||||
|
local PAYMENT_TAG="$(get_arg '--payment-image-tag')"
|
||||||
|
local CONTENT_REPO="$(get_arg '--content-image-repo')"
|
||||||
|
local CONTENT_IMAGE="$(get_arg '--content-image-name')"
|
||||||
|
local CONTENT_TAG="$(get_arg '--content-image-tag')"
|
||||||
|
local CENTRAL_STORAGE_REPO="$(get_arg '--central_storage-image-repo')"
|
||||||
|
local CENTRAL_STORAGE_IMAGE="$(get_arg '--central_storage-image-name')"
|
||||||
|
local CENTRAL_STORAGE_TAG="$(get_arg '--central_storage-image-tag')"
|
||||||
|
local AUTHENTICATION_REPO="$(get_arg '--authentication-image-repo')"
|
||||||
|
local AUTHENTICATION_IMAGE="$(get_arg '--authentication-image-name')"
|
||||||
|
local AUTHENTICATION_TAG="$(get_arg '--authentication-image-tag')"
|
||||||
|
local FORCE_INIT="$(get_arg '--force')"
|
||||||
|
|
||||||
local is_pull_all_components=true
|
local is_pull_all_components=true
|
||||||
local components=("devsvc" "payment" "content" "central_storage" "authentication")
|
local components=("devsvc" "payment" "content" "central_storage" "authentication")
|
||||||
|
|
||||||
echo "==> Checking parameters..."
|
echo "==> Checking parameters..."
|
||||||
for component in "${components[@]}"; do
|
for component in "${components[@]}"; do
|
||||||
echo "==> Checking ${component} image repo...value: ${args["${component}_image_repo"]}"
|
echo "==> Checking ${component} image repo...value: $(get_arg "--${component}-image-repo")"
|
||||||
# if any component image repo is provided, then don't pull all components
|
# if any component image repo is provided, then don't pull all components
|
||||||
if [[ -n "${args["${component}_image_repo"]}" ]]; then
|
|
||||||
|
if [[ -n "$(get_arg "--${component}-image-repo")" ]]; then
|
||||||
is_pull_all_components=false
|
is_pull_all_components=false
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
@ -987,9 +1060,10 @@ devbox_init_command() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# record container id
|
# record container id, DEVBOX_FRONTEND_PORT, DEVBOX_BACKEND_PORT
|
||||||
echo "$container_id" > "$WORKING_HOME/.devbox-instance"
|
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"
|
||||||
|
|
||||||
# -------------------------------------------------------------------
|
# -------------------------------------------------------------------
|
||||||
# 6. linbwang: pull and start other components
|
# 6. linbwang: pull and start other components
|
||||||
@ -997,29 +1071,21 @@ devbox_init_command() {
|
|||||||
|
|
||||||
echo "==> [INIT] Starting Freeleaps services... $USE_LOCAL_COMPONENT"
|
echo "==> [INIT] Starting Freeleaps services... $USE_LOCAL_COMPONENT"
|
||||||
|
|
||||||
if [[ "${USE_LOCAL_COMPONENT,,}" == "true" ]]; then
|
if [[ "$(lower "$USE_LOCAL_COMPONENT")" == "true" ]]; then
|
||||||
echo ' ===> Using local components for Freeleaps services.'
|
echo ' ===> Using local components for Freeleaps services.'
|
||||||
|
|
||||||
# Define local components ports dictionary
|
|
||||||
declare -A local_components_ports
|
|
||||||
local_components_ports["devsvc"]="8007"
|
|
||||||
local_components_ports["payment"]="8006"
|
|
||||||
local_components_ports["content"]="8013"
|
|
||||||
local_components_ports["central_storage"]="8005"
|
|
||||||
local_components_ports["authentication"]="8004"
|
|
||||||
|
|
||||||
# Local components for Freeleaps services (devsvc, payment, content, central_storage, authentication)
|
# Local components for Freeleaps services (devsvc, payment, content, central_storage, authentication)
|
||||||
for component in "${components[@]}"; do
|
for component in "${components[@]}"; do
|
||||||
repo_var="${component^^}_REPO"
|
repo_var="$(upper "$component")_REPO"
|
||||||
image_var="${component^^}_IMAGE"
|
image_var="$(upper "$component")_IMAGE"
|
||||||
tag_var="${component^^}_TAG"
|
tag_var="$(upper "$component")_TAG"
|
||||||
|
|
||||||
# 使用间接展开获取变量的值
|
|
||||||
|
# Get the component's repo, image, and tag
|
||||||
COMPONENT_REPO="${!repo_var}"
|
COMPONENT_REPO="${!repo_var}"
|
||||||
COMPONENT_IMAGE="${!image_var}"
|
COMPONENT_IMAGE="${!image_var}"
|
||||||
COMPONENT_TAG="${!tag_var}"
|
COMPONENT_TAG="${!tag_var}"
|
||||||
|
|
||||||
# 调试输出,检查变量是否正确
|
|
||||||
echo "Component: $component"
|
echo "Component: $component"
|
||||||
echo " Repo: $COMPONENT_REPO"
|
echo " Repo: $COMPONENT_REPO"
|
||||||
echo " Image: $COMPONENT_IMAGE"
|
echo " Image: $COMPONENT_IMAGE"
|
||||||
@ -1057,19 +1123,19 @@ if [[ "${USE_LOCAL_COMPONENT,,}" == "true" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
port=$(get_port $component)
|
||||||
echo "==> Creating and starting ${component} container... ${local_components_ports[$component]}"
|
echo "==> Creating and starting ${component} container... ${port}"
|
||||||
local component_container_id
|
local component_container_id
|
||||||
component_container_id="$(
|
component_container_id="$(
|
||||||
docker run -d \
|
docker run -d \
|
||||||
--name "$component" \
|
--name "$component" \
|
||||||
--link "$DEVBOX_NAME" \
|
--link "$DEVBOX_NAME" \
|
||||||
-p "${local_components_ports[$component]}:${local_components_ports[$component]}" \
|
-p "${port}:${port}" \
|
||||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||||
-e SERVICE_API_ACCESS_PORT=${local_components_ports[$component]} \
|
-e SERVICE_API_ACCESS_PORT=${port} \
|
||||||
-e SERVICE_API_ACCESS_HOST=0.0.0.0 \
|
-e SERVICE_API_ACCESS_HOST=0.0.0.0 \
|
||||||
"$component_full_image" \
|
"$component_full_image" \
|
||||||
uvicorn webapi.main:app --reload --port ${local_components_ports[$component]} --host 0.0.0.0 2>/dev/null
|
uvicorn webapi.main:app --reload --port ${port} --host 0.0.0.0 2>/dev/null
|
||||||
)"
|
)"
|
||||||
if [[ -z "$component_container_id" ]]; then
|
if [[ -z "$component_container_id" ]]; then
|
||||||
echo "WARNING: Failed to create ${component} container. please Check the image and specify it to initialize the component."
|
echo "WARNING: Failed to create ${component} container. please Check the image and specify it to initialize the component."
|
||||||
@ -1123,7 +1189,7 @@ echo "step 2: Update /home/.devbox/freeleaps/apps/.env"
|
|||||||
# Get default IP address
|
# Get default IP address
|
||||||
|
|
||||||
DEFAULT_IP=\$(ip route | grep default | sed -n 's/.*default via \([^ ]*\).*/\1/p')
|
DEFAULT_IP=\$(ip route | grep default | sed -n 's/.*default via \([^ ]*\).*/\1/p')
|
||||||
if [[ "\${USE_LOCAL_COMPONENT,,}" == "true" ]]; then
|
if [[ "\$(lower "\$USE_LOCAL_COMPONENT")" == "true" ]]; then
|
||||||
echo "==> Using local components"
|
echo "==> Using local components"
|
||||||
# Local components for Freeleaps services (devsvc, payment, content, central_storage, authentication)
|
# Local components for Freeleaps services (devsvc, payment, content, central_storage, authentication)
|
||||||
cat << 'EOFinner' > /home/.devbox/freeleaps/apps/.env
|
cat << 'EOFinner' > /home/.devbox/freeleaps/apps/.env
|
||||||
@ -1249,7 +1315,7 @@ echo '============================================'
|
|||||||
./start_webapi.sh > /home/.devbox/logs/backend.logs 2>&1 &
|
./start_webapi.sh > /home/.devbox/logs/backend.logs 2>&1 &
|
||||||
BACKEND_PID=\$!
|
BACKEND_PID=\$!
|
||||||
|
|
||||||
# Save BACKEND_PID to a file \${WORKING_HOME}/.frontend.pid: Stores the process id of frontend process.
|
# Save BACKEND_PID to a file \${WORKING_HOME}/.backend.pid: Stores the process id of backend process.
|
||||||
echo "\$BACKEND_PID" > /home/.devbox/.backend.pid
|
echo "\$BACKEND_PID" > /home/.devbox/.backend.pid
|
||||||
|
|
||||||
echo '============================================'
|
echo '============================================'
|
||||||
@ -1299,10 +1365,9 @@ npm install -g pnpm
|
|||||||
pnpm install
|
pnpm install
|
||||||
npm run build
|
npm run build
|
||||||
npm run format
|
npm run format
|
||||||
# Start the frontend service with nohup in order to keep it running after the SSH session is closed
|
# Start the frontend service with nohup in order to keep it running after the SSH session is closed. Save the process ID of the frontend service
|
||||||
nohup npm run dev > /home/.devbox/logs/frontend.logs > /dev/null 2>&1 &
|
nohup npm run dev > /home/.devbox/logs/frontend.logs 2>&1 &
|
||||||
# Save the process ID of the frontend service
|
FRONTEND_PID=\$!
|
||||||
FRONTEND_PID=$!
|
|
||||||
|
|
||||||
echo "npm run dev has been started with PID: \$FRONTEND_PID"
|
echo "npm run dev has been started with PID: \$FRONTEND_PID"
|
||||||
echo "\$FRONTEND_PID" > /home/.devbox/.frontend.pid
|
echo "\$FRONTEND_PID" > /home/.devbox/.frontend.pid
|
||||||
@ -1366,10 +1431,10 @@ devbox_deinit_command() {
|
|||||||
|
|
||||||
# src/deinit_command.sh
|
# src/deinit_command.sh
|
||||||
echo "# It contains the implementation for the 'devbox deinit' command."
|
echo "# It contains the implementation for the 'devbox deinit' command."
|
||||||
local WORKING_HOME="${args['--working-home']:-${HOME}/.devbox}"
|
local WORKING_HOME="$(get_arg '--working-home' "${HOME}/.devbox")"
|
||||||
local CLEAR_LOGS="${args['--clear-logs']:-false}"
|
local CLEAR_LOGS="$(get_arg '--clear-logs' 'false')"
|
||||||
local CLEAR_REPO="${args['--clear-repo']:-false}"
|
local CLEAR_REPO="$(get_arg '--clear-repo' 'false')"
|
||||||
local FORCE="${args['--force']}"
|
local FORCE="$(get_arg '--force')"
|
||||||
|
|
||||||
# print the parameters
|
# print the parameters
|
||||||
echo "==> Deinitialization parameters:"
|
echo "==> Deinitialization parameters:"
|
||||||
@ -1412,8 +1477,8 @@ devbox_deinit_command() {
|
|||||||
# :command.function
|
# :command.function
|
||||||
devbox_start_command() {
|
devbox_start_command() {
|
||||||
|
|
||||||
local COMPONENT="${args['--component']}"
|
local COMPONENT="$(get_arg '--component')"
|
||||||
local WORKING_HOME="${args['--working-home']:-${HOME}/.devbox}"
|
local WORKING_HOME="$(get_arg '--working-home' "${HOME}/.devbox")"
|
||||||
|
|
||||||
# Check if the DevBox container is running
|
# Check if the DevBox container is running
|
||||||
local devbox_container_id_file_path="${WORKING_HOME}/.devbox-instance"
|
local devbox_container_id_file_path="${WORKING_HOME}/.devbox-instance"
|
||||||
@ -1426,10 +1491,10 @@ devbox_start_command() {
|
|||||||
|
|
||||||
echo "==> Starting DevBox services..."
|
echo "==> Starting DevBox services..."
|
||||||
|
|
||||||
# 检查 DevBox 容器的状态
|
# Check if DevBox container is running
|
||||||
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
|
||||||
echo "==> DevBox container is not running, starting container..."
|
echo "==> DevBox container is not running, starting container..."
|
||||||
# 启动容器
|
# Start the container
|
||||||
if ! docker start "${devbox_container_id}"; then
|
if ! docker start "${devbox_container_id}"; then
|
||||||
echo "ERROR: Failed to start DevBox container."
|
echo "ERROR: Failed to start DevBox container."
|
||||||
exit 1
|
exit 1
|
||||||
@ -1439,14 +1504,14 @@ devbox_start_command() {
|
|||||||
echo "==> DevBox container is already running."
|
echo "==> DevBox container is already running."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 如果未指定组件,启动所有组件
|
# If no component is specified, start all components
|
||||||
if [[ -z "$COMPONENT" ]]; then
|
if [[ -z "$COMPONENT" ]]; then
|
||||||
COMPONENTS=("mongodb" "rabbitmq" "backend" "frontend")
|
COMPONENTS=("mongodb" "rabbitmq" "backend" "frontend")
|
||||||
else
|
else
|
||||||
COMPONENTS=("$COMPONENT")
|
COMPONENTS=("$COMPONENT")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 启动指定的组件
|
# Start the specified components
|
||||||
for comp in "${COMPONENTS[@]}"; do
|
for comp in "${COMPONENTS[@]}"; do
|
||||||
case "$comp" in
|
case "$comp" in
|
||||||
"mongodb")
|
"mongodb")
|
||||||
@ -1459,7 +1524,7 @@ devbox_start_command() {
|
|||||||
local mongodb_container_id=$(cat "$mongodb_container_id_file_path")
|
local mongodb_container_id=$(cat "$mongodb_container_id_file_path")
|
||||||
if ! docker ps --no-trunc --format '{{.ID}}' | grep -q "^${mongodb_container_id}\$"; then
|
if ! docker ps --no-trunc --format '{{.ID}}' | grep -q "^${mongodb_container_id}\$"; then
|
||||||
echo "==> MongoDB container is not running, starting container..."
|
echo "==> MongoDB container is not running, starting container..."
|
||||||
# 启动容器
|
# Start the container
|
||||||
if ! docker start "${mongodb_container_id}"; then
|
if ! docker start "${mongodb_container_id}"; then
|
||||||
echo "ERROR: Failed to start MongoDB container."
|
echo "ERROR: Failed to start MongoDB container."
|
||||||
exit 1
|
exit 1
|
||||||
@ -1480,7 +1545,7 @@ devbox_start_command() {
|
|||||||
local rabbitmq_container_id=$(cat "$rabbitmq_container_id_file_path")
|
local rabbitmq_container_id=$(cat "$rabbitmq_container_id_file_path")
|
||||||
if ! docker ps --no-trunc --format '{{.ID}}' | grep -q "^${rabbitmq_container_id}\$"; then
|
if ! docker ps --no-trunc --format '{{.ID}}' | grep -q "^${rabbitmq_container_id}\$"; then
|
||||||
echo "==> RabbitMQ container is not running, starting container..."
|
echo "==> RabbitMQ container is not running, starting container..."
|
||||||
# 启动容器
|
# Start the container
|
||||||
if ! docker start "${rabbitmq_container_id}"; then
|
if ! docker start "${rabbitmq_container_id}"; then
|
||||||
echo "ERROR: Failed to start RabbitMQ container."
|
echo "ERROR: Failed to start RabbitMQ container."
|
||||||
exit 1
|
exit 1
|
||||||
@ -1494,7 +1559,7 @@ devbox_start_command() {
|
|||||||
"backend")
|
"backend")
|
||||||
echo "==> Starting backend service..."
|
echo "==> Starting backend service..."
|
||||||
# start the backend service
|
# start the backend service
|
||||||
docker exec -i "$devbox_container_id" bash <<'EOF'
|
docker exec -i "$devbox_container_id" bash <<EOF
|
||||||
# Start the backend service
|
# Start the backend service
|
||||||
echo "Starting backend service..."
|
echo "Starting backend service..."
|
||||||
|
|
||||||
@ -1504,8 +1569,12 @@ if [ ! -f /home/.devbox/.backend.pid ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Checking if the backend service is already running..."
|
||||||
|
|
||||||
backend_pid=\$(cat /home/.devbox/.backend.pid)
|
backend_pid=\$(cat /home/.devbox/.backend.pid)
|
||||||
|
|
||||||
|
echo "Backend PID: \$backend_pid"
|
||||||
|
|
||||||
if ps -p "\$backend_pid" > /dev/null; then
|
if ps -p "\$backend_pid" > /dev/null; then
|
||||||
echo "Backend service is already running."
|
echo "Backend service is already running."
|
||||||
else
|
else
|
||||||
@ -1533,6 +1602,7 @@ else
|
|||||||
ATTEMPT=0
|
ATTEMPT=0
|
||||||
|
|
||||||
# Check if \$DEVBOX_BACKEND_PORT exists
|
# Check if \$DEVBOX_BACKEND_PORT exists
|
||||||
|
DEVBOX_BACKEND_PORT=\$(cat /home/.devbox/.devbox-backend-port)
|
||||||
if [ -z "\$DEVBOX_BACKEND_PORT" ]; then
|
if [ -z "\$DEVBOX_BACKEND_PORT" ]; then
|
||||||
echo "ERROR: DEVBOX_BACKEND_PORT is not set."
|
echo "ERROR: DEVBOX_BACKEND_PORT is not set."
|
||||||
export DEVBOX_BACKEND_PORT=8002
|
export DEVBOX_BACKEND_PORT=8002
|
||||||
@ -1564,23 +1634,31 @@ EOF
|
|||||||
"frontend")
|
"frontend")
|
||||||
echo "==> Starting frontend service..."
|
echo "==> Starting frontend service..."
|
||||||
# Start the frontend service
|
# Start the frontend service
|
||||||
docker exec -i "$devbox_container_id" bash <<'EOF'
|
docker exec -i "$devbox_container_id" bash <<EOF
|
||||||
# Start the frontend service
|
# Start the frontend service
|
||||||
echo "Starting frontend service..."
|
echo "Starting frontend service..."
|
||||||
# Check if /home/.devbox/.frontend.pid exists
|
# Check if /home/.devbox/.frontend.pid exists
|
||||||
if [ -f /home/.devbox/.frontend.pid ]; then
|
if [ -f /home/.devbox/.frontend.pid ]; then
|
||||||
|
|
||||||
frontend_pid=\$(cat /home/.devbox/.frontend.pid)
|
frontend_pid=\$(cat /home/.devbox/.frontend.pid)
|
||||||
|
|
||||||
# Check if the frontend service is already running
|
# Remove empty spaces and new lines in the frontend_pid
|
||||||
|
frontend_pid=\$(echo "\$frontend_pid" | tr -d '[:space:]')
|
||||||
|
|
||||||
|
# Check if frontend pid is empty
|
||||||
|
if [ -z "\$frontend_pid" ]; then
|
||||||
|
echo "Frontend service is not running. "
|
||||||
|
else
|
||||||
|
echo '============================================'
|
||||||
if ps -p "\$frontend_pid" > /dev/null; then
|
if ps -p "\$frontend_pid" > /dev/null; then
|
||||||
echo "Frontend service is already running."
|
echo "Frontend service is already running."
|
||||||
exit 0
|
exit 0
|
||||||
else
|
|
||||||
# Remove the frontend.pid file
|
|
||||||
rm -f /home/.devbox/.frontend.pid
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Remove the .frontend.pid file before starting the frontend service
|
||||||
|
rm -f /home/.devbox/.frontend.pid
|
||||||
|
fi
|
||||||
echo '============================================'
|
echo '============================================'
|
||||||
echo ' Start frontend service locally'
|
echo ' Start frontend service locally'
|
||||||
echo '============================================'
|
echo '============================================'
|
||||||
@ -1604,20 +1682,22 @@ EOF
|
|||||||
|
|
||||||
# Start the frontend service with nohup in order to keep it running after the SSH session is closed
|
# Start the frontend service with nohup in order to keep it running after the SSH session is closed
|
||||||
# Save the process ID of the frontend service
|
# Save the process ID of the frontend service
|
||||||
nohup npm run dev > /home/.devbox/logs/frontend.logs > /dev/null 2>&1 &
|
|
||||||
FRONTEND_PID=$!
|
nohup npm run dev > /home/.devbox/logs/frontend.logs 2>&1 &
|
||||||
|
FRONTEND_PID=\$!
|
||||||
|
|
||||||
echo "npm run dev has been started with PID: \$FRONTEND_PID"
|
echo "npm run dev has been started with PID: \$FRONTEND_PID"
|
||||||
echo "\$FRONTEND_PID" > /home/.devbox/.frontend.pid
|
echo "\$FRONTEND_PID" > /home/.devbox/.frontend.pid
|
||||||
|
|
||||||
# Wait for the frontend service to start
|
# Wait for the frontend service to start
|
||||||
sleep 30
|
sleep 10
|
||||||
|
|
||||||
# 30 attempts, 10 seconds each, total wait time 5 minutes
|
# 30 attempts, 10 seconds each, total wait time 5 minutes
|
||||||
MAX_ATTEMPTS=30
|
MAX_ATTEMPTS=30
|
||||||
ATTEMPT=0
|
ATTEMPT=0
|
||||||
|
|
||||||
# Check if \$DEVBOX_FRONTEND_PORT exists
|
DEVBOX_FRONTEND_PORT=\$(cat /home/.devbox/.devbox-frontend-port)
|
||||||
|
# get DEVBOX_FRONTEND_PORT from environment variables
|
||||||
if [ -z "\$DEVBOX_FRONTEND_PORT" ]; then
|
if [ -z "\$DEVBOX_FRONTEND_PORT" ]; then
|
||||||
echo "ERROR: DEVBOX_FRONTEND_PORT is not set."
|
echo "ERROR: DEVBOX_FRONTEND_PORT is not set."
|
||||||
export DEVBOX_FRONTEND_PORT=5173
|
export DEVBOX_FRONTEND_PORT=5173
|
||||||
@ -1661,9 +1741,8 @@ EOF
|
|||||||
# :command.function
|
# :command.function
|
||||||
devbox_stop_command() {
|
devbox_stop_command() {
|
||||||
echo "==> Stopping DevBox services..."
|
echo "==> Stopping DevBox services..."
|
||||||
|
local COMPONENT="$(get_arg '--component')"
|
||||||
local COMPONENT="${args['--component']}"
|
local WORKING_HOME="$(get_arg '--working-home' "${HOME}/.devbox")"
|
||||||
local WORKING_HOME="${args['--working-home']:-${HOME}/.devbox}"
|
|
||||||
|
|
||||||
echo "==> Stopping DevBox services..."
|
echo "==> Stopping DevBox services..."
|
||||||
|
|
||||||
@ -1731,8 +1810,8 @@ devbox_stop_command() {
|
|||||||
devbox_status_command() {
|
devbox_status_command() {
|
||||||
|
|
||||||
echo "==> Checking DevBox services status..."
|
echo "==> Checking DevBox services status..."
|
||||||
local COMPONENT="${args['--component']}"
|
local COMPONENT="$(get_arg '--component')"
|
||||||
local WORKING_HOME="${args['--working-home']:-${HOME}/.devbox}"
|
local WORKING_HOME="$(get_arg '--working-home' "${HOME}/.devbox")"
|
||||||
|
|
||||||
# Check if .devbox-instance file exists
|
# Check if .devbox-instance file exists
|
||||||
if [[ ! -f "${WORKING_HOME}/.devbox-instance" ]]; then
|
if [[ ! -f "${WORKING_HOME}/.devbox-instance" ]]; then
|
||||||
@ -1830,8 +1909,8 @@ devbox_status_command() {
|
|||||||
# :command.function
|
# :command.function
|
||||||
devbox_restart_command() {
|
devbox_restart_command() {
|
||||||
echo "==> Restarting DevBox services..."
|
echo "==> Restarting DevBox services..."
|
||||||
local COMPONENT="${args['--component']}"
|
local COMPONENT="$(get_arg '--component')"
|
||||||
local WORKING_HOME="${args['--working-home']:-${HOME}/.devbox}"
|
local WORKING_HOME="$(get_arg '--working-home' "${HOME}/.devbox")"
|
||||||
|
|
||||||
# Check devbox container file path
|
# Check devbox container file path
|
||||||
local devbox_container_id_file_path="${WORKING_HOME}/.devbox-instance"
|
local devbox_container_id_file_path="${WORKING_HOME}/.devbox-instance"
|
||||||
@ -2052,8 +2131,8 @@ EOF
|
|||||||
|
|
||||||
# Start the frontend service with nohup in order to keep it running after the SSH session is closed
|
# Start the frontend service with nohup in order to keep it running after the SSH session is closed
|
||||||
# Save the process ID of the frontend service
|
# Save the process ID of the frontend service
|
||||||
nohup npm run dev > /home/.devbox/logs/frontend.logs > /dev/null 2>&1 &
|
nohup npm run dev > /home/.devbox/logs/frontend.logs 2>&1 &
|
||||||
FRONTEND_PID=$!
|
FRONTEND_PID=\$!
|
||||||
|
|
||||||
echo "npm run dev has been started with PID: \$FRONTEND_PID"
|
echo "npm run dev has been started with PID: \$FRONTEND_PID"
|
||||||
echo "\$FRONTEND_PID" > /home/.devbox/.frontend.pid
|
echo "\$FRONTEND_PID" > /home/.devbox/.frontend.pid
|
||||||
@ -2250,7 +2329,7 @@ devbox_init_parse_requirements() {
|
|||||||
|
|
||||||
# :flag.case_arg
|
# :flag.case_arg
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--os']="$2"
|
add_arg '--os' "$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
else
|
else
|
||||||
@ -2264,7 +2343,7 @@ devbox_init_parse_requirements() {
|
|||||||
|
|
||||||
# :flag.case_arg
|
# :flag.case_arg
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--arch']="$2"
|
add_arg '--arch' "$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
else
|
else
|
||||||
@ -2278,7 +2357,7 @@ devbox_init_parse_requirements() {
|
|||||||
|
|
||||||
# :flag.case_arg
|
# :flag.case_arg
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--devbox-container-name']="$2"
|
add_arg '--devbox-container-name' "$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
else
|
else
|
||||||
@ -2292,7 +2371,7 @@ devbox_init_parse_requirements() {
|
|||||||
|
|
||||||
# :flag.case_arg
|
# :flag.case_arg
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--devbox-container-port']="$2"
|
add_arg '--devbox-container-port' "$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
else
|
else
|
||||||
@ -2306,7 +2385,7 @@ devbox_init_parse_requirements() {
|
|||||||
|
|
||||||
# :flag.case_arg
|
# :flag.case_arg
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--devbox-image-repo']="$2"
|
add_arg '--devbox-image-repo' "$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
else
|
else
|
||||||
@ -2320,7 +2399,7 @@ devbox_init_parse_requirements() {
|
|||||||
|
|
||||||
# :flag.case_arg
|
# :flag.case_arg
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--devbox-image-name']="$2"
|
add_arg '--devbox-image-name' "$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
else
|
else
|
||||||
@ -2334,7 +2413,7 @@ devbox_init_parse_requirements() {
|
|||||||
|
|
||||||
# :flag.case_arg
|
# :flag.case_arg
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--devbox-image-tag']="$2"
|
add_arg '--devbox-image-tag' "$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
else
|
else
|
||||||
@ -2348,7 +2427,7 @@ devbox_init_parse_requirements() {
|
|||||||
|
|
||||||
# :flag.case_arg
|
# :flag.case_arg
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--working-home']="$2"
|
add_arg '--working-home' "$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
else
|
else
|
||||||
@ -2362,7 +2441,7 @@ devbox_init_parse_requirements() {
|
|||||||
|
|
||||||
# :flag.case_arg
|
# :flag.case_arg
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--freeleaps-username']="$2"
|
add_arg '--freeleaps-username' "$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
else
|
else
|
||||||
@ -2376,7 +2455,7 @@ devbox_init_parse_requirements() {
|
|||||||
|
|
||||||
# :flag.case_arg
|
# :flag.case_arg
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--freeleaps-password']="$2"
|
add_arg '--freeleaps-password' "$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
else
|
else
|
||||||
@ -2388,7 +2467,7 @@ devbox_init_parse_requirements() {
|
|||||||
# :flag.case
|
# :flag.case
|
||||||
--use-local-component)
|
--use-local-component)
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--use-local-component']="$2"
|
add_arg '--use-local-component' "$2"
|
||||||
shift 2
|
shift 2
|
||||||
else
|
else
|
||||||
printf "%s\n" "--use-local-component requires an argument: --use-local-component USING_LOCAL_COMPONENT" >&2
|
printf "%s\n" "--use-local-component requires an argument: --use-local-component USING_LOCAL_COMPONENT" >&2
|
||||||
@ -2401,7 +2480,7 @@ devbox_init_parse_requirements() {
|
|||||||
|
|
||||||
# :flag.case_arg
|
# :flag.case_arg
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--devsvc-image-repo']="$2"
|
add_arg '--devsvc-image-repo' "$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
else
|
else
|
||||||
@ -2415,7 +2494,7 @@ devbox_init_parse_requirements() {
|
|||||||
|
|
||||||
# :flag.case_arg
|
# :flag.case_arg
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--devsvc-image-name']="$2"
|
add_arg '--devsvc-image-name' "$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
else
|
else
|
||||||
@ -2429,7 +2508,7 @@ devbox_init_parse_requirements() {
|
|||||||
|
|
||||||
# :flag.case_arg
|
# :flag.case_arg
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--devsvc-image-tag']="$2"
|
add_arg '--devsvc-image-tag' "$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
else
|
else
|
||||||
@ -2441,7 +2520,7 @@ devbox_init_parse_requirements() {
|
|||||||
# :flag.case
|
# :flag.case
|
||||||
--payment-image-repo)
|
--payment-image-repo)
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--payment-image-repo']="$2"
|
add_arg '--payment-image-repo' "$2"
|
||||||
shift 2
|
shift 2
|
||||||
else
|
else
|
||||||
printf "%s\n" "--payment-image-repo requires an argument: --payment-image-repo FREELEAPS_PAYMENT_IMAGE_REPO" >&2
|
printf "%s\n" "--payment-image-repo requires an argument: --payment-image-repo FREELEAPS_PAYMENT_IMAGE_REPO" >&2
|
||||||
@ -2452,7 +2531,7 @@ devbox_init_parse_requirements() {
|
|||||||
# :flag.case
|
# :flag.case
|
||||||
--payment-image-name)
|
--payment-image-name)
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--payment-image-name']="$2"
|
add_arg '--payment-image-name' "$2"
|
||||||
shift 2
|
shift 2
|
||||||
else
|
else
|
||||||
printf "%s\n" "--payment-image-name requires an argument: --payment-image-name FREELEAPS_PAYMENT_IMAGE_NAME" >&2
|
printf "%s\n" "--payment-image-name requires an argument: --payment-image-name FREELEAPS_PAYMENT_IMAGE_NAME" >&2
|
||||||
@ -2463,7 +2542,7 @@ devbox_init_parse_requirements() {
|
|||||||
# :flag.case
|
# :flag.case
|
||||||
--payment-image-tag)
|
--payment-image-tag)
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--payment-image-tag']="$2"
|
add_arg '--payment-image-tag' "$2"
|
||||||
shift 2
|
shift 2
|
||||||
else
|
else
|
||||||
printf "%s\n" "--payment-image-tag requires an argument: --payment-image-tag FREELEAPS_PAYMENT_IMAGE_TAG" >&2
|
printf "%s\n" "--payment-image-tag requires an argument: --payment-image-tag FREELEAPS_PAYMENT_IMAGE_TAG" >&2
|
||||||
@ -2474,7 +2553,7 @@ devbox_init_parse_requirements() {
|
|||||||
# :flag.case
|
# :flag.case
|
||||||
--content-image-repo)
|
--content-image-repo)
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--content-image-repo']="$2"
|
add_arg '--content-image-repo' "$2"
|
||||||
shift 2
|
shift 2
|
||||||
else
|
else
|
||||||
printf "%s\n" "--content-image-repo requires an argument: --content-image-repo FREELEAPS_CONTENT_IMAGE_REPO" >&2
|
printf "%s\n" "--content-image-repo requires an argument: --content-image-repo FREELEAPS_CONTENT_IMAGE_REPO" >&2
|
||||||
@ -2485,7 +2564,7 @@ devbox_init_parse_requirements() {
|
|||||||
# :flag.case
|
# :flag.case
|
||||||
--content-image-name)
|
--content-image-name)
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--content-image-name']="$2"
|
add_arg '--content-image-name' "$2"
|
||||||
shift 2
|
shift 2
|
||||||
else
|
else
|
||||||
printf "%s\n" "--content-image-name requires an argument: --content-image-name FREELEAPS_CONTENT_IMAGE_NAME" >&2
|
printf "%s\n" "--content-image-name requires an argument: --content-image-name FREELEAPS_CONTENT_IMAGE_NAME" >&2
|
||||||
@ -2496,7 +2575,7 @@ devbox_init_parse_requirements() {
|
|||||||
# :flag.case
|
# :flag.case
|
||||||
--content-image-tag)
|
--content-image-tag)
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--content-image-tag']="$2"
|
add_arg '--content-image-tag' "$2"
|
||||||
shift 2
|
shift 2
|
||||||
else
|
else
|
||||||
printf "%s\n" "--content-image-tag requires an argument: --content-image-tag FREELEAPS_CONTENT_IMAGE_TAG" >&2
|
printf "%s\n" "--content-image-tag requires an argument: --content-image-tag FREELEAPS_CONTENT_IMAGE_TAG" >&2
|
||||||
@ -2507,7 +2586,7 @@ devbox_init_parse_requirements() {
|
|||||||
# :flag.case
|
# :flag.case
|
||||||
--central_storage-image-repo)
|
--central_storage-image-repo)
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--central_storage-image-repo']="$2"
|
add_arg '--central_storage-image-repo' "$2"
|
||||||
shift 2
|
shift 2
|
||||||
else
|
else
|
||||||
printf "%s\n" "--central_storage-image-repo requires an argument: --central_storage-image-repo FREELEAPS_CENTRAL_STORAGE_IMAGE_REPO" >&2
|
printf "%s\n" "--central_storage-image-repo requires an argument: --central_storage-image-repo FREELEAPS_CENTRAL_STORAGE_IMAGE_REPO" >&2
|
||||||
@ -2518,7 +2597,7 @@ devbox_init_parse_requirements() {
|
|||||||
# :flag.case
|
# :flag.case
|
||||||
--central_storage-image-name)
|
--central_storage-image-name)
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--central_storage-image-name']="$2"
|
add_arg '--central_storage-image-name' "$2"
|
||||||
shift 2
|
shift 2
|
||||||
else
|
else
|
||||||
printf "%s\n" "--central_storage-image-name requires an argument: --central_storage-image-name FREELEAPS_CENTRAL_STORAGE_IMAGE_NAME" >&2
|
printf "%s\n" "--central_storage-image-name requires an argument: --central_storage-image-name FREELEAPS_CENTRAL_STORAGE_IMAGE_NAME" >&2
|
||||||
@ -2529,7 +2608,7 @@ devbox_init_parse_requirements() {
|
|||||||
# :flag.case
|
# :flag.case
|
||||||
--central_storage-image-tag)
|
--central_storage-image-tag)
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--central_storage-image-tag']="$2"
|
add_arg '--central_storage-image-tag' "$2"
|
||||||
shift 2
|
shift 2
|
||||||
else
|
else
|
||||||
printf "%s\n" "--central_storage-image-tag requires an argument: --central_storage-image-tag FREELEAPS_CENTRAL_STORAGE_IMAGE_TAG" >&2
|
printf "%s\n" "--central_storage-image-tag requires an argument: --central_storage-image-tag FREELEAPS_CENTRAL_STORAGE_IMAGE_TAG" >&2
|
||||||
@ -2540,7 +2619,7 @@ devbox_init_parse_requirements() {
|
|||||||
# :flag.case
|
# :flag.case
|
||||||
--authentication-image-repo)
|
--authentication-image-repo)
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--authentication-image-repo']="$2"
|
add_arg '--authentication-image-repo' "$2"
|
||||||
shift 2
|
shift 2
|
||||||
else
|
else
|
||||||
printf "%s\n" "--authentication-image-repo requires an argument: --authentication-image-repo FREELEAPS_AUTHENTICATION_IMAGE_REPO" >&2
|
printf "%s\n" "--authentication-image-repo requires an argument: --authentication-image-repo FREELEAPS_AUTHENTICATION_IMAGE_REPO" >&2
|
||||||
@ -2551,7 +2630,7 @@ devbox_init_parse_requirements() {
|
|||||||
# :flag.case
|
# :flag.case
|
||||||
--authentication-image-name)
|
--authentication-image-name)
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--authentication-image-name']="$2"
|
add_arg '--authentication-image-name' "$2"
|
||||||
shift 2
|
shift 2
|
||||||
else
|
else
|
||||||
printf "%s\n" "--authentication-image-name requires an argument: --authentication-image-name FREELEAPS_AUTHENTICATION_IMAGE_NAME" >&2
|
printf "%s\n" "--authentication-image-name requires an argument: --authentication-image-name FREELEAPS_AUTHENTICATION_IMAGE_NAME" >&2
|
||||||
@ -2562,7 +2641,7 @@ devbox_init_parse_requirements() {
|
|||||||
# :flag.case
|
# :flag.case
|
||||||
--authentication-image-tag)
|
--authentication-image-tag)
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--authentication-image-tag']="$2"
|
add_arg '--authentication-image-tag' "$2"
|
||||||
shift 2
|
shift 2
|
||||||
else
|
else
|
||||||
printf "%s\n" "--authentication-image-tag requires an argument: --authentication-image-tag FREELEAPS_AUTHENTICATION_IMAGE_TAG" >&2
|
printf "%s\n" "--authentication-image-tag requires an argument: --authentication-image-tag FREELEAPS_AUTHENTICATION_IMAGE_TAG" >&2
|
||||||
@ -2573,7 +2652,7 @@ devbox_init_parse_requirements() {
|
|||||||
--force | -f)
|
--force | -f)
|
||||||
|
|
||||||
# :flag.case_no_arg
|
# :flag.case_no_arg
|
||||||
args['--force']=1
|
add_arg '--force' '1'
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@ -2594,33 +2673,82 @@ devbox_init_parse_requirements() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
# :command.required_flags_filter
|
# :command.required_flags_filter
|
||||||
if [[ -z ${args['--freeleaps-username']+x} ]]; then
|
|
||||||
|
if [[ -z "$(get_arg '--freeleaps-username')" ]]; then
|
||||||
|
|
||||||
printf "missing required flag: --freeleaps-username FREELEAPS_USERNAME\n" >&2
|
printf "missing required flag: --freeleaps-username FREELEAPS_USERNAME\n" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [[ -z ${args['--freeleaps-password']+x} ]]; then
|
if [[ -z "$(get_arg '--freeleaps-password')" ]]; then
|
||||||
printf "missing required flag: --freeleaps-password FREELEAPS_PASSWORD\n" >&2
|
printf "missing required flag: --freeleaps-password FREELEAPS_PASSWORD\n" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# :command.default_assignments
|
# :command.default_assignments
|
||||||
[[ -n ${args['--os']:-} ]] || args['--os']="auto"
|
|
||||||
[[ -n ${args['--arch']:-} ]] || args['--arch']="auto"
|
|
||||||
[[ -n ${args['--devbox-container-name']:-} ]] || args['--devbox-container-name']="devbox"
|
|
||||||
[[ -n ${args['--devbox-container-port']:-} ]] || args['--devbox-container-port']="22222"
|
|
||||||
[[ -n ${args['--devbox-frontend-port']:-} ]] || args['--devbox-frontend-port']="5173"
|
|
||||||
[[ -n ${args['--devbox-backend-port']:-} ]] || args['--devbox-backend-port']="8002"
|
|
||||||
|
|
||||||
[[ -n ${args['--devbox-image-repo']:-} ]] || args['--devbox-image-repo']="docker.io/freeleaps"
|
if [ -z "$(get_arg '--os')" ]; then
|
||||||
[[ -n ${args['--devbox-image-name']:-} ]] || args['--devbox-image-name']="devbox_v1"
|
add_arg '--os' "auto"
|
||||||
[[ -n ${args['--devbox-image-tag']:-} ]] || args['--devbox-image-tag']="devbox_local"
|
fi
|
||||||
[[ -n ${args['--devsvc-image-tag']:-} ]] || args['--devsvc-image-tag']="latest-linux-arm64"
|
|
||||||
[[ -n ${args['--payment-image-tag']:-} ]] || args['--payment-image-tag']="latest-linux-arm64"
|
if [ -z "$(get_arg '--arch')" ]; then
|
||||||
[[ -n ${args['--content-image-tag']:-} ]] || args['--content-image-tag']="latest-linux-arm64"
|
add_arg '--arch' "auto"
|
||||||
[[ -n ${args['--central_storage-image-tag']:-} ]] || args['--central_storage-image-tag']="latest-linux-arm64"
|
fi
|
||||||
[[ -n ${args['--authentication-image-tag']:-} ]] || args['--authentication-image-tag']="latest-linux-arm64"
|
|
||||||
[[ -n ${args['--working-home']:-} ]] || args['--working-home']="${HOME}/.devbox"
|
if [ -z "$(get_arg '--devbox-container-name')" ]; then
|
||||||
[[ -n ${args['--use-local-component']:-} ]] || args['--use-local-component']="true"
|
add_arg '--devbox-container-name' "devbox"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$(get_arg '--devbox-container-port')" ]; then
|
||||||
|
add_arg '--devbox-container-port' "22222"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$(get_arg '--devbox-frontend-port')" ]; then
|
||||||
|
add_arg '--devbox-frontend-port' "5173"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$(get_arg '--devbox-backend-port')" ]; then
|
||||||
|
add_arg '--devbox-backend-port' "8002"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$(get_arg '--devbox-image-repo')" ]; then
|
||||||
|
add_arg '--devbox-image-repo' "docker.io/freeleaps"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$(get_arg '--devbox-image-name')" ]; then
|
||||||
|
add_arg '--devbox-image-name' "devbox_v1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$(get_arg '--devbox-image-tag')" ]; then
|
||||||
|
add_arg '--devbox-image-tag' "devbox_local"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$(get_arg '--devsvc-image-tag')" ]; then
|
||||||
|
add_arg '--devsvc-image-tag' "latest-linux-arm64"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$(get_arg '--payment-image-tag')" ]; then
|
||||||
|
add_arg '--payment-image-tag' "latest-linux-arm64"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$(get_arg '--content-image-tag')" ]; then
|
||||||
|
add_arg '--content-image-tag' "latest-linux-arm64"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$(get_arg '--central_storage-image-tag')" ]; then
|
||||||
|
add_arg '--central_storage-image-tag' "latest-linux-arm64"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$(get_arg '--authentication-image-tag')" ]; then
|
||||||
|
add_arg '--authentication-image-tag' "latest-linux-arm64"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$(get_arg '--working-home')" ]; then
|
||||||
|
add_arg '--working-home' "${HOME}/.devbox"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$(get_arg '--use-local-component')" ]; then
|
||||||
|
add_arg '--use-local-component' "true"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -2657,7 +2785,7 @@ devbox_deinit_parse_requirements() {
|
|||||||
|
|
||||||
# :flag.case_arg
|
# :flag.case_arg
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--working-home']="$2"
|
add_arg '--working-home' "$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
else
|
else
|
||||||
@ -2671,7 +2799,7 @@ devbox_deinit_parse_requirements() {
|
|||||||
|
|
||||||
# :flag.case_arg
|
# :flag.case_arg
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--clear-logs']="$2"
|
add_arg '--clear-logs' "$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
else
|
else
|
||||||
@ -2685,7 +2813,7 @@ devbox_deinit_parse_requirements() {
|
|||||||
|
|
||||||
# :flag.case_arg
|
# :flag.case_arg
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--clear-repo']="$2"
|
add_arg '--clear-repo' "$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
else
|
else
|
||||||
@ -2711,9 +2839,15 @@ devbox_deinit_parse_requirements() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
# :command.default_assignments
|
# :command.default_assignments
|
||||||
[[ -n ${args['--working-home']:-} ]] || args['--working-home']="${HOME}/.devbox"
|
if [ -z "$(get_arg '--working-home')" ]; then
|
||||||
[[ -n ${args['--clear-logs']:-} ]] || args['--clear-logs']="true"
|
add_arg '--working-home' "${HOME}/.devbox"
|
||||||
[[ -n ${args['--clear-repo']:-} ]] || args['--clear-repo']="false"
|
fi
|
||||||
|
if [ -z "$(get_arg '--clear-logs')" ]; then
|
||||||
|
add_arg '--clear-logs' "true"
|
||||||
|
fi
|
||||||
|
if [ -z "$(get_arg '--clear-repo')" ]; then
|
||||||
|
add_arg '--clear-repo' "false"
|
||||||
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2748,7 +2882,7 @@ devbox_start_parse_requirements() {
|
|||||||
|
|
||||||
# :flag.case_arg
|
# :flag.case_arg
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--component']="$2"
|
add_arg '--component' "$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
else
|
else
|
||||||
@ -2806,7 +2940,7 @@ devbox_stop_parse_requirements() {
|
|||||||
|
|
||||||
# :flag.case_arg
|
# :flag.case_arg
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
args['--component']="$2"
|
add_arg '--component' "$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
else
|
else
|
||||||
@ -2923,18 +3057,23 @@ devbox_restart_parse_requirements() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# :command.initialize
|
|
||||||
|
|
||||||
initialize() {
|
initialize() {
|
||||||
version="1.0.0"
|
version="1.0.0"
|
||||||
long_usage=''
|
long_usage=""
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# :command.globals
|
# Use the following variables to define the environment variables and input parameters
|
||||||
declare -g -A args=()
|
args_keys=()
|
||||||
declare -g -A deps=()
|
args_values=()
|
||||||
declare -g -a env_var_names=()
|
|
||||||
declare -g -a input=()
|
|
||||||
|
|
||||||
|
deps_keys=()
|
||||||
|
deps_values=()
|
||||||
|
|
||||||
|
# For each environment variable, add a line like the following:
|
||||||
|
env_var_names=()
|
||||||
|
input=()
|
||||||
}
|
}
|
||||||
|
|
||||||
# :command.run
|
# :command.run
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user