diff --git a/scripts/init-config.sh b/scripts/init-config.sh index a4672c62d..2c222e262 100755 --- a/scripts/init-config.sh +++ b/scripts/init-config.sh @@ -35,6 +35,8 @@ declare -A TEMPLATES=( ["${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 if [[ ! -f "${template}" ]]; then 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]}" 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_ROOT}/scripts/genconfig.sh" "${ENV_FILE}" "${template}" > "${output_file}" || { openim::log::error "Error processing template file ${template}" diff --git a/scripts/install/openim-tools.sh b/scripts/install/openim-tools.sh index fd95dc00d..f97b9d836 100755 --- a/scripts/install/openim-tools.sh +++ b/scripts/install/openim-tools.sh @@ -61,6 +61,7 @@ openim::tools::pre_start_name() { local targets=( ncpu component + up35 ) echo "${targets[@]}" } diff --git a/tools/up35/up35.go b/tools/up35/up35.go index 2b7daf9f9..5d4740fca 100644 --- a/tools/up35/up35.go +++ b/tools/up35/up35.go @@ -5,13 +5,12 @@ import ( "errors" "flag" "fmt" - "log" - "os" - "path/filepath" - "reflect" - "strconv" - "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/mongo" "go.mongodb.org/mongo-driver/mongo/options" @@ -19,12 +18,10 @@ import ( gormMysql "gorm.io/driver/mysql" "gorm.io/gorm" "gorm.io/gorm/logger" - - "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" + "log" + "os" + "reflect" + "strconv" ) const ( @@ -34,12 +31,9 @@ const ( ) func main() { - var dir string - flag.StringVar(&dir, "c", "../../../../../", "path to config directory") + var path string + flag.StringVar(&path, "c", "", "path config file") flag.Parse() - - path := filepath.Join(dir, "config.yaml") - if err := Main(path); err != nil { log.Fatal(err) return