mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-01-09 13:36:57 +08:00
fix: config env command
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
This commit is contained in:
parent
481d1983f3
commit
fbf3d77822
@ -24,8 +24,8 @@ zookeeper:
|
|||||||
|
|
||||||
mysql:
|
mysql:
|
||||||
address: [ 127.0.0.1:13306 ] #目前仅支持单机
|
address: [ 127.0.0.1:13306 ] #目前仅支持单机
|
||||||
username: root #用户名
|
username: root
|
||||||
password: openIM123 #密码
|
password: openIM123
|
||||||
database: openIM_v3 #不建议修改
|
database: openIM_v3 #不建议修改
|
||||||
maxOpenConn: 1000 #最大连接数
|
maxOpenConn: 1000 #最大连接数
|
||||||
maxIdleConn: 100 #最大空闲连接数
|
maxIdleConn: 100 #最大空闲连接数
|
||||||
@ -37,14 +37,14 @@ mongo:
|
|||||||
uri: #不为空则直接使用该值
|
uri: #不为空则直接使用该值
|
||||||
address: [ 127.0.0.1:37017 ] #单机时为mongo地址,使用分片集群时,为mongos地址
|
address: [ 127.0.0.1:37017 ] #单机时为mongo地址,使用分片集群时,为mongos地址
|
||||||
database: openIM_v3 #mongo db 默认即可
|
database: openIM_v3 #mongo db 默认即可
|
||||||
username: root #用户名
|
username: root
|
||||||
password: openIM123 #密码
|
password: openIM123
|
||||||
maxPoolSize: 100
|
maxPoolSize: 100
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
address: [ 127.0.0.1:16379 ] #
|
address: [ 127.0.0.1:16379 ] #
|
||||||
username: #only redis version 6.0+ need username
|
username: #only redis version 6.0+ need username
|
||||||
password: openIM123 #密码
|
password: openIM123
|
||||||
|
|
||||||
kafka:
|
kafka:
|
||||||
username: #用户名
|
username: #用户名
|
||||||
@ -77,9 +77,9 @@ object:
|
|||||||
apiURL: "http://127.0.0.1:10002/object/" #地址需要app能访问到
|
apiURL: "http://127.0.0.1:10002/object/" #地址需要app能访问到
|
||||||
minio:
|
minio:
|
||||||
bucket: "openim" #不建议修改
|
bucket: "openim" #不建议修改
|
||||||
endpoint: "http://127.0.0.1:10005" #minio对外服务的ip和端口,app要能访问此ip和端口
|
endpoint: http://127.0.0.1:10005 #地址需要app能够访问
|
||||||
accessKeyID: "root" #ID
|
accessKeyID: root
|
||||||
secretAccessKey: "openIM123" #秘钥
|
secretAccessKey: openIM123
|
||||||
sessionToken: "" #token
|
sessionToken: "" #token
|
||||||
cos: #tencent cos
|
cos: #tencent cos
|
||||||
bucketURL: "https://temp-1252357374.cos.ap-chengdu.myqcloud.com"
|
bucketURL: "https://temp-1252357374.cos.ap-chengdu.myqcloud.com"
|
||||||
@ -167,7 +167,7 @@ retainChatRecords: 365 #mongo保存离线消息
|
|||||||
chatRecordsClearTime: "0 2 * * 3" #每周三凌晨2点清理mongo中的过期(超过retainChatRecords时间)消息,这个删除是为了清理满足上个配置retainChatRecords的过期消息,不会发送通知,仅仅作为清理磁盘使用
|
chatRecordsClearTime: "0 2 * * 3" #每周三凌晨2点清理mongo中的过期(超过retainChatRecords时间)消息,这个删除是为了清理满足上个配置retainChatRecords的过期消息,不会发送通知,仅仅作为清理磁盘使用
|
||||||
msgDestructTime: "0 2 * * *" #消息自动删除时间,每天凌晨2点删除过期消息,这个删除是为了删除保留时间超过超过会话字段msg_destruct_time(秒)的消息。
|
msgDestructTime: "0 2 * * *" #消息自动删除时间,每天凌晨2点删除过期消息,这个删除是为了删除保留时间超过超过会话字段msg_destruct_time(秒)的消息。
|
||||||
|
|
||||||
secret: tuoyun #秘钥,获取token时校验
|
secret: openIM123
|
||||||
|
|
||||||
tokenPolicy:
|
tokenPolicy:
|
||||||
expire: 90 #过期时间(天)
|
expire: 90 #过期时间(天)
|
||||||
|
|||||||
216
install.sh
216
install.sh
@ -23,34 +23,60 @@ set -o pipefail
|
|||||||
############### OpenIM Github ###############
|
############### OpenIM Github ###############
|
||||||
# ... rest of the script ...
|
# ... rest of the script ...
|
||||||
|
|
||||||
# OpenIM Repo
|
# TODO
|
||||||
OWNER="OpenIMSDK"
|
# You can configure this script in three ways.
|
||||||
REPO="Open-IM-Server"
|
# 1. First, set the variables in this column with more comments.
|
||||||
|
# 2. The second is to pass an environment variable via a flag such as --help.
|
||||||
|
# 3. The third way is to set the variable externally, or pass it in as an environment variable
|
||||||
|
|
||||||
# Update your Go version here
|
# Default configuration for OpenIM Repo
|
||||||
|
# The OpenIM Repo settings can be customized according to your needs.
|
||||||
|
|
||||||
|
# OpenIM Repo owner, by default it's set to "OpenIMSDK". If you're using a different owner, replace accordingly.
|
||||||
|
OWNER="OpenIMSDK"
|
||||||
|
|
||||||
|
# The repository name, by default it's "Open-IM-Server". If you're using a different repository, replace accordingly.
|
||||||
|
REPO="Open-IM-Server"
|
||||||
|
|
||||||
|
# Version of Go you want to use, make sure it is compatible with your OpenIM-Server requirements.
|
||||||
|
# Default is 1.18, if you want to use a different version, replace accordingly.
|
||||||
GO_VERSION="1.18"
|
GO_VERSION="1.18"
|
||||||
|
|
||||||
|
# Default HTTP_PORT is 80. If you want to use a different port, uncomment and replace the value.
|
||||||
# HTTP_PORT=80
|
# HTTP_PORT=80
|
||||||
|
|
||||||
# CPU core number, concurrent execution
|
# CPU core number for concurrent execution. By default it's determined automatically.
|
||||||
|
# Uncomment the next line if you want to set it manually.
|
||||||
# CPU=$(grep -c ^processor /proc/cpuinfo)
|
# CPU=$(grep -c ^processor /proc/cpuinfo)
|
||||||
|
|
||||||
# default is latest tag: https://github.com/OpenIMSDK/Open-IM-Server/releases
|
# By default, the script uses the latest tag from OpenIM-Server releases.
|
||||||
|
# If you want to use a specific tag, uncomment and replace "v3.0.0" with the desired tag.
|
||||||
# LATEST_TAG=v3.0.0
|
# LATEST_TAG=v3.0.0
|
||||||
|
|
||||||
# default OpenIM install directory is /tmp
|
# Default OpenIM install directory is /tmp. If you want to use a different directory, uncomment and replace "/test".
|
||||||
# DOWNLOAD_OPENIM_DIR="/test"
|
# DOWNLOAD_OPENIM_DIR="/test"
|
||||||
|
|
||||||
# github proxy
|
# GitHub proxy settings. If you are using a proxy, uncomment and replace the empty field with your proxy URL.
|
||||||
# PROXY="https://ghproxy.com/"
|
|
||||||
PROXY=
|
PROXY=
|
||||||
|
|
||||||
|
# If you have a GitHub token, replace the empty field with your token.
|
||||||
GITHUB_TOKEN=
|
GITHUB_TOKEN=
|
||||||
|
|
||||||
USER=root #no need to modify
|
# Default user is "root". If you need to modify it, uncomment and replace accordingly.
|
||||||
PASSWORD=openIM123 #A combination of 8 or more numbers and letters, this password applies to redis, mysql, mongo, as well as accessSecret in config/config.yaml
|
# USER=root
|
||||||
ENDPOINT=http://127.0.0.1:10005 #minio's external service IP and port, or use the domain name storage.xx.xx, the app must be able to access this IP and port or domain,
|
|
||||||
API_URL=http://127.0.0.1:10002/object/ #the app must be able to access this IP and port or domain,
|
# Default password for redis, mysql, mongo, as well as accessSecret in config/config.yaml.
|
||||||
DATA_DIR=./ #designate large disk directory, default is current directory
|
# Remember, it should be a combination of 8 or more numbers and letters. If you want to set a different password, uncomment and replace "openIM123".
|
||||||
|
# PASSWORD=openIM123
|
||||||
|
|
||||||
|
# Default endpoint for minio's external service IP and port. If you want to use a different endpoint, uncomment and replace.
|
||||||
|
# ENDPOINT=http://127.0.0.1:10005
|
||||||
|
|
||||||
|
# Default API_URL, replace if necessary.
|
||||||
|
# API_URL=http://127.0.0.1:10002/object/
|
||||||
|
|
||||||
|
# Default data directory. If you want to specify a different directory, uncomment and replace "./".
|
||||||
|
# DATA_DIR=./
|
||||||
|
|
||||||
############### OpenIM Functions ###############
|
############### OpenIM Functions ###############
|
||||||
# Install horizon of the script
|
# Install horizon of the script
|
||||||
@ -210,6 +236,7 @@ function download_source_code() {
|
|||||||
|
|
||||||
tar -xzvf "${DOWNLOAD_OPENIM_DIR}/${MODIFIED_TAG}.tar.gz" -C "$DOWNLOAD_OPENIM_DIR"
|
tar -xzvf "${DOWNLOAD_OPENIM_DIR}/${MODIFIED_TAG}.tar.gz" -C "$DOWNLOAD_OPENIM_DIR"
|
||||||
cd "$DOWNLOAD_OPENIM_DIR/$REPO-$MODIFIED_TAG"
|
cd "$DOWNLOAD_OPENIM_DIR/$REPO-$MODIFIED_TAG"
|
||||||
|
git init && git add . && git commit -m "init" --no-verify
|
||||||
|
|
||||||
success "Source code downloaded and extracted to $REPO-$MODIFIED_TAG"
|
success "Source code downloaded and extracted to $REPO-$MODIFIED_TAG"
|
||||||
}
|
}
|
||||||
@ -217,9 +244,40 @@ function download_source_code() {
|
|||||||
function set_openim_env() {
|
function set_openim_env() {
|
||||||
warn "This command can only be executed once. It will modify the component passwords in docker-compose based on the PASSWORD variable in .env, and modify the component passwords in config/config.yaml. If the password in .env changes, you need to first execute docker-compose down; rm components -rf and then execute this command."
|
warn "This command can only be executed once. It will modify the component passwords in docker-compose based on the PASSWORD variable in .env, and modify the component passwords in config/config.yaml. If the password in .env changes, you need to first execute docker-compose down; rm components -rf and then execute this command."
|
||||||
# Set default values for user input
|
# Set default values for user input
|
||||||
user="root"
|
# If the USER environment variable is not set, it defaults to 'root'
|
||||||
password="openIM123"
|
if [ -z "$USER" ]; then
|
||||||
endpoint="http://"
|
USER="root"
|
||||||
|
debug "USER is not set. Defaulting to 'root'."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If the PASSWORD environment variable is not set, it defaults to 'openIM123'
|
||||||
|
# This password applies to redis, mysql, mongo, as well as accessSecret in config/config.yaml
|
||||||
|
if [ -z "$PASSWORD" ]; then
|
||||||
|
PASSWORD="openIM123"
|
||||||
|
debug "PASSWORD is not set. Defaulting to 'openIM123'."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If the ENDPOINT environment variable is not set, it defaults to 'http://127.0.0.1:10005'
|
||||||
|
# This is minio's external service IP and port, or it could be a domain like storage.xx.xx
|
||||||
|
# The app must be able to access this IP and port or domain
|
||||||
|
if [ -z "$ENDPOINT" ]; then
|
||||||
|
ENDPOINT="http://127.0.0.1:10005"
|
||||||
|
debug "ENDPOINT is not set. Defaulting to 'http://127.0.0.1:10005'."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If the API_URL environment variable is not set, it defaults to 'http://127.0.0.1:10002/object/'
|
||||||
|
# The app must be able to access this IP and port or domain
|
||||||
|
if [ -z "$API_URL" ]; then
|
||||||
|
API_URL="http://127.0.0.1:10002/object/"
|
||||||
|
debug "API_URL is not set. Defaulting to 'http://127.0.0.1:10002/object/'."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If the DATA_DIR environment variable is not set, it defaults to the current directory './'
|
||||||
|
# This can be set to a directory with large disk space
|
||||||
|
if [ -z "$DATA_DIR" ]; then
|
||||||
|
DATA_DIR="./"
|
||||||
|
debug "DATA_DIR is not set. Defaulting to './'."
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_openim() {
|
function install_openim() {
|
||||||
@ -235,11 +293,12 @@ function install_openim() {
|
|||||||
############### OpenIM Help ###############
|
############### OpenIM Help ###############
|
||||||
|
|
||||||
# Function to display help message
|
# Function to display help message
|
||||||
display_help() {
|
function cmd_help() {
|
||||||
openim_color
|
openim_color
|
||||||
color_echo ${BRIGHT_GREEN_PREFIX} "Usage: $0 [options]"
|
color_echo ${BRIGHT_GREEN_PREFIX} "Usage: $0 [options]"
|
||||||
color_echo ${BRIGHT_GREEN_PREFIX} "Options:"
|
color_echo ${BRIGHT_GREEN_PREFIX} "Options:"
|
||||||
echo
|
echo
|
||||||
|
color_echo ${BLUE_PREFIX} "-i, --install ${CYAN_PREFIX}Execute the installation logic of the script${COLOR_SUFFIX}"
|
||||||
color_echo ${BLUE_PREFIX} "-u, --user ${CYAN_PREFIX}set user (default: root)${COLOR_SUFFIX}"
|
color_echo ${BLUE_PREFIX} "-u, --user ${CYAN_PREFIX}set user (default: root)${COLOR_SUFFIX}"
|
||||||
color_echo ${BLUE_PREFIX} "-p, --password ${CYAN_PREFIX}set password (default: openIM123)${COLOR_SUFFIX}"
|
color_echo ${BLUE_PREFIX} "-p, --password ${CYAN_PREFIX}set password (default: openIM123)${COLOR_SUFFIX}"
|
||||||
color_echo ${BLUE_PREFIX} "-e, --endpoint ${CYAN_PREFIX}set endpoint (default: http://127.0.0.1:10005)${COLOR_SUFFIX}"
|
color_echo ${BLUE_PREFIX} "-e, --endpoint ${CYAN_PREFIX}set endpoint (default: http://127.0.0.1:10005)${COLOR_SUFFIX}"
|
||||||
@ -255,42 +314,97 @@ display_help() {
|
|||||||
color_echo ${BLUE_PREFIX} "--cpu ${CYAN_PREFIX}set the number of concurrent processes${COLOR_SUFFIX}"
|
color_echo ${BLUE_PREFIX} "--cpu ${CYAN_PREFIX}set the number of concurrent processes${COLOR_SUFFIX}"
|
||||||
echo
|
echo
|
||||||
color_echo ${RED_PREFIX} "Note: Only one of the -t/--tag or -r/--release options can be used at a time.${COLOR_SUFFIX}"
|
color_echo ${RED_PREFIX} "Note: Only one of the -t/--tag or -r/--release options can be used at a time.${COLOR_SUFFIX}"
|
||||||
color_echo ${RED_PREFIX} "If both are used, the -t/--tag option will be prioritized.${COLOR_SUFFIX}"
|
color_echo ${RED_PREFIX} "If both are used or none of them are used, the -t/--tag option will be prioritized.${COLOR_SUFFIX}"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Use getopts to parse command line flags
|
function parseinput() {
|
||||||
while getopts ":h:u:p:e:a:d:" opt; do
|
# set default values
|
||||||
case ${opt} in
|
# USER=root
|
||||||
h )
|
# PASSWORD=openIM123
|
||||||
display_help
|
# ENDPOINT=http://127.0.0.1:10005
|
||||||
;;
|
# API=http://127.0.0.1:10002/object/
|
||||||
u )
|
# DIRECTORY=./
|
||||||
user=$OPTARG
|
# CHINA=false
|
||||||
;;
|
# TAG=latest
|
||||||
p )
|
# RELEASE=""
|
||||||
password=$OPTARG
|
# GO_VERSION=1.18
|
||||||
;;
|
# INSTALL_DIR=/tmp
|
||||||
e )
|
# GITHUB_TOKEN=""
|
||||||
endpoint=$OPTARG
|
# CPU=$(nproc)
|
||||||
;;
|
|
||||||
a )
|
if [ $# -eq 0 ]; then
|
||||||
api_url=$OPTARG
|
cmd_help
|
||||||
;;
|
exit 1
|
||||||
d )
|
fi
|
||||||
data_dir=$OPTARG
|
|
||||||
;;
|
while [ $# -gt 0 ]; do
|
||||||
\? )
|
case $1 in
|
||||||
echo "Invalid Option: -$OPTARG" 1>&2
|
-h|--help)
|
||||||
exit 1
|
cmd_help
|
||||||
;;
|
exit
|
||||||
: )
|
;;
|
||||||
echo "Invalid Option: -$OPTARG requires an argument" 1>&2
|
-u|--user)
|
||||||
exit 1
|
shift
|
||||||
;;
|
USER=$1
|
||||||
esac
|
;;
|
||||||
done
|
-p|--password)
|
||||||
|
shift
|
||||||
|
PASSWORD=$1
|
||||||
|
;;
|
||||||
|
-e|--endpoint)
|
||||||
|
shift
|
||||||
|
ENDPOINT=$1
|
||||||
|
;;
|
||||||
|
-a|--api)
|
||||||
|
shift
|
||||||
|
API=$1
|
||||||
|
;;
|
||||||
|
-d|--directory)
|
||||||
|
shift
|
||||||
|
DIRECTORY=$1
|
||||||
|
;;
|
||||||
|
-cn|--china)
|
||||||
|
CHINA=true
|
||||||
|
;;
|
||||||
|
-t|--tag)
|
||||||
|
shift
|
||||||
|
TAG=$1
|
||||||
|
;;
|
||||||
|
-r|--release)
|
||||||
|
shift
|
||||||
|
RELEASE=$1
|
||||||
|
;;
|
||||||
|
-g|--go-version)
|
||||||
|
shift
|
||||||
|
GO_VERSION=$1
|
||||||
|
;;
|
||||||
|
-i|--install-dir)
|
||||||
|
shift
|
||||||
|
INSTALL_DIR=$1
|
||||||
|
;;
|
||||||
|
-gt|--github-token)
|
||||||
|
shift
|
||||||
|
GITHUB_TOKEN=$1
|
||||||
|
;;
|
||||||
|
--cpu)
|
||||||
|
shift
|
||||||
|
CPU=$1
|
||||||
|
;;
|
||||||
|
-i|--install)
|
||||||
|
openim_main
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown option: $1"
|
||||||
|
cmd_help
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
############### OpenIM LOGO ###############
|
############### OpenIM LOGO ###############
|
||||||
# Set text color to cyan for header and URL
|
# Set text color to cyan for header and URL
|
||||||
@ -443,4 +557,4 @@ function openim_main() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
openim_main "$@"
|
parseinput "$@"
|
||||||
Loading…
x
Reference in New Issue
Block a user