예제 #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
파일: gem.go 프로젝트: agonzalezro/servpeek
// NewGemCommander returns gem command manager
func NewGemCommander() *PkgCommander {
	return &PkgCommander{
		ListPkgs: command.NewCommand(gem, gemListPkgsArgs...),
		QueryPkg: command.NewCommand(gem, gemQueryPkgArgs...),
	}
}
예제 #13
0
파일: pip.go 프로젝트: agonzalezro/servpeek
// NewPipCommander returns pip command manager
func NewPipCommander() *PkgCommander {
	return &PkgCommander{
		ListPkgs: command.NewCommand(pip, pipListPkgsArgs...),
		QueryPkg: command.NewCommand(pip, pipQueryPkgArgs...),
	}
}
예제 #14
0
파일: yum.go 프로젝트: agonzalezro/servpeek
// NewYumCommander returns yum command manager
func NewYumCommander() *PkgCommander {
	return &PkgCommander{
		ListPkgs: command.NewCommand(rpm, rpmListPkgsArgs...),
		QueryPkg: command.NewCommand(rpm, rpmQueryPkgArgs...),
	}
}
예제 #15
0
파일: apk.go 프로젝트: agonzalezro/servpeek
// NewApkCommander returns aptitude command manager
func NewApkCommander() *PkgCommander {
	return &PkgCommander{
		ListPkgs: command.NewCommand(apk, apkListPkgsArgs...),
		QueryPkg: command.NewCommand(apk, apkQueryPkgArgs...),
	}
}
예제 #16
0
파일: apt.go 프로젝트: agonzalezro/servpeek
// NewAptCommander returns aptitude command manager
func NewAptCommander() *PkgCommander {
	return &PkgCommander{
		ListPkgs: command.NewCommand(dpkg, dpkgListPkgsArgs...),
		QueryPkg: command.NewCommand(dpkg, dpkgQueryPkgArgs...),
	}
}