summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-09-21 16:48:28 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-09-22 10:03:24 +0200
commit1966f9e786dfb67543401d181a374bd7f3856f37 (patch)
treef9fbc6628dd215c3287f8923956b4f19c97f7c1f
parentc6c53d11b08251056fba48f47b3e2349d6bed114 (diff)
Set default syncthing path.
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
-rw-r--r--.vscode/settings.json5
-rw-r--r--lib/xdsconfig/config.go13
2 files changed, 15 insertions, 3 deletions
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,