fix: 解决 nexus 安装失败的问题 (#461)

This commit is contained in:
zhengkunwang223 2023-03-31 12:16:14 +08:00 committed by GitHub
parent 4ad3b82c84
commit 3457b99df6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 0 deletions

View File

@ -257,6 +257,9 @@ func (a AppService) Install(ctx context.Context, req request.AppInstallCreate) (
if err := createLink(ctx, app, &appInstall, req.Params); err != nil {
return nil, err
}
if err := upAppPre(app, appInstall); err != nil {
return nil, err
}
go upApp(appInstall.GetComposePath(), appInstall)
go updateToolApp(appInstall)
return &appInstall, nil

View File

@ -339,6 +339,17 @@ func copyAppData(key, version, installName string, params map[string]interface{}
return
}
// 处理文件夹权限等问题
func upAppPre(app model.App, appInstall model.AppInstall) error {
if app.Key == "nexus" {
dataPath := path.Join(appInstall.GetPath(), "data")
if err := files.NewFileOp().Chown(dataPath, 200, 0); err != nil {
return err
}
}
return nil
}
func upApp(composeFilePath string, appInstall model.AppInstall) {
out, err := compose.Up(composeFilePath)
if err != nil {

View File

@ -106,6 +106,10 @@ func (f FileOp) Chmod(dst string, mode fs.FileMode) error {
return f.Fs.Chmod(dst, mode)
}
func (f FileOp) Chown(dst string, uid int, gid int) error {
return f.Fs.Chown(dst, uid, gid)
}
func (f FileOp) Rename(oldName string, newName string) error {
return f.Fs.Rename(oldName, newName)
}