diff options
author | Unknwon <u@gogs.io> | 2015-12-19 21:43:32 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-12-19 21:43:32 -0500 |
commit | 53eb37d5292942e8f6d667f9a6fb9d35455d2967 (patch) | |
tree | a5386fe64d7dfd31767423b613dcd765893f4d99 /modules/setting/setting.go | |
parent | 3bcdb3855cffb916944923e7442c929ff94d4574 (diff) |
fix #1436
Diffstat (limited to 'modules/setting/setting.go')
-rw-r--r-- | modules/setting/setting.go | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 67f2f158..0ab0eafa 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -64,6 +64,7 @@ var ( StartSSHServer bool SSHDomain string SSHPort int + SSHRootPath string OfflineMode bool DisableRouterLog bool CertFile, KeyFile string @@ -273,10 +274,16 @@ func NewContext() { log.Fatal(4, "Fail to load custom conf '%s': %v", CustomConf, err) } } else { - log.Warn("Custom config (%s) not found, ignore this if you're running first time", CustomConf) + log.Warn("Custom config '%s' not found, ignore this if you're running first time", CustomConf) } Cfg.NameMapper = ini.AllCapsUnderscore + homeDir, err := com.HomeDir() + if err != nil { + log.Fatal(4, "Fail to get home directory: %v", err) + } + homeDir = strings.Replace(homeDir, "\\", "/", -1) + LogRootPath = Cfg.Section("log").Key("ROOT_PATH").MustString(path.Join(workDir, "log")) forcePathSeparator(LogRootPath) @@ -290,7 +297,7 @@ func NewContext() { // Check if has app suburl. url, err := url.Parse(AppUrl) if err != nil { - log.Fatal(4, "Invalid ROOT_URL(%s): %s", AppUrl, err) + log.Fatal(4, "Invalid ROOT_URL '%s': %s", AppUrl, err) } AppSubUrl = strings.TrimSuffix(url.Path, "/") @@ -312,6 +319,10 @@ func NewContext() { } SSHDomain = sec.Key("SSH_DOMAIN").MustString(Domain) SSHPort = sec.Key("SSH_PORT").MustInt(22) + SSHRootPath = sec.Key("SSH_ROOT_PATH").MustString(path.Join(homeDir, ".ssh")) + if err := os.MkdirAll(SSHRootPath, 0700); err != nil { + log.Fatal(4, "Fail to create '%s': %v", SSHRootPath, err) + } OfflineMode = sec.Key("OFFLINE_MODE").MustBool() DisableRouterLog = sec.Key("DISABLE_ROUTER_LOG").MustBool() StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(workDir) @@ -368,12 +379,6 @@ func NewContext() { } // Determine and create root git repository path. - homeDir, err := com.HomeDir() - if err != nil { - log.Fatal(4, "Fail to get home directory: %v", err) - } - homeDir = strings.Replace(homeDir, "\\", "/", -1) - sec = Cfg.Section("repository") RepoRootPath = sec.Key("ROOT").MustString(path.Join(homeDir, "gogs-repositories")) forcePathSeparator(RepoRootPath) |