()
| 25 | } |
| 26 | |
| 27 | func New() (Controller, error) { |
| 28 | managerOptions := []string{"systemctl", "rc-service", "service"} |
| 29 | for _, item := range managerOptions { |
| 30 | if _, err := exec.LookPath(item); err != nil { |
| 31 | continue |
| 32 | } |
| 33 | switch item { |
| 34 | case "systemctl": |
| 35 | return manager.NewSystemd(), nil |
| 36 | case "rc-service": |
| 37 | return manager.NewOpenrc(), nil |
| 38 | case "service": |
| 39 | return manager.NewSysvinit(), nil |
| 40 | } |
| 41 | } |
| 42 | return nil, errors.New("not support such manager initializatio") |
| 43 | } |
| 44 | |
| 45 | func NewWithClient(client *ssh.SSHClient) (Controller, error) { |
| 46 | managerOptions := []string{"systemctl", "rc-service", "service"} |
no outgoing calls
no test coverage detected