From 342c85fafaa4eac3c1a45a8d038b0c4e2d8c8512 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 Jun 2023 23:25:43 +0800 Subject: [PATCH] feat: Initialize the root directory main script file Signed-off-by: unknown --- install_guide.sh | 177 ++++++++++++++++++++++++++++++++++++++++++ install_im_compose.sh | 21 +++++ install_im_server.sh | 19 +++++ 3 files changed, 217 insertions(+) create mode 100644 install_guide.sh create mode 100644 install_im_compose.sh create mode 100644 install_im_server.sh diff --git a/install_guide.sh b/install_guide.sh new file mode 100644 index 000000000..b0067396a --- /dev/null +++ b/install_guide.sh @@ -0,0 +1,177 @@ +#!/bin/bash + +echo "Welcome to the Open-IM-Server installation script." +echo "Please select an deploy option:" +echo "1. docker-compose install" +echo "2. exit" + +clear_openimlog() { + rm -rf ./logs/* +} + +is_path() { + if [ -e "$1" ]; then + return 1 + else + return 0 + fi +} + +is_empty() { + if [ -z "$1" ]; then + return 1 + else + return 0 + fi +} + +is_directory_exists() { + if [ -d "$1" ]; then + return 1 + else + return 0 + fi +} + +edit_config() { + echo "Is edit config.yaml?" + echo "1. vi edit config" + echo "2. do not edit config" + read choice + case $choice in + 1) + vi config/config.yaml + ;; + 2) + echo "do not edit config" + ;; + esac +} + +edit_enterprise_config() { + echo "Is edit enterprise config.yaml?" + echo "1. vi edit enterprise config" + echo "2. do not edit enterprise config" + read choice + case $choice in + 1) + vi ./.docker-compose_cfg/config.yaml + ;; + 2) + echo "Do not edit enterprise config" + ;; + esac +} + +install_docker_compose() { + echo "Please input the installation path, default is $(pwd)/Open-IM-Server, press enter to use default" + read install_path + is_empty $install_path + if [ $? -eq 1 ]; then + install_path="." + fi + echo "Installing Open-IM-Server to ${install_path}/Open-IM-Server..." + is_path $install_path + mkdir -p $install_path + cd $install_path + is_directory_exists "${install_path}/Open-IM-Server" + if [ $? -eq 1 ]; then + echo "WARNING: Directory $install_path/Open-IM-Server exist, please ensure your path" + echo "1. delete the directory and install" + echo "2. exit" + read choice + case $choice in + 1) + rm -rf "${install_path}/Open-IM-Server" + ;; + 2) + exit 1 + ;; + esac + fi + rm -rf ./Open-IM-Server + set -e + git clone https://github.com/OpenIMSDK/Open-IM-Server.git --recursive; + set +e + cd ./Open-IM-Server + git checkout errcode + echo "======== git clone success ========" + source .env + if [ $DATA_DIR = "./" ]; then + DATA_DIR=$(pwd)/components + fi + echo "Please input the components data directory, deault is ${DATA_DIR}, press enter to use default" + read NEW_DATA_DIR + is_empty $NEW_DATA_DIR + if [ $? -eq 0 ]; then + DATA_DIR=$NEW_DATA_DIR + fi + echo "Please input the user, deault is root, press enter to use default" + read NEW_USER + is_empty $NEW_USER + if [ $? -eq 0 ]; then + USER=$NEW_USER + fi + + echo "Please input the password, default is openIM123, press enter to use default" + read NEW_PASSWORD + is_empty $NEW_PASSWORD + if [ $? -eq 0 ]; then + PASSWORD=$NEW_PASSWORD + fi + + echo "Please input the minio_endpoint, default will detect auto, press enter to use default" + read NEW_MINIO_ENDPOINT + is_empty $NEW_MINIO_ENDPOINT + if [ $? -eq 1 ]; then + internet_ip=`curl ifconfig.me -s` + MINIO_ENDPOINT="http://${internet_ip}:10005" + else + MINIO_ENDPOINT=$NEW_MINIO_ENDPOINT + fi + set -e + export MINIO_ENDPOINT + export USER + export PASSWORD + export DATA_DIR + + cat < .env +USER=${USER} +PASSWORD=${PASSWORD} +MINIO_ENDPOINT=${MINIO_ENDPOINT} +DATA_DIR=${DATA_DIR} +EOF + + edit_config + edit_enterprise_config + + cd script; + chmod +x *.sh; + ./init_pwd.sh; + ./env_check.sh; + cd ..; + docker-compose up -d; + cd script; + ./docker_check_service.sh; +} + +read choice + +case $choice in + 1) + install_docker_compose + ;; + 2) + + ;; + 3) + ;; + 4) + echo "Exiting installation script..." + exit 0 + ;; + *) + echo "Invalid option, please try again." + ;; +esac + diff --git a/install_im_compose.sh b/install_im_compose.sh new file mode 100644 index 000000000..36d3a4b73 --- /dev/null +++ b/install_im_compose.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +internet_ip=`curl ifconfig.me -s` +echo $internet_ip + +source .env +echo $MINIO_ENDPOINT +if [ $MINIO_ENDPOINT == "http://127.0.0.1:10005" ]; then + sed -i "s/127.0.0.1/${internet_ip}/" .env + +fi + +cd script ; +chmod +x *.sh ; +./init_pwd.sh +./env_check.sh; +cd .. ; +docker-compose -f im-compose.yaml up -d +docker ps + + + diff --git a/install_im_server.sh b/install_im_server.sh new file mode 100644 index 000000000..ea641d0f8 --- /dev/null +++ b/install_im_server.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +internet_ip=`curl ifconfig.me -s` +echo $internet_ip + +source .env +echo $MINIO_ENDPOINT +if [ $MINIO_ENDPOINT == "http://127.0.0.1:10005" ]; then + sed -i "s/127.0.0.1/${internet_ip}/" .env + +fi + +cd script ; +chmod +x *.sh ; +./init_pwd.sh +./env_check.sh; +cd .. ; +docker-compose up -d; +cd script ; +./docker_check_service.sh