mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 03:07:20 +08:00
fix: 阻止酒吧点炒饭
This commit is contained in:
@@ -369,6 +369,9 @@ func (r *projectRepo) parsePercent(value string) (float64, error) {
|
||||
|
||||
// generateUnitFile 生成 systemd unit 文件
|
||||
func (r *projectRepo) generateUnitFile(req *request.ProjectCreate) error {
|
||||
req.RootDir = lo.If(!strings.HasPrefix(req.RootDir, "/"), filepath.Join("/", req.RootDir)).Else(req.RootDir)
|
||||
req.WorkingDir = lo.If(req.WorkingDir != "", req.WorkingDir).Else(req.RootDir)
|
||||
req.WorkingDir = lo.If(!strings.HasPrefix(req.WorkingDir, "/"), filepath.Join("/", req.WorkingDir)).Else(req.WorkingDir)
|
||||
options := []*unit.UnitOption{
|
||||
// [Unit] section
|
||||
unit.NewUnitOption("Unit", "Description", req.Description),
|
||||
@@ -376,7 +379,7 @@ func (r *projectRepo) generateUnitFile(req *request.ProjectCreate) error {
|
||||
|
||||
// [Service] section
|
||||
unit.NewUnitOption("Service", "Type", "simple"),
|
||||
unit.NewUnitOption("Service", "WorkingDirectory", lo.If(req.WorkingDir != "", req.WorkingDir).Else(req.RootDir)),
|
||||
unit.NewUnitOption("Service", "WorkingDirectory", req.WorkingDir),
|
||||
}
|
||||
|
||||
if req.ExecStart != "" {
|
||||
@@ -416,6 +419,10 @@ func (r *projectRepo) generateUnitFile(req *request.ProjectCreate) error {
|
||||
|
||||
// updateUnitFile 更新 systemd unit 文件
|
||||
func (r *projectRepo) updateUnitFile(name string, req *request.ProjectUpdate) error {
|
||||
req.RootDir = lo.If(!strings.HasPrefix(req.RootDir, "/"), filepath.Join("/", req.RootDir)).Else(req.RootDir)
|
||||
req.WorkingDir = lo.If(req.WorkingDir != "", req.WorkingDir).Else(req.RootDir)
|
||||
req.WorkingDir = lo.If(!strings.HasPrefix(req.WorkingDir, "/"), filepath.Join("/", req.WorkingDir)).Else(req.WorkingDir)
|
||||
|
||||
options := []*unit.UnitOption{
|
||||
// [Unit] section
|
||||
unit.NewUnitOption("Unit", "Description", req.Description),
|
||||
@@ -440,7 +447,7 @@ func (r *projectRepo) updateUnitFile(name string, req *request.ProjectUpdate) er
|
||||
|
||||
// [Service] section
|
||||
options = append(options, unit.NewUnitOption("Service", "Type", "simple"))
|
||||
options = append(options, unit.NewUnitOption("Service", "WorkingDirectory", lo.If(req.WorkingDir != "", req.WorkingDir).Else(req.RootDir)))
|
||||
options = append(options, unit.NewUnitOption("Service", "WorkingDirectory", req.WorkingDir))
|
||||
|
||||
if req.ExecStartPre != "" {
|
||||
options = append(options, unit.NewUnitOption("Service", "ExecStartPre", req.ExecStartPre))
|
||||
|
||||
@@ -8,14 +8,14 @@ type ToolboxDiskDevice struct {
|
||||
// ToolboxDiskMount 挂载请求
|
||||
type ToolboxDiskMount struct {
|
||||
Device string `form:"device" json:"device" validate:"required"`
|
||||
Path string `form:"path" json:"path" validate:"required"`
|
||||
Path string `form:"path" json:"path" validate:"required|isUnixPath"`
|
||||
WriteFstab bool `form:"write_fstab" json:"write_fstab"`
|
||||
MountOption string `form:"mount_option" json:"mount_option"`
|
||||
}
|
||||
|
||||
// ToolboxDiskUmount 卸载请求
|
||||
type ToolboxDiskUmount struct {
|
||||
Path string `form:"path" json:"path" validate:"required"`
|
||||
Path string `form:"path" json:"path" validate:"required|isUnixPath"`
|
||||
}
|
||||
|
||||
// ToolboxDiskFormat 格式化请求
|
||||
@@ -44,12 +44,12 @@ type ToolboxDiskVGName struct {
|
||||
|
||||
// ToolboxDiskLVPath 逻辑卷路径请求
|
||||
type ToolboxDiskLVPath struct {
|
||||
Path string `form:"path" json:"path" validate:"required"`
|
||||
Path string `form:"path" json:"path" validate:"required|isUnixPath"`
|
||||
}
|
||||
|
||||
// ToolboxDiskExtendLV 扩容逻辑卷请求
|
||||
type ToolboxDiskExtendLV struct {
|
||||
Path string `form:"path" json:"path" validate:"required"`
|
||||
Path string `form:"path" json:"path" validate:"required|isUnixPath"`
|
||||
Size int `form:"size" json:"size" validate:"required|min:1"`
|
||||
Resize bool `form:"resize" json:"resize"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user