mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-01-11 23:57:12 +08:00
68 lines
1.8 KiB
Bash
Executable File
68 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Common utilities, variables and checks for all build scripts.
|
|
set -o errexit
|
|
set -o nounset
|
|
set -o pipefail
|
|
|
|
#Include shell font styles and some basic information
|
|
SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
|
|
|
source $SCRIPTS_ROOT/style_info.sh
|
|
|
|
# docker-compose.yaml file name
|
|
docker_compose_file_name="docker-compose.yaml"
|
|
|
|
trap 'onCtrlC' INT
|
|
function onCtrlC () {
|
|
#Capture CTRL+C, terminate the background process of the program when the script is terminated in the form of ctrl+c
|
|
kill -9 ${do_sth_pid} ${progress_pid}
|
|
echo
|
|
echo 'Ctrl+C is captured'
|
|
exit 1
|
|
}
|
|
|
|
# Get the public internet IP address
|
|
internet_ip=$(curl ifconfig.me -s)
|
|
echo -e "${PURPLE_PREFIX}=========> Your public internet IP address is ${internet_ip} ${COLOR_SUFFIX} \n"
|
|
|
|
# Load environment variables from .env file
|
|
source ${OPENIM_ROOT}/.env
|
|
|
|
echo -e "${PURPLE_PREFIX}=========> Your minio endpoint is ${MINIO_ENDPOINT} ${COLOR_SUFFIX} \n"
|
|
|
|
# Change directory to scripts folder
|
|
|
|
chmod +x ${SCRIPTS_ROOT}/*.sh
|
|
|
|
# Execute necessary scripts
|
|
echo -e "${PURPLE_PREFIX}=========> init_pwd.sh ${COLOR_SUFFIX} \n"
|
|
|
|
${SCRIPTS_ROOT}/init_pwd.sh
|
|
|
|
echo -e "${PURPLE_PREFIX}=========> env_check.sh ${COLOR_SUFFIX} \n"
|
|
|
|
${SCRIPTS_ROOT}/env_check.sh
|
|
|
|
# Replace local IP address with the public IP address in .env file
|
|
if [ $API_URL == "http://127.0.0.1:10002/object/" ]; then
|
|
sed -i "s/127.0.0.1/${internet_ip}/" ${OPENIM_ROOT}/.env
|
|
fi
|
|
|
|
if [ $MINIO_ENDPOINT == "http://127.0.0.1:10005" ]; then
|
|
sed -i "s/127.0.0.1/${internet_ip}/" ${OPENIM_ROOT}/.env
|
|
fi
|
|
|
|
# Go back to the previous directory
|
|
cd ${OPENIM_ROOT}
|
|
|
|
# Check if docker-compose command is available
|
|
if command -v docker-compose &> /dev/null
|
|
then
|
|
docker-compose up -d
|
|
else
|
|
docker compose up -d
|
|
fi
|
|
|
|
${SCRIPTS_ROOT}/docker_check_service.sh |