backy/cmd/exec.go
Andrew Woodlee 4b382bddd9 v0.3.0
* Getting environment variables and passwords from Vault (not tested
yet)
* Vault configuration to config (not tested yet)
* Ability to run scripts from file on local machine on the remote host
* Ability to get ouput in the notification of a list for individual
commands or all commands
* Make SSH connections close after all commands have been run; reuse
previous connections if needed
2023-07-01 21:46:54 -05:00

34 lines
755 B
Go

// exec.go
// Copyright (C) Andrew Woodlee 2023
// License: Apache-2.0
package cmd
import (
"git.andrewnw.xyz/CyberShell/backy/pkg/backy"
"git.andrewnw.xyz/CyberShell/backy/pkg/logging"
"github.com/spf13/cobra"
)
var (
execCmd = &cobra.Command{
Use: "exec command ...",
Short: "Runs commands defined in config file in order given.",
Long: `Exec executes commands defined in config file in order given.`,
Run: execute,
}
)
func execute(cmd *cobra.Command, args []string) {
if len(args) < 1 {
logging.ExitWithMSG("Please provide a command to run. Pass --help to see options.", 0, nil)
}
opts := backy.NewOpts(cfgFile, backy.AddCommands(args))
opts.InitConfig()
// opts.InitMongo()
backy.ReadConfig(opts).ExecuteCmds(opts)
}