Skip to content

Commit

Permalink
Merge pull request #897 from signal18/clean-up
Browse files Browse the repository at this point in the history
Clean up previous release
  • Loading branch information
svaroqui authored Oct 3, 2024
2 parents 69e996b + 26d1405 commit e5da065
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ non-cgo: osc tst pro arb cli emb

tar: osc-basedir tst-basedir pro-basedir osc-cgo-basedir

osc pro emb pro-basedir osc-basedir: react
pro emb pro-basedir : react

react:
$(Building react frontend $(REACT))
Expand Down
40 changes: 24 additions & 16 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -913,34 +913,37 @@ func (repman *ReplicationManager) OverwriteParameterFlags(destViper *viper.Viper

}

func (repman *ReplicationManager) initEmbedOrExtraConfDir() error {
func (repman *ReplicationManager) initEmbed() error {
//test si y'a un repertoire ./.replication-manager sinon on le créer
//test si y'a un repertoire ./.replication-manager/config.toml sinon on le créer depuis embed
//test y'a un repertoire ./.replication-manager/data sinon on le créer
//test y'a un repertoire ./.replication-manager/share sinon on le créer
if _, err := os.Stat(repman.GetExtraConfigDir()); os.IsNotExist(err) {
os.MkdirAll(repman.GetExtraConfigDir(), os.ModePerm)
os.MkdirAll(repman.GetExtraConfigDir()+"/clsuter.d", os.ModePerm)
if conf.WithEmbed == "ON" {
os.MkdirAll(repman.GetExtraDataDir()+"/data", os.ModePerm)
os.MkdirAll(repman.GetExtraDataDir()+"/share", os.ModePerm)
}
if _, err := os.Stat("./.replication-manager"); os.IsNotExist(err) {
os.MkdirAll("./.replication-manager", os.ModePerm)
os.MkdirAll("./.replication-manager/data", os.ModePerm)
os.MkdirAll("./.replication-manager/share", os.ModePerm)
os.MkdirAll("./.replication-manager/cluster.d", os.ModePerm)
}

if _, err := os.Stat(repman.GetExtraConfigDir() + "/config.toml"); os.IsNotExist(err) {
if _, err := os.Stat("./replication-manager"); os.IsNotExist(err) {
os.MkdirAll("./replication-manager", os.ModePerm)
os.MkdirAll("./replication-manager/data", os.ModePerm)
os.MkdirAll("./replication-manager/share", os.ModePerm)
}

file, err := etc.EmbededDbModuleFS.ReadFile("local/embed/config.toml")
if _, err := os.Stat("./.replication-manager/config.toml"); os.IsNotExist(err) {

file, err := etc.EmbededDbModuleFS.ReadFile("local/embed/config.toml")
if err != nil {
repman.Logrus.Errorf("failed opening file because: %s", err.Error())
return err
}
err = os.WriteFile(repman.GetExtraConfigDir()+"/config.toml", file, 0644) //remplacer nil par l'obj créer pour config.toml dans etc/local/embed
err = os.WriteFile("./.replication-manager/config.toml", file, 0644) //remplacer nil par l'obj créer pour config.toml dans etc/local/embed
if err != nil {
repman.Logrus.Errorf("failed write file because: %s", err.Error())
return err
}
if _, err := os.Stat(repman.GetExtraConfigDir() + "/config.toml"); os.IsNotExist(err) {
if _, err := os.Stat("./.replication-manager/config.toml"); os.IsNotExist(err) {
repman.Logrus.Errorf("failed create ./.replication-manager/config.toml file because: %s", err.Error())
return err
}
Expand All @@ -960,8 +963,10 @@ func (repman *ReplicationManager) InitConfig(conf config.Config) {
repman.cloud18CheckSum = nil
// call after init if configuration file is provide

// create extra user config and if repman is embed, create folders and load missing embedded files
repman.initEmbedOrExtraConfDir()
//if repman is embed, create folders and load missing embedded files
if conf.WithEmbed == "ON" {
repman.initEmbed()
}

//init viper to read config file .toml
fistRead := viper.GetViper()
Expand All @@ -984,7 +989,7 @@ func (repman *ReplicationManager) InitConfig(conf config.Config) {
if conf.WithEmbed == "OFF" {
fistRead.AddConfigPath("/etc/replication-manager/")
} else {
fistRead.AddConfigPath(repman.GetExtraConfigDir() + "")
fistRead.AddConfigPath("./.replication-manager")
}
fistRead.AddConfigPath(".")

Expand All @@ -997,7 +1002,7 @@ func (repman *ReplicationManager) InitConfig(conf config.Config) {
}
//if embed, add config path
if conf.WithEmbed == "ON" {
if _, err := os.Stat(repman.GetExtraConfigDir() + "/config.toml"); os.IsNotExist(err) {
if _, err := os.Stat("./.replication-manager/config.toml"); os.IsNotExist(err) {
repman.Logrus.Warning("No config file ./.replication-manager/config.toml ")
}
} else {
Expand Down Expand Up @@ -1645,6 +1650,9 @@ func (repman *ReplicationManager) Run() error {

repman.initKeys()

if WithProvisioning != "ON" {
repman.Conf.HttpUseReact = false
}
// repman.currentCluster.SetCfgGroupDisplay(strClusters)
if repman.Conf.ApiServ {
go repman.apiserver()
Expand Down

0 comments on commit e5da065

Please sign in to comment.