You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
566 B
Go
30 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
|
|
}
|