mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-24 22:51:19 +08:00
29 lines
566 B
Go
29 lines
566 B
Go
package service
|
|
|
|
import (
|
|
"github.com/1Panel-dev/1Panel/agent/app/dto/response"
|
|
"os/exec"
|
|
)
|
|
|
|
type SystemService struct{}
|
|
|
|
type ISystemService interface {
|
|
IsComponentExist(name string) response.ComponentInfo
|
|
}
|
|
|
|
func NewISystemService() ISystemService {
|
|
return &SystemService{}
|
|
}
|
|
|
|
func (s *SystemService) IsComponentExist(name string) response.ComponentInfo {
|
|
info := response.ComponentInfo{}
|
|
path, err := exec.LookPath(name)
|
|
if err != nil {
|
|
info.Exists = false
|
|
info.Error = err.Error()
|
|
return info
|
|
}
|
|
info.Exists = true
|
|
info.Path = path
|
|
return info
|
|
}
|