forked from freeleaps/freeleaps-pub
Update for fixing gitea startup blocing signin issue
This commit is contained in:
parent
f1af132c2a
commit
1e25c6452b
@ -446,43 +446,6 @@ get_port() {
|
|||||||
echo "$port"
|
echo "$port"
|
||||||
}
|
}
|
||||||
|
|
||||||
check_jq() {
|
|
||||||
# 从参数中获取 OS 和 ARCH,默认值分别为 auto
|
|
||||||
local target_os target_arch
|
|
||||||
target_os="$(get_arg '--os' 'auto')"
|
|
||||||
target_arch="$(get_arg '--arch' 'auto')"
|
|
||||||
|
|
||||||
if ! command -v jq >/dev/null 2>&1; then
|
|
||||||
echo "[INFO] 'jq' is not installed. Installing jq..."
|
|
||||||
case "$target_os" in
|
|
||||||
darwin)
|
|
||||||
if command -v brew >/dev/null 2>&1; then
|
|
||||||
brew install jq
|
|
||||||
else
|
|
||||||
echo "[ERROR] brew not found. Please install jq manually."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
linux | wsl2 | auto)
|
|
||||||
if command -v apt-get >/dev/null 2>&1; then
|
|
||||||
sudo apt-get update && sudo apt-get install -y jq
|
|
||||||
elif command -v yum >/dev/null 2>&1; then
|
|
||||||
sudo yum install -y epel-release && sudo yum install -y jq
|
|
||||||
else
|
|
||||||
echo "[ERROR] apt-get or yum not found. Please install jq manually."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "[ERROR] Unsupported OS: $target_os"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
else
|
|
||||||
echo "[INFO] 'jq' is already installed."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# :command.command_functions
|
# :command.command_functions
|
||||||
# :command.function
|
# :command.function
|
||||||
devbox_init_command() {
|
devbox_init_command() {
|
||||||
@ -852,14 +815,8 @@ if [[ $USE_LOCAL_COMPONENT_VAL == true ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Check if jq is installed, if not install it
|
|
||||||
check_jq
|
|
||||||
|
|
||||||
# Get Gitea data volume mount point
|
|
||||||
GITEA_DATA=$(docker volume inspect devbox_freeleaps2-gitea-data | jq -r '.[0].Mountpoint')
|
|
||||||
|
|
||||||
echo "Gitea data volume mount point: $GITEA_DATA"
|
|
||||||
|
|
||||||
echo "==> Starting Gitea, MongoDB, RabbitMQ containers..."
|
echo "==> Starting Gitea, MongoDB, RabbitMQ containers..."
|
||||||
# Start local components by docker compose file and start up specified services. docker compose file is in the same directory as the script (docker-compose.dev.arm64.new.yaml)
|
# Start local components by docker compose file and start up specified services. docker compose file is in the same directory as the script (docker-compose.dev.arm64.new.yaml)
|
||||||
@ -889,42 +846,49 @@ if [[ $USE_LOCAL_COMPONENT_VAL == true ]]; then
|
|||||||
|
|
||||||
echo "${component} container created: $component_container_id"
|
echo "${component} container created: $component_container_id"
|
||||||
|
|
||||||
# Check if devbox_freeleaps2-gitea-data exists, if not create a docker volume for gitea data, if exists then remove it and create a new one
|
# Get the owner group of the WORKING_HOME
|
||||||
if docker volume ls | grep -q "devbox_freeleaps2-gitea-data"; then
|
if [[ "$(uname)" == "Darwin" ]]; then
|
||||||
docker volume rm devbox_freeleaps2-gitea-data
|
OWNER_GROUP=$(stat -f "%Su:%Sg" "${WORKING_HOME}")
|
||||||
fi
|
|
||||||
|
|
||||||
docker volume create devbox_freeleaps2-gitea-data || {
|
|
||||||
echo "ERROR: Failed to create volume devbox_freeleaps2-gitea-data."
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check volume created successfully
|
|
||||||
if ! docker volume ls | grep -q "devbox_freeleaps2-gitea-data"; then
|
|
||||||
echo "ERROR: Failed to create volume devbox_freeleaps2-gitea-data."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -d "${GITEA_DATA}/gitea" ]]; then
|
|
||||||
echo "Gitea data exist, skipping..."
|
|
||||||
else
|
else
|
||||||
echo "Gitea data not exist, copying..."
|
OWNER_GROUP=$(stat -c "%U:%G" "${WORKING_HOME}")
|
||||||
sudo rm -rf ${GITEA_DATA}/git
|
fi
|
||||||
sudo rm -rf ${GITEA_DATA}/gitea
|
|
||||||
sudo rm -rf ${GITEA_DATA}/ssh
|
|
||||||
sudo mv data/git ${GITEA_DATA}/
|
|
||||||
sudo mv data/gitea ${GITEA_DATA}/
|
|
||||||
sudo mv data/ssh ${GITEA_DATA}/
|
|
||||||
sudo chown -R freedev:freedev ${GITEA_DATA}
|
|
||||||
echo "Gitea data copying is done"
|
|
||||||
# Check if gitea data copied successfully
|
|
||||||
if [[ ! -d "${GITEA_DATA}/gitea" ]]; then
|
|
||||||
echo "ERROR: Failed to copy gitea data."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# restart gitea container
|
# Echo OWNER_GROUP
|
||||||
docker-compose -f docker-compose.dev.arm64.new.yaml restart gitea
|
echo "OWNER_GROUP: $OWNER_GROUP"
|
||||||
|
|
||||||
|
# Copy gitea data to the gitea container
|
||||||
|
GITEA_HOST_DIR="${WORKING_HOME}/freeleaps2-gitea"
|
||||||
|
|
||||||
|
# Remove existing data directories
|
||||||
|
sudo rm -rf ${GITEA_HOST_DIR}/git
|
||||||
|
sudo rm -rf ${GITEA_HOST_DIR}/gitea
|
||||||
|
sudo rm -rf ${GITEA_HOST_DIR}/ssh
|
||||||
|
|
||||||
|
# Move data directories to the gitea container
|
||||||
|
sudo mv data/git ${GITEA_HOST_DIR}/
|
||||||
|
sudo mv data/gitea ${GITEA_HOST_DIR}/
|
||||||
|
sudo mv data/ssh ${GITEA_HOST_DIR}/
|
||||||
|
|
||||||
|
# Change the owner group of the gitea data directories
|
||||||
|
sudo chown -R "${OWNER_GROUP}" ${GITEA_HOST_DIR}
|
||||||
|
echo "Gitea data copying is done"
|
||||||
|
|
||||||
|
# Check if gitea data directories exist in the gitea container
|
||||||
|
if [[ ! -d "${GITEA_HOST_DIR}/gitea" ]]; then
|
||||||
|
echo "ERROR: Failed to copy gitea data."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# restart gitea container
|
||||||
|
docker-compose -f docker-compose.dev.arm64.new.yaml restart rabbitmq
|
||||||
|
sleep 10
|
||||||
|
|
||||||
|
docker-compose -f docker-compose.dev.arm64.new.yaml restart gitea
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
# restart notification if it is in the start_components
|
||||||
|
if [[ " ${start_components[@]} " =~ "notification" ]]; then
|
||||||
|
docker-compose -f docker-compose.dev.arm64.new.yaml restart notification
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo '============================================'
|
echo '============================================'
|
||||||
@ -956,6 +920,7 @@ echo "$USE_LOCAL_COMPONENT" > "$WORKING_HOME/.use-local-component"
|
|||||||
|
|
||||||
pushd $WORKING_HOME
|
pushd $WORKING_HOME
|
||||||
|
|
||||||
|
|
||||||
IS_START_FRONTEND=false
|
IS_START_FRONTEND=false
|
||||||
|
|
||||||
# Make a user input (Y/N) to continue pull freeleaps.com code and start if N then exit
|
# Make a user input (Y/N) to continue pull freeleaps.com code and start if N then exit
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user