From: Sebastien Douheret Date: Thu, 21 Sep 2017 14:48:28 +0000 (+0200) Subject: Set default syncthing path. X-Git-Tag: v0.3.1~9 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?p=src%2Fxds%2Fxds-server.git;a=commitdiff_plain;h=1966f9e786dfb67543401d181a374bd7f3856f37 Set default syncthing path. Signed-off-by: Sebastien Douheret --- diff --git a/.vscode/settings.json b/.vscode/settings.json index 4f2a394..826f7fd 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -54,6 +54,7 @@ "eows", "mfolders", "IFOLDER", - "flds" + "flds", + "dflt" ] -} \ No newline at end of file +} diff --git a/lib/xdsconfig/config.go b/lib/xdsconfig/config.go index f3cba4a..84e0778 100644 --- a/lib/xdsconfig/config.go +++ b/lib/xdsconfig/config.go @@ -38,6 +38,7 @@ const ( DefaultAPIVersion = "1" DefaultPort = "8000" DefaultShareDir = "${HOME}/.xds-server/projects" + DefaultSTHomeDir = "${HOME}/.xds-server/syncthing-config" DefaultSdkRootDir = "/xdt/sdk" ) @@ -45,6 +46,15 @@ const ( func Init(cliCtx *cli.Context, log *logrus.Logger) (*Config, error) { var err error + dfltShareDir := DefaultShareDir + dfltSTHomeDir := DefaultSTHomeDir + if resDir, err := common.ResolveEnvVar(DefaultShareDir); err == nil { + dfltShareDir = resDir + } + if resDir, err := common.ResolveEnvVar(DefaultSTHomeDir); err == nil { + dfltSTHomeDir = resDir + } + // Define default configuration c := Config{ Version: cliCtx.App.Metadata["version"].(string), @@ -60,9 +70,10 @@ func Init(cliCtx *cli.Context, log *logrus.Logger) (*Config, error) { }, FileConf: FileConfig{ WebAppDir: "webapp/dist", - ShareRootDir: DefaultShareDir, + ShareRootDir: dfltShareDir, SdkRootDir: DefaultSdkRootDir, HTTPPort: DefaultPort, + SThgConf: &SyncThingConf{Home: dfltSTHomeDir}, LogsDir: "", }, Log: log,