Action: runDump,
Flags: []cli.Flag{
cli.BoolFlag{"verbose, v", "show process details", ""},
+ cli.StringFlag{"config, c", "custom/conf/app.ini", "Configuration file", ""},
},
}
func runDump(ctx *cli.Context) {
+ if ctx.IsSet("config") {
+ setting.CustomConf = ctx.String("config")
+ }
setting.NewConfigContext()
models.LoadModelsConfig()
models.SetEngine()
Usage: "This command should only be called by SSH shell",
Description: `Serv provide access auth for repositories`,
Action: runServ,
- Flags: []cli.Flag{},
+ Flags: []cli.Flag{
+ cli.StringFlag{"config, c", "custom/conf/app.ini", "Configuration file", ""},
+ },
}
func setup(logPath string) {
}
func runServ(k *cli.Context) {
+ if k.IsSet("config") {
+ setting.CustomConf = k.String("config")
+ }
setup("serv.log")
keys := strings.Split(os.Args[2], "-")
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/log"
+ "github.com/gogits/gogs/modules/setting"
)
var CmdUpdate = cli.Command{
Usage: "This command should only be called by SSH shell",
Description: `Update get pushed info and insert into database`,
Action: runUpdate,
- Flags: []cli.Flag{},
+ Flags: []cli.Flag{
+ cli.StringFlag{"config, c", "custom/conf/app.ini", "Configuration file", ""},
+ },
}
func runUpdate(c *cli.Context) {
+ if c.IsSet("config") {
+ setting.CustomConf = c.String("config")
+ }
cmd := os.Getenv("SSH_ORIGINAL_COMMAND")
if cmd == "" {
return
Action: runWeb,
Flags: []cli.Flag{
cli.StringFlag{"port, p", "3000", "Temporary port number to prevent conflict", ""},
+ cli.StringFlag{"config, c", "custom/conf/app.ini", "Configuration file", ""},
},
}
}
func runWeb(ctx *cli.Context) {
+ if ctx.IsSet("config") {
+ setting.CustomConf = ctx.String("config")
+ }
routers.GlobalInit()
checkVersion()
const (
// "### autogenerated by gitgos, DO NOT EDIT\n"
- _TPL_PUBLICK_KEY = `command="%s serv key-%d",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty %s` + "\n"
+ _TPL_PUBLICK_KEY = `command="%s serv --config=%s key-%d",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty %s` + "\n"
)
var (
// GetAuthorizedString generates and returns formatted public key string for authorized_keys file.
func (key *PublicKey) GetAuthorizedString() string {
- return fmt.Sprintf(_TPL_PUBLICK_KEY, appPath, key.Id, key.Content)
+ return fmt.Sprintf(_TPL_PUBLICK_KEY, appPath, setting.CustomConf, key.Id, key.Content)
}
var (
)
const (
- TPL_UPDATE_HOOK = "#!/usr/bin/env %s\n%s update $1 $2 $3\n"
+ TPL_UPDATE_HOOK = "#!/usr/bin/env %s\n%s update --config=%s $1 $2 $3\n"
)
var (
// hook/post-update
if err := createHookUpdate(filepath.Join(repoPath, "hooks", "update"),
- fmt.Sprintf(TPL_UPDATE_HOOK, setting.ScriptType, "\""+appPath+"\"")); err != nil {
+ fmt.Sprintf(TPL_UPDATE_HOOK, setting.ScriptType, "\""+appPath+"\"", setting.CustomConf)); err != nil {
return err
}
Cfg *ini.File
ConfRootPath string
CustomPath string // Custom directory path.
+ CustomConf string
ProdMode bool
RunUser string
IsWindows bool
CustomPath = path.Join(workDir, "custom")
}
- cfgPath := path.Join(CustomPath, "conf/app.ini")
- if com.IsFile(cfgPath) {
- if err = Cfg.Append(cfgPath); err != nil {
- log.Fatal(4, "Fail to load custom 'conf/app.ini': %v", err)
+ if len(CustomConf) == 0 {
+ CustomConf = path.Join(CustomPath, "conf/app.ini")
+ }
+
+ if com.IsFile(CustomConf) {
+ if err = Cfg.Append(CustomConf); err != nil {
+ log.Fatal(4, "Fail to load custom conf '%s': %v", CustomConf, err)
}
} else {
- log.Warn("No custom 'conf/app.ini' found, ignore this if you're running first time")
+ log.Warn("Custom config (%s) not found, ignore this if you're running first time", CustomConf)
}
Cfg.NameMapper = ini.AllCapsUnderscore
"os"
"os/exec"
"path"
+ "path/filepath"
"strings"
"github.com/Unknwon/com"
cfg.Section("security").Key("INSTALL_LOCK").SetValue("true")
cfg.Section("security").Key("SECRET_KEY").SetValue(base.GetRandomString(15))
- os.MkdirAll("custom/conf", os.ModePerm)
- if err := cfg.SaveTo(path.Join(setting.CustomPath, "conf/app.ini")); err != nil {
+ os.MkdirAll(filepath.Dir(setting.CustomConf), os.ModePerm)
+ if err := cfg.SaveTo(setting.CustomConf); err != nil {
ctx.RenderWithErr(ctx.Tr("install.save_config_failed", err), INSTALL, &form)
return
}