]> source.dussan.org Git - gitea.git/commitdiff
Add custom.ini
authorUnknown <joe2010xtmf@163.com>
Tue, 11 Mar 2014 03:03:17 +0000 (23:03 -0400)
committerUnknown <joe2010xtmf@163.com>
Tue, 11 Mar 2014 03:03:17 +0000 (23:03 -0400)
.gitignore
conf/app.ini
models/models.go
modules/base/conf.go

index b0f80a57846537ecc0436cf11d1a4cec42229844..49d19b83d0aac8ff62300303839c69c43c8a5010 100644 (file)
@@ -3,4 +3,5 @@ gogs
 *.exe~
 .DS_Store
 *.db
-*.log
\ No newline at end of file
+*.log
+conf/custom.ini
\ No newline at end of file
index 1969dcba1c3e97c2bda071913ce8676e7a5284f5..fb425d81c0955221686daf2c42f43f354c9570d8 100644 (file)
@@ -3,7 +3,6 @@ RUN_USER = lunny
 
 [repository]
 ROOT = /Users/lunny/git/gogs-repositories
-ROOT_jiahuachen = /Users/jiahuachen/git/gogs-repositories
 
 [server]
 HTTP_ADDR = 
@@ -15,7 +14,6 @@ HOST =
 NAME = gogs
 USER = root
 PASSWD =
-PASSWD_jiahua = root
 
 [security]
 USER_PASSWD_SALT = !#@FDEWREWR&*(
index 7dfc0aaf0a821feaf823bfffe5164ad0c7bcced1..056682475909c09a11d984f064f253f5cac659de 100644 (file)
@@ -7,7 +7,6 @@ package models
 import (
        "fmt"
        "os"
-       "os/user"
 
        _ "github.com/go-sql-driver/mysql"
        "github.com/lunny/xorm"
@@ -47,16 +46,7 @@ func setEngine() {
        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",
@@ -83,9 +73,6 @@ func setEngine() {
        //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() {
index 19e9d689c2bad657786779b5327d810b50a29461..1240448c10a2eb563991cf4f834e713378aa79b5 100644 (file)
@@ -11,6 +11,7 @@ import (
        "path"
        "path/filepath"
 
+       "github.com/Unknwon/com"
        "github.com/Unknwon/goconfig"
 )
 
@@ -36,11 +37,20 @@ func init() {
                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
 }