*.exe~
.DS_Store
*.db
-*.log
\ No newline at end of file
+*.log
+conf/custom.ini
\ No newline at end of file
[repository]
ROOT = /Users/lunny/git/gogs-repositories
-ROOT_jiahuachen = /Users/jiahuachen/git/gogs-repositories
[server]
HTTP_ADDR =
NAME = gogs
USER = root
PASSWD =
-PASSWD_jiahua = root
[security]
USER_PASSWD_SALT = !#@FDEWREWR&*(
import (
"fmt"
"os"
- "os/user"
_ "github.com/go-sql-driver/mysql"
"github.com/lunny/xorm"
dbUser := base.Cfg.MustValue("database", "USER")
dbPwd := base.Cfg.MustValue("database", "PASSWD")
- uname, err := user.Current()
- if err != nil {
- fmt.Printf("models.init -> fail to get user: %s\n", err)
- os.Exit(2)
- }
-
- if uname.Username == "jiahuachen" {
- dbPwd = base.Cfg.MustValue("database", "PASSWD_jiahua")
- }
-
+ var err error
switch dbType {
case "mysql":
orm, err = xorm.NewEngine("mysql", fmt.Sprintf("%v:%v@%v/%v?charset=utf8",
//log.Trace("Initialized database -> %s", dbName)
RepoRootPath = base.Cfg.MustValue("repository", "ROOT")
- if uname.Username == "jiahuachen" {
- RepoRootPath = base.Cfg.MustValue("repository", "ROOT_jiahuachen")
- }
}
func init() {
"path"
"path/filepath"
+ "github.com/Unknwon/com"
"github.com/Unknwon/goconfig"
)
os.Exit(2)
}
- cfgPath := filepath.Join(workDir, "conf", "app.ini")
+ cfgPathPrefix := filepath.Join(workDir, "conf")
+ cfgPath := filepath.Join(cfgPathPrefix, "app.ini")
Cfg, err = goconfig.LoadConfigFile(cfgPath)
if err != nil {
fmt.Printf("Cannot load config file '%s'\n", cfgPath)
os.Exit(2)
}
+
+ cfgPath = filepath.Join(cfgPathPrefix, "custom.ini")
+ if com.IsFile(cfgPath) {
+ if err = Cfg.AppendFiles(cfgPath); err != nil {
+ fmt.Printf("Cannot load config file '%s'\n", cfgPath)
+ os.Exit(2)
+ }
+ }
Cfg.BlockMode = false
}