diff --git a/config.example.yml b/config.example.yml index d7403e6..4d19ee3 100644 --- a/config.example.yml +++ b/config.example.yml @@ -12,3 +12,4 @@ redis: port: 6379 system: verify: false + mount_dir: /path/to/mount diff --git a/services/config/config.go b/services/config/config.go index eb63ce5..2d722f6 100644 --- a/services/config/config.go +++ b/services/config/config.go @@ -41,8 +41,9 @@ type logStruct struct { } type systemStruct struct { - Salt string `yaml:"salt,omitempty"` - Verify bool `yaml:"verify,omitempty"` + Salt string `yaml:"salt,omitempty"` + Verify bool `yaml:"verify,omitempty"` + MountDir string `yaml:"mount_dir,omitempty"` } var config = configStruct{ diff --git a/services/config/exporter.go b/services/config/exporter.go index f25337f..2c7f5e1 100644 --- a/services/config/exporter.go +++ b/services/config/exporter.go @@ -53,6 +53,10 @@ func GetSystemVerify() bool { return config.GetSystemVerify() } +func GetSystemMountDir() string { + return config.GetSystemMountDir() +} + func Save() error { return config.Save() } diff --git a/services/config/internal.go b/services/config/internal.go index 29fa092..256944c 100644 --- a/services/config/internal.go +++ b/services/config/internal.go @@ -40,6 +40,10 @@ func (c *configStruct) GetSystemVerify() bool { return c.System.Verify } +func (c *configStruct) GetSystemMountDir() string { + return c.System.MountDir +} + func (c *configStruct) Save() error { return c.save() } diff --git a/services/instanceController/createInstance.go b/services/instanceController/createInstance.go index 88e55c3..09b41d0 100644 --- a/services/instanceController/createInstance.go +++ b/services/instanceController/createInstance.go @@ -6,6 +6,7 @@ import ( "errors" "megrez/libs/crypto" "megrez/libs/request" + "megrez/services/config" "strconv" ) @@ -56,13 +57,16 @@ func createInstance(ip string, port int, apikey string, Src: volumeName, Dest: "/root/megrez-tmp", }, - { - Src: "/data/pub", - Dest: "/root/megrez-pub", - }, } } + if config.GetSystemMountDir() != "" { + data.Binds = append(data.Binds, bindStruct{ + Src: config.GetSystemMountDir(), + Dest: "/root/megrez", + }) + } + reqBytes, err := json.Marshal(data) if err != nil { l.Error("marshal request data error: %v", err)