forked from forgejo/forgejo
Add gogs fix location command
This commit is contained in:
parent
f160b4f33c
commit
a3e1383cac
10 changed files with 179 additions and 40 deletions
|
@ -46,7 +46,9 @@ func LoadModelsConfig() {
|
|||
DbCfg.Host = setting.Cfg.MustValue("database", "HOST")
|
||||
DbCfg.Name = setting.Cfg.MustValue("database", "NAME")
|
||||
DbCfg.User = setting.Cfg.MustValue("database", "USER")
|
||||
DbCfg.Pwd = setting.Cfg.MustValue("database", "PASSWD")
|
||||
if len(DbCfg.Pwd) == 0 {
|
||||
DbCfg.Pwd = setting.Cfg.MustValue("database", "PASSWD")
|
||||
}
|
||||
DbCfg.SslMode = setting.Cfg.MustValue("database", "SSL_MODE")
|
||||
DbCfg.Path = setting.Cfg.MustValue("database", "PATH", "data/gogs.db")
|
||||
}
|
||||
|
@ -67,7 +69,6 @@ func NewTestEngine(x *xorm.Engine) (err error) {
|
|||
}
|
||||
cnnstr := fmt.Sprintf("user=%s password=%s host=%s port=%s dbname=%s sslmode=%s",
|
||||
DbCfg.User, DbCfg.Pwd, host, port, DbCfg.Name, DbCfg.SslMode)
|
||||
//fmt.Println(cnnstr)
|
||||
x, err = xorm.NewEngine("postgres", cnnstr)
|
||||
case "sqlite3":
|
||||
if !EnableSQLite3 {
|
||||
|
|
|
@ -37,7 +37,7 @@ var (
|
|||
var sshOpLocker = sync.Mutex{}
|
||||
|
||||
var (
|
||||
sshPath string // SSH directory.
|
||||
SshPath string // SSH directory.
|
||||
appPath string // Execution(binary) path.
|
||||
)
|
||||
|
||||
|
@ -67,9 +67,9 @@ func init() {
|
|||
}
|
||||
|
||||
// Determine and create .ssh path.
|
||||
sshPath = filepath.Join(homeDir(), ".ssh")
|
||||
if err = os.MkdirAll(sshPath, os.ModePerm); err != nil {
|
||||
qlog.Fatalf("publickey.init(fail to create sshPath(%s)): %v\n", sshPath, err)
|
||||
SshPath = filepath.Join(homeDir(), ".ssh")
|
||||
if err = os.MkdirAll(SshPath, os.ModePerm); err != nil {
|
||||
qlog.Fatalf("publickey.init(fail to create SshPath(%s)): %v\n", SshPath, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ func saveAuthorizedKeyFile(key *PublicKey) error {
|
|||
sshOpLocker.Lock()
|
||||
defer sshOpLocker.Unlock()
|
||||
|
||||
fpath := filepath.Join(sshPath, "authorized_keys")
|
||||
fpath := filepath.Join(SshPath, "authorized_keys")
|
||||
f, err := os.OpenFile(fpath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0600)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -216,8 +216,8 @@ func DeletePublicKey(key *PublicKey) error {
|
|||
return err
|
||||
}
|
||||
|
||||
fpath := filepath.Join(sshPath, "authorized_keys")
|
||||
tmpPath := filepath.Join(sshPath, "authorized_keys.tmp")
|
||||
fpath := filepath.Join(SshPath, "authorized_keys")
|
||||
tmpPath := filepath.Join(SshPath, "authorized_keys.tmp")
|
||||
log.Trace("publickey.DeletePublicKey(authorized_keys): %s", fpath)
|
||||
|
||||
if err = rewriteAuthorizedKeys(key, fpath, tmpPath); err != nil {
|
||||
|
|
|
@ -28,6 +28,10 @@ import (
|
|||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
const (
|
||||
TPL_UPDATE_HOOK = "#!/usr/bin/env %s\n%s update $1 $2 $3\n"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrRepoAlreadyExist = errors.New("Repository already exist")
|
||||
ErrRepoNotExist = errors.New("Repository does not exist")
|
||||
|
@ -450,7 +454,7 @@ func initRepository(f string, user *User, repo *Repository, initReadme bool, rep
|
|||
rp := strings.NewReplacer("\\", "/", " ", "\\ ")
|
||||
// hook/post-update
|
||||
if err := createHookUpdate(filepath.Join(repoPath, "hooks", "update"),
|
||||
fmt.Sprintf("#!/usr/bin/env %s\n%s update $1 $2 $3\n", setting.ScriptType,
|
||||
fmt.Sprintf(TPL_UPDATE_HOOK, setting.ScriptType,
|
||||
rp.Replace(appPath))); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue