fix: fix scripts

Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
pull/1508/head
Xinwei Xiong(cubxxw) 2 years ago
parent 3b74ad56d4
commit 104e69ecd4

@ -35,6 +35,8 @@ declare -A TEMPLATES=(
["${OPENIM_ROOT}/deployments/templates/alertmanager.yml"]="${OPENIM_ROOT}/config/alertmanager.yml" ["${OPENIM_ROOT}/deployments/templates/alertmanager.yml"]="${OPENIM_ROOT}/config/alertmanager.yml"
) )
openim::log::info "Read more configuration information: https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md"
for template in "${!TEMPLATES[@]}"; do for template in "${!TEMPLATES[@]}"; do
if [[ ! -f "${template}" ]]; then if [[ ! -f "${template}" ]]; then
openim::log::error_exit "template file ${template} does not exist..." openim::log::error_exit "template file ${template} does not exist..."
@ -42,6 +44,16 @@ for template in "${!TEMPLATES[@]}"; do
IFS=';' read -ra OUTPUT_FILES <<< "${TEMPLATES[$template]}" IFS=';' read -ra OUTPUT_FILES <<< "${TEMPLATES[$template]}"
for output_file in "${OUTPUT_FILES[@]}"; do for output_file in "${OUTPUT_FILES[@]}"; do
if [[ -f "${output_file}" ]]; then
read -p "File ${output_file} already exists. Overwrite? (Y/N): " -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
openim::log::info "Overwriting ${output_file}. Previous configuration will be lost."
else
openim::log::info "Skipping generation of ${output_file}."
continue
fi
fi
openim::log::info "⌚ Working with template file: ${template} to ${output_file}..." openim::log::info "⌚ Working with template file: ${template} to ${output_file}..."
"${OPENIM_ROOT}/scripts/genconfig.sh" "${ENV_FILE}" "${template}" > "${output_file}" || { "${OPENIM_ROOT}/scripts/genconfig.sh" "${ENV_FILE}" "${template}" > "${output_file}" || {
openim::log::error "Error processing template file ${template}" openim::log::error "Error processing template file ${template}"

@ -61,6 +61,7 @@ openim::tools::pre_start_name() {
local targets=( local targets=(
ncpu ncpu
component component
up35
) )
echo "${targets[@]}" echo "${targets[@]}"
} }

@ -5,13 +5,12 @@ import (
"errors" "errors"
"flag" "flag"
"fmt" "fmt"
"log"
"os"
"path/filepath"
"reflect"
"strconv"
"github.com/go-sql-driver/mysql" "github.com/go-sql-driver/mysql"
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
"github.com/openimsdk/open-im-server/v3/pkg/common/db/mgo"
mongoModel "github.com/openimsdk/open-im-server/v3/pkg/common/db/table/relation"
"github.com/openimsdk/open-im-server/v3/pkg/common/db/unrelation"
mysqlModel "github.com/openimsdk/open-im-server/v3/tools/data-conversion/openim/mysql/v3"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/mongo/options"
@ -19,12 +18,10 @@ import (
gormMysql "gorm.io/driver/mysql" gormMysql "gorm.io/driver/mysql"
"gorm.io/gorm" "gorm.io/gorm"
"gorm.io/gorm/logger" "gorm.io/gorm/logger"
"log"
"github.com/openimsdk/open-im-server/v3/pkg/common/config" "os"
"github.com/openimsdk/open-im-server/v3/pkg/common/db/mgo" "reflect"
mongoModel "github.com/openimsdk/open-im-server/v3/pkg/common/db/table/relation" "strconv"
"github.com/openimsdk/open-im-server/v3/pkg/common/db/unrelation"
mysqlModel "github.com/openimsdk/open-im-server/v3/tools/data-conversion/openim/mysql/v3"
) )
const ( const (
@ -34,12 +31,9 @@ const (
) )
func main() { func main() {
var dir string var path string
flag.StringVar(&dir, "c", "../../../../../", "path to config directory") flag.StringVar(&path, "c", "", "path config file")
flag.Parse() flag.Parse()
path := filepath.Join(dir, "config.yaml")
if err := Main(path); err != nil { if err := Main(path); err != nil {
log.Fatal(err) log.Fatal(err)
return return

Loading…
Cancel
Save