|
|
@ -64,6 +64,7 @@ var ( |
|
|
|
StartSSHServer bool |
|
|
|
StartSSHServer bool |
|
|
|
SSHDomain string |
|
|
|
SSHDomain string |
|
|
|
SSHPort int |
|
|
|
SSHPort int |
|
|
|
|
|
|
|
SSHRootPath string |
|
|
|
OfflineMode bool |
|
|
|
OfflineMode bool |
|
|
|
DisableRouterLog bool |
|
|
|
DisableRouterLog bool |
|
|
|
CertFile, KeyFile string |
|
|
|
CertFile, KeyFile string |
|
|
@ -273,10 +274,16 @@ func NewContext() { |
|
|
|
log.Fatal(4, "Fail to load custom conf '%s': %v", CustomConf, err) |
|
|
|
log.Fatal(4, "Fail to load custom conf '%s': %v", CustomConf, err) |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} 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 |
|
|
|
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")) |
|
|
|
LogRootPath = Cfg.Section("log").Key("ROOT_PATH").MustString(path.Join(workDir, "log")) |
|
|
|
forcePathSeparator(LogRootPath) |
|
|
|
forcePathSeparator(LogRootPath) |
|
|
|
|
|
|
|
|
|
|
@ -290,7 +297,7 @@ func NewContext() { |
|
|
|
// Check if has app suburl.
|
|
|
|
// Check if has app suburl.
|
|
|
|
url, err := url.Parse(AppUrl) |
|
|
|
url, err := url.Parse(AppUrl) |
|
|
|
if err != nil { |
|
|
|
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, "/") |
|
|
|
AppSubUrl = strings.TrimSuffix(url.Path, "/") |
|
|
|
|
|
|
|
|
|
|
@ -312,6 +319,10 @@ func NewContext() { |
|
|
|
} |
|
|
|
} |
|
|
|
SSHDomain = sec.Key("SSH_DOMAIN").MustString(Domain) |
|
|
|
SSHDomain = sec.Key("SSH_DOMAIN").MustString(Domain) |
|
|
|
SSHPort = sec.Key("SSH_PORT").MustInt(22) |
|
|
|
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() |
|
|
|
OfflineMode = sec.Key("OFFLINE_MODE").MustBool() |
|
|
|
DisableRouterLog = sec.Key("DISABLE_ROUTER_LOG").MustBool() |
|
|
|
DisableRouterLog = sec.Key("DISABLE_ROUTER_LOG").MustBool() |
|
|
|
StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(workDir) |
|
|
|
StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(workDir) |
|
|
@ -368,12 +379,6 @@ func NewContext() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Determine and create root git repository path.
|
|
|
|
// 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") |
|
|
|
sec = Cfg.Section("repository") |
|
|
|
RepoRootPath = sec.Key("ROOT").MustString(path.Join(homeDir, "gogs-repositories")) |
|
|
|
RepoRootPath = sec.Key("ROOT").MustString(path.Join(homeDir, "gogs-repositories")) |
|
|
|
forcePathSeparator(RepoRootPath) |
|
|
|
forcePathSeparator(RepoRootPath) |
|
|
|