BillionMail gives you open-source MailServer, NewsLetter, Email Marketing — fully self-hosted, dev-friendly, and free from monthly fees. Join the discord: https://discord.gg/asfXzBUhZr
Modify the Settings command to get the host project directory
lotk1fb517193465
diff --git a/core/internal/controller/settings/settings.go b/core/internal/controller/settings/settings.goindex 3fac0af2..877efcb4 100644--- a/core/internal/controller/settings/settings.go+++ b/core/internal/controller/settings/settings.go@@ -145,12 +145,16 @@ func convertEnvToConfig(envMap map[string]string) *v1.SystemConfig {if port := envMap["HTTPS_PORT"]; port != "" {config.ManagePorts.HTTPS = parseInt(port, 443)}- config.ManagePorts.Command1 = fmt.Sprintf("cd %s && echo \"PORT\" | bash bm.sh change-port", projectPath)- config.ManagePorts.Command2 = fmt.Sprintf("cd %s && echo \"PORT\" | bash bm.sh change-apply-ssl-port", projectPath)+ HostWorkDir, err := public.GetHostWorkDir()+ if err != nil {+ HostWorkDir = projectPath+ }+ config.ManagePorts.Command1 = fmt.Sprintf("cd %s && echo \"PORT\" | bash bm.sh change-port", HostWorkDir)+ config.ManagePorts.Command2 = fmt.Sprintf("cd %s && echo \"PORT\" | bash bm.sh change-apply-ssl-port", HostWorkDir)// Time zone configurationconfig.ManageTimeZone.TimeZone = envMap["TZ"]- config.ManageTimeZone.Command = fmt.Sprintf("cd %s && echo \"TIME ZONE\" | bash bm.sh change-tz", projectPath)+ config.ManageTimeZone.Command = fmt.Sprintf("cd %s && echo \"TIME ZONE\" | bash bm.sh change-tz", HostWorkDir)// Network configurationconfig.IPv4Network = envMap["IPV4_NETWORK"]@@ -232,3 +236,34 @@ func validateConfigValue(key, value string) error {return nil}++//func getHostWorkDir() (string, error) {+// public.DockerApiFromCtx()+// dockerapi, err := docker.NewDockerAPI()+// if err != nil {+// return "", fmt.Errorf("failed to initialize docker client: %w", err)+// }+//+// containerName := "billionmail-core-billionmail-1"+// ctx := context.Background()+//+// container, err := dockerapi.GetContainerByName(ctx, containerName)+// if err != nil {+// return "", fmt.Errorf("failed to get container '%s': %w", containerName, err)+// }+//+// if container.Labels == nil {+// return "", fmt.Errorf("container '%s' has no labels", containerName)+// }+//+// workingDir, exists := container.Labels["com.docker.compose.project.working_dir"]+// if !exists {+// return "", fmt.Errorf("container '%s' missing working directory label", containerName)+// }+//+// if workingDir == "" {+// return "", fmt.Errorf("working directory label is empty for container '%s'", containerName)+// }+//+// return workingDir, nil+//}diff --git a/core/internal/service/public/common.go b/core/internal/service/public/common.goindex bcaba01a..1669f409 100644--- a/core/internal/service/public/common.go+++ b/core/internal/service/public/common.go@@ -2641,3 +2641,33 @@ func LoadEnvFile() (map[string]string, error) {return envMap, nil}++func GetHostWorkDir() (string, error) {+ dockerapi, err := docker.NewDockerAPI()+ if err != nil {+ return "", fmt.Errorf("failed to initialize docker client: %w", err)+ }++ containerName := "billionmail-core-billionmail-1"+ ctx := context.Background()++ container, err := dockerapi.GetContainerByName(ctx, containerName)+ if err != nil {+ return "", fmt.Errorf("failed to get container '%s': %w", containerName, err)+ }++ if container.Labels == nil {+ return "", fmt.Errorf("container '%s' has no labels", containerName)+ }++ workingDir, exists := container.Labels["com.docker.compose.project.working_dir"]+ if !exists {+ return "", fmt.Errorf("container '%s' missing working directory label", containerName)+ }++ if workingDir == "" {+ return "", fmt.Errorf("working directory label is empty for container '%s'", containerName)+ }++ return workingDir, nil+}