Пример #1
0
// NewUpstartCommander returns upstart service commander
func NewUpstartCommander() *SvcCommander {
	return &SvcCommander{
		Start:  command.NewCommand(serviceCmd, []string{"start"}...),
		Stop:   command.NewCommand(serviceCmd, []string{"stop"}...),
		Status: command.NewCommand(serviceCmd, []string{"status"}...),
	}
}
Пример #2
0
// NewBaseCommander returns basic service commander
func NewBaseCommander(ctlCmd string) *Commander {
	return &Commander{
		StartCmd:  command.NewCommand(ctlCmd, []string{}...),
		StopCmd:   command.NewCommand(ctlCmd, []string{}...),
		StatusCmd: command.NewCommand(ctlCmd, []string{}...),
	}
}
Пример #3
0
// NewPipManager returns pip Manager or fails with error
func NewPipManager() Manager {
	return &pipManager{
		baseManager: baseManager{
			ListPkgsCmd: command.NewCommand(pip, pipListPkgsCmdArgs...),
			QueryPkgCmd: command.NewCommand(pip, pipQueryPkgCmdArgs...),
			parser:      NewPipParser(),
			pkgType:     "pip",
		},
	}
}
Пример #4
0
// NewGemManager returns gem Manager or fails with error
func NewGemManager() Manager {
	return &gemManager{
		baseManager: baseManager{
			ListPkgsCmd: command.NewCommand(gem, gemListPkgsCmdArgs...),
			QueryPkgCmd: command.NewCommand(gem, gemQueryPkgCmdArgs...),
			parser:      NewGemParser(),
			pkgType:     "gem",
		},
	}
}
Пример #5
0
// NewApkManager returns apk Manager or fails with error
func NewApkManager() Manager {
	return &apkManager{
		baseManager: baseManager{
			ListPkgsCmd: command.NewCommand(apk, apkListPkgsCmdArgs...),
			QueryPkgCmd: command.NewCommand(apk, apkQueryPkgCmdArgs...),
			parser:      NewApkParser(),
			pkgType:     "apk",
		},
	}
}
Пример #6
0
// NewYumManager returns yum Manager or fails with error
func NewYumManager() Manager {
	return &yumManager{
		baseManager: baseManager{
			ListPkgsCmd: command.NewCommand(rpm, rpmListPkgsCmdArgs...),
			QueryPkgCmd: command.NewCommand(rpm, rpmQueryPkgCmdArgs...),
			parser:      NewYumParser(),
			pkgType:     "yum",
		},
	}
}
Пример #7
0
// NewAptManager returns apt Manager or fails with error
func NewAptManager() Manager {
	return &aptManager{
		baseManager: baseManager{
			ListPkgsCmd: command.NewCommand(dpkg, dpkgListPkgsCmdArgs...),
			QueryPkgCmd: command.NewCommand(dpkg, dpkgQueryPkgCmdArgs...),
			parser:      NewAptParser(),
			pkgType:     "apt",
		},
	}
}
Пример #8
0
func TestBuildCmd(t *testing.T) {
	cmd := "foo"
	args := []string{"bar"}
	actCmd := BuildCmd(cmd, args...)
	expCmd := command.NewCommand(cmd, args...)
	assert.Exactly(t, expCmd, actCmd)
}
Пример #9
0
// Stop stops systemd service. It returns error if the service fails to be stopped
func (sm *SystemdInit) Stop(svcName string) error {
	stopCmd := command.NewCommand(systemctl, []string{"stop", svcName + ".service"}...)
	_, err := stopCmd.RunCombined()
	if err != nil {
		return err
	}
	return nil
}
Пример #10
0
// Status queries status of systemd service and returns it.
// It returns error if the status of the queried service could not be determined
func (sm *SystemdInit) Status(svcName string) (service.Status, error) {
	statusCmd := command.NewCommand(systemctl, []string{"status", svcName + ".service"}...)
	status, err := statusCmd.RunCombined()
	if err != nil {
		return service.Unknown, err
	}
	switch {
	case strings.Contains(status, "active (running)"):
		return service.Running, nil
	case strings.Contains(status, "inactive (stopped)"):
		return service.Stopped, nil
	}
	return service.Unknown, fmt.Errorf("Unable to determine %s status", svcName)
}
Пример #11
0
// BuildCmd builds Command from cmd name and arguments
func BuildCmd(cmd string, args ...string) *command.Command {
	return command.NewCommand(cmd, args...)

}
Пример #12
0
// NewGemCommander returns gem command manager
func NewGemCommander() *PkgCommander {
	return &PkgCommander{
		ListPkgs: command.NewCommand(gem, gemListPkgsArgs...),
		QueryPkg: command.NewCommand(gem, gemQueryPkgArgs...),
	}
}
Пример #13
0
// NewPipCommander returns pip command manager
func NewPipCommander() *PkgCommander {
	return &PkgCommander{
		ListPkgs: command.NewCommand(pip, pipListPkgsArgs...),
		QueryPkg: command.NewCommand(pip, pipQueryPkgArgs...),
	}
}
Пример #14
0
// NewYumCommander returns yum command manager
func NewYumCommander() *PkgCommander {
	return &PkgCommander{
		ListPkgs: command.NewCommand(rpm, rpmListPkgsArgs...),
		QueryPkg: command.NewCommand(rpm, rpmQueryPkgArgs...),
	}
}
Пример #15
0
// NewApkCommander returns aptitude command manager
func NewApkCommander() *PkgCommander {
	return &PkgCommander{
		ListPkgs: command.NewCommand(apk, apkListPkgsArgs...),
		QueryPkg: command.NewCommand(apk, apkQueryPkgArgs...),
	}
}
Пример #16
0
// NewAptCommander returns aptitude command manager
func NewAptCommander() *PkgCommander {
	return &PkgCommander{
		ListPkgs: command.NewCommand(dpkg, dpkgListPkgsArgs...),
		QueryPkg: command.NewCommand(dpkg, dpkgQueryPkgArgs...),
	}
}