Пример #1
0
func updateCommand() shared.Command {
	cmd := []string{
		"sudo",
		"apt-get",
		"update",
		"-y",
	}

	return shared.NewCommand(strings.Join(cmd, " "))
}
Пример #2
0
func installCommand(args shared.Args) shared.Command {
	packages := shared.ExtractOptions(args.Options["packages"])

	cmd := []string{
		"sudo",
		"apt-get",
		"install",
		"-y",
		strings.Join(packages, " "),
	}

	return shared.NewCommand(strings.Join(cmd, " "))
}
Пример #3
0
func (t *Command) Execute(args shared.Args, reply *shared.Response) error {
	cmd := []string{
		"ping",
	}

	if count, ok := args.Options["count"]; ok {
		c := count.(float64)
		cmd = append(cmd, fmt.Sprintf("-c %v", c))
	}

	cmd = append(cmd, shared.ExtractString(args.Options["url"]))
	*reply = shared.NewResponse(shared.NewCommand(strings.Join(cmd, " ")))

	return nil
}
Пример #4
0
func (t *Command) Execute(args shared.Args, reply *shared.Response) error {
	directory := args.Options["directory"].(string)

	a := []string{
		"git",
		"clone",
		args.Options["repo"].(string),
		directory,
	}

	cmd := shared.NewCommand(strings.Join(a, " "))
	cmd.Unless(shared.DirectoryExists(directory))

	*reply = shared.NewResponse(cmd)

	return nil
}
Пример #5
0
func (t *Command) Execute(args shared.Args, reply *shared.Response) error {
	*reply = shared.NewResponse(shared.NewCommand("whoami"))

	return nil
}