Exemplo n.º 1
0
func updateCommand() shared.Command {
	cmd := []string{
		"sudo",
		"apt-get",
		"update",
		"-y",
	}

	return shared.NewCommand(strings.Join(cmd, " "))
}
Exemplo n.º 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, " "))
}
Exemplo n.º 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
}
Exemplo n.º 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
}
Exemplo n.º 5
0
func (t *Command) Execute(args shared.Args, reply *shared.Response) error {
	*reply = shared.NewResponse(shared.NewCommand("whoami"))

	return nil
}